Commit 1a497adb authored by Chunchi Che's avatar Chunchi Che

fix Menu.tsx

parent defc2a80
Pipeline #22830 passed with stages
in 14 minutes and 14 seconds
......@@ -40,5 +40,4 @@ export const resetUniverse = () => {
placeStore.reset();
playerStore.reset();
replayStore.reset();
accountStore.reset();
};
......@@ -35,6 +35,9 @@ export const Menu = () => {
const snapPhase = useSnapshot(phase);
const { currentPlayer } = useSnapshot(matStore);
const currentPhase = snapPhase.currentPhase;
const enableBp = snapPhase.enableBp;
const enableM2 = snapPhase.enableM2;
const enableEp = snapPhase.enableEp;
const clearAllIdleInteractivities = () => {
for (const card of cardStore.inner) {
......@@ -72,18 +75,36 @@ export const Menu = () => {
[PhaseType.UNKNOWN, "未知阶段", -1, false],
];
const checkPhaseEnabled = (phase: PhaseType) => {
switch (phase) {
case PhaseType.BATTLE:
return enableBp;
case PhaseType.MAIN2:
return enableM2;
case PhaseType.END:
return enableEp;
default:
return true;
}
};
const phaseSwitchItems: MenuProps["items"] = phaseBind
.filter(([, , , show]) => show)
.map(([phase, label, response], key) => ({
key,
label,
disabled: currentPhase >= phase,
disabled: currentPhase >= phase || !checkPhaseEnabled(phase),
onClick: () => {
if (response === 2) sendSelectIdleCmdResponse(response);
else sendSelectBattleCmdResponse(response);
clearAllIdleInteractivities();
},
icon: currentPhase >= phase ? <CheckOutlined /> : <ArrowRightOutlined />,
icon:
currentPhase >= phase || !checkPhaseEnabled(phase) ? (
<CheckOutlined />
) : (
<ArrowRightOutlined />
),
danger: phase === PhaseType.END,
}));
......
......@@ -12,7 +12,7 @@ const NeosConfig = useConfig();
const DefaultUserName = "Guest";
const Home: React.FC = () => {
const { user } = useSnapshot(accountStore);
const user = useSnapshot(accountStore).user;
const navigate = useNavigate();
const onLogout = () => {}; // 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