Commit 8d1d656b authored by chechunchi's avatar chechunchi

Revert "refactor: store"

This reverts commit d65485b1.
parent d65485b1
Pipeline #22166 passed with stages
in 16 minutes and 52 seconds
...@@ -6,8 +6,8 @@ import { subscribeKey } from "valtio/utils"; ...@@ -6,8 +6,8 @@ import { subscribeKey } from "valtio/utils";
import { fetchCard, ygopro } from "@/api"; import { fetchCard, ygopro } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { sleep } from "@/infra"; import { sleep } from "@/infra";
import { cardStore, CardType, matStore } from "@/stores"; import { cardStore, CardType, store } from "@/stores";
const { matStore } = store;
const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token
export default async (start: ygopro.StocGameMessage.MsgStart) => { export default async (start: ygopro.StocGameMessage.MsgStart) => {
......
...@@ -7,6 +7,7 @@ export * from "./methods"; ...@@ -7,6 +7,7 @@ export * from "./methods";
export * from "./moraStore"; export * from "./moraStore";
export * from "./placeStore"; export * from "./placeStore";
import { proxy } from "valtio";
import { devtools } from "valtio/utils"; import { devtools } from "valtio/utils";
import { cardStore } from "./cardStore"; import { cardStore } from "./cardStore";
...@@ -17,10 +18,14 @@ import { messageStore } from "./messageStore"; ...@@ -17,10 +18,14 @@ import { messageStore } from "./messageStore";
import { moraStore } from "./moraStore"; import { moraStore } from "./moraStore";
import { placeStore } from "./placeStore"; import { placeStore } from "./placeStore";
devtools(chatStore, { name: "chat store", enabled: true }); export const store = proxy({
devtools(joinStore, { name: "join store", enabled: true }); chatStore,
devtools(moraStore, { name: "mora store", enabled: true }); joinStore,
devtools(matStore, { name: "mat store", enabled: true }); moraStore,
devtools(messageStore, { name: "message store", enabled: true }); matStore, // 决斗盘
devtools(cardStore, { name: "card store", enabled: true }); messageStore, // 决斗的信息,包括模态框
devtools(placeStore, { name: "place store", enabled: true }); cardStore,
placeStore,
});
devtools(store, { name: "valtio store", enabled: true });
...@@ -94,7 +94,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -94,7 +94,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
useEffect(() => { useEffect(() => {
setHighlight(!!snap.idleInteractivities.length); setHighlight(!!snap.idleInteractivities.length);
}, [snap.idleInteractivities.length]); }, [snap.idleInteractivities]);
return ( return (
<animated.div <animated.div
......
...@@ -30,7 +30,7 @@ import { DeckManager, fetchDeck, type IDeck } from "@/api/deck"; ...@@ -30,7 +30,7 @@ import { DeckManager, fetchDeck, type IDeck } from "@/api/deck";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import socketMiddleWare, { socketCmd } from "@/middleware/socket"; import socketMiddleWare, { socketCmd } from "@/middleware/socket";
import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite"; import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
import { chatStore, joinStore, matStore, moraStore } from "@/stores"; import { store } from "@/stores";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
...@@ -42,10 +42,8 @@ const { ...@@ -42,10 +42,8 @@ const {
} = useConfig(); } = useConfig();
const WaitRoom = () => { const WaitRoom = () => {
const snapJoin = useSnapshot(joinStore); const state = store;
const snapChat = useSnapshot(chatStore); const snap = useSnapshot(state);
const snapMat = useSnapshot(matStore);
const snapMora = useSnapshot(moraStore);
const params = useParams<{ const params = useParams<{
player?: string; player?: string;
passWd?: string; passWd?: string;
...@@ -91,12 +89,12 @@ const WaitRoom = () => { ...@@ -91,12 +89,12 @@ const WaitRoom = () => {
const [api, contextHolder] = notification.useNotification(); const [api, contextHolder] = notification.useNotification();
const joined = snapJoin.value; const joined = snap.joinStore.value;
const chat = snapChat.message; const chat = snap.chatStore.message;
const isHost = snapMat.isHost; const isHost = snap.matStore.isHost;
const player0 = snapMat.player[0]; const player0 = snap.matStore.player[0];
const player1 = snapMat.player[1]; const player1 = snap.matStore.player[1];
const duelStart = snapMora.duelStart; const duelStart = snap.moraStore.duelStart;
// FIXME: 这些数据应该从`store`中获取 // FIXME: 这些数据应该从`store`中获取
// TODO: 云卡组 // TODO: 云卡组
......
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