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