Commit 64510003 authored by timel's avatar timel

refactor: 80%

parent dbbf2469
import "./index.scss"; import styles from "./index.module.scss";
import { import {
ArrowRightOutlined, ArrowRightOutlined,
...@@ -53,7 +53,12 @@ export const Menu = () => { ...@@ -53,7 +53,12 @@ export const Menu = () => {
: 7; : 7;
// PhaseType, 中文, response, 是否显示 // PhaseType, 中文, response, 是否显示
const phaseBind: [PhaseType, string, number, boolean][] = [ const phaseBind: [
phase: PhaseType,
label: string,
response: number,
show: boolean
][] = [
[PhaseType.DRAW, "抽卡阶段", -1, true], [PhaseType.DRAW, "抽卡阶段", -1, true],
[PhaseType.STANDBY, "准备阶段", -1, true], [PhaseType.STANDBY, "准备阶段", -1, true],
[PhaseType.MAIN1, "主要阶段 1", -1, true], [PhaseType.MAIN1, "主要阶段 1", -1, true],
...@@ -69,9 +74,9 @@ export const Menu = () => { ...@@ -69,9 +74,9 @@ export const Menu = () => {
const phaseSwitchItems: MenuProps["items"] = phaseBind const phaseSwitchItems: MenuProps["items"] = phaseBind
.filter(([, , , show]) => show) .filter(([, , , show]) => show)
.map(([phase, str, response], i) => ({ .map(([phase, label, response], key) => ({
key: i, key,
label: str, label,
disabled: currentPhase >= phase, disabled: currentPhase >= phase,
onClick: () => { onClick: () => {
if (response === 2) sendSelectIdleCmdResponse(response); if (response === 2) sendSelectIdleCmdResponse(response);
...@@ -95,37 +100,35 @@ export const Menu = () => { ...@@ -95,37 +100,35 @@ export const Menu = () => {
const globalDisable = !matStore.isMe(currentPlayer); const globalDisable = !matStore.isMe(currentPlayer);
return ( return (
<> <div className={styles["menu-container"]}>
<div className="menu-container"> <DropdownWithTitle
<DropdownWithTitle title="请选择要进入的阶段"
title="请选择要进入的阶段" menu={{ items: phaseSwitchItems }}
menu={{ items: phaseSwitchItems }} disabled={globalDisable}
>
<Button
icon={<StepForwardFilled style={{ transform: "scale(1.5)" }} />}
type="text"
disabled={globalDisable} disabled={globalDisable}
> >
<Button {phaseBind.find(([key]) => key === currentPhase)?.[1]}
icon={<StepForwardFilled style={{ transform: "scale(1.5)" }} />} </Button>
type="text" </DropdownWithTitle>
disabled={globalDisable} <Tooltip title="聊天室">
> <Button
{phaseBind.find(([key]) => key === currentPhase)?.[1]} icon={<MessageFilled />}
</Button> type="text"
</DropdownWithTitle>
<Tooltip title="聊天室">
<Button
icon={<MessageFilled />}
type="text"
disabled={globalDisable}
></Button>
</Tooltip>
<DropdownWithTitle
title="是否投降?"
menu={{ items: surrenderMenuItems }}
disabled={globalDisable} disabled={globalDisable}
> ></Button>
<Button icon={<CloseCircleFilled />} type="text"></Button> </Tooltip>
</DropdownWithTitle> <DropdownWithTitle
</div> title="是否投降?"
</> menu={{ items: surrenderMenuItems }}
disabled={globalDisable}
>
<Button icon={<CloseCircleFilled />} type="text"></Button>
</DropdownWithTitle>
</div>
); );
}; };
......
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