Commit d49f1d95 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/feedback' into 'main'

修复组卡页卡组全删后出现的crash,卡片选择弹窗区分敌我卡片

See merge request !297
parents 07eb4ed6 78548c51
Pipeline #23382 passed with stages
in 13 minutes and 41 seconds
...@@ -13,6 +13,8 @@ export interface IDeck { ...@@ -13,6 +13,8 @@ export interface IDeck {
side: number[]; side: number[];
} }
export const emptyDeck: IDeck = { deckName: "", main: [], extra: [], side: [] };
export const deckStore = proxy({ export const deckStore = proxy({
decks: [] as IDeck[], decks: [] as IDeck[],
......
import { proxy } from "valtio"; import { proxy } from "valtio";
import { IDeck } from "./deckStore"; import { emptyDeck, IDeck } from "./deckStore";
import { type NeosStore } from "./shared"; import { type NeosStore } from "./shared";
export enum SideStage { export enum SideStage {
...@@ -13,8 +13,6 @@ export enum SideStage { ...@@ -13,8 +13,6 @@ export enum SideStage {
WAITING = 8, // 观战者等待双方玩家 WAITING = 8, // 观战者等待双方玩家
} }
const emptyDeck: IDeck = { deckName: "", main: [], extra: [], side: [] };
class SideStore implements NeosStore { class SideStore implements NeosStore {
stage: SideStage = SideStage.NONE; stage: SideStage = SideStage.NONE;
deck: IDeck = emptyDeck; deck: IDeck = emptyDeck;
......
...@@ -29,7 +29,7 @@ import { subscribeKey } from "valtio/utils"; ...@@ -29,7 +29,7 @@ import { subscribeKey } from "valtio/utils";
import { type CardMeta, searchCards } from "@/api"; import { type CardMeta, searchCards } from "@/api";
import { isExtraDeckCard, isToken } from "@/common"; import { isExtraDeckCard, isToken } from "@/common";
import { FtsConditions } from "@/middleware/sqlite/fts"; import { FtsConditions } from "@/middleware/sqlite/fts";
import { deckStore, type IDeck, initStore } from "@/stores"; import { deckStore, emptyDeck, type IDeck, initStore } from "@/stores";
import { import {
Background, Background,
DeckCard, DeckCard,
...@@ -74,7 +74,9 @@ export const loader: LoaderFunction = async () => { ...@@ -74,7 +74,9 @@ export const loader: LoaderFunction = async () => {
export const Component: React.FC = () => { export const Component: React.FC = () => {
const snapDecks = useSnapshot(deckStore); const snapDecks = useSnapshot(deckStore);
const { progress } = useSnapshot(initStore.sqlite); const { progress } = useSnapshot(initStore.sqlite);
const [selectedDeck, setSelectedDeck] = useState<IDeck>(deckStore.decks[0]); const [selectedDeck, setSelectedDeck] = useState<IDeck>(
deckStore.decks.at(0) ?? emptyDeck,
);
const { message } = App.useApp(); const { message } = App.useApp();
...@@ -107,7 +109,7 @@ export const Component: React.FC = () => { ...@@ -107,7 +109,7 @@ export const Component: React.FC = () => {
decks={snapDecks.decks} decks={snapDecks.decks}
selected={selectedDeck.deckName} selected={selectedDeck.deckName}
onSelect={(name) => onSelect={(name) =>
setSelectedDeck(deckStore.get(name) ?? deckStore.decks[0]) setSelectedDeck(deckStore.get(name) ?? emptyDeck)
} }
onDelete={async (name) => await deckStore.delete(name)} onDelete={async (name) => await deckStore.delete(name)}
onDownload={(name) => { onDownload={(name) => {
......
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
margin-inline-end: 0; margin-inline-end: 0;
margin-block-end: 0; margin-block-end: 0;
flex-shrink: 0; flex-shrink: 0;
&.opponent {
&::before {
background-color: #dc003433;
box-shadow: 0 0 0 2px #d22d2d inset;
}
}
} }
.card { .card {
......
import { CheckCard } from "@ant-design/pro-components"; import { CheckCard } from "@ant-design/pro-components";
import { Button, Card, Segmented, Space, Tooltip } from "antd"; import { Button, Card, Segmented, Space, Tooltip } from "antd";
import classnames from "classnames";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio"; import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import { type CardMeta, Region, type ygopro } from "@/api"; import { type CardMeta, Region, type ygopro } from "@/api";
import { fetchStrings } from "@/api"; import { fetchStrings } from "@/api";
import { CardType, matStore } from "@/stores"; import { CardType, isMe, matStore } from "@/stores";
import { YgoCard } from "@/ui/Shared"; import { YgoCard } from "@/ui/Shared";
import { groupBy } from "../../utils"; import { groupBy } from "../../utils";
...@@ -176,7 +177,11 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -176,7 +177,11 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
className={styles.card} className={styles.card}
/> />
} }
className={styles["check-card"]} className={classnames(styles["check-card"], {
[styles.opponent]:
card.location?.controller !== undefined &&
!isMe(card.location.controller),
})}
value={card} value={card}
onClick={() => { onClick={() => {
showCardModal(card); showCardModal(card);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment