Commit 55f0b27c authored by chechunchi's avatar chechunchi

optimize Menu.tsx

parent e2bf6c92
Pipeline #21506 passed with stages
in 16 minutes and 27 seconds
import "@/styles/mat.css";
import Icon from "@ant-design/icons";
import { Button, Modal } from "antd";
import { ReactComponent as BattleSvg } from "neos-assets/crossed-swords.svg";
import { ReactComponent as EpSvg } from "neos-assets/power-button.svg";
import { ReactComponent as Main2Svg } from "neos-assets/sword-in-stone.svg";
import { ReactComponent as SurrenderSvg } from "neos-assets/truce.svg";
import React, { useState } from "react";
import { useSnapshot } from "valtio";
......@@ -19,23 +14,15 @@ import {
matStore,
} from "@/stores";
const IconSize = "150%";
const PhaseButton = (props: {
text: string;
enable: boolean;
onClick: () => void;
icon?: React.ReactNode;
}) => {
return (
<Button
icon={props.icon}
disabled={!props.enable}
onClick={props.onClick}
size="large"
>
<button disabled={!props.enable} onClick={props.onClick}>
{props.text}
</Button>
</button>
);
};
......@@ -61,20 +48,20 @@ export const Menu = () => {
const onBp = () => {
sendSelectIdleCmdResponse(6);
clearAllIdleInteractivities(0); // 为什么要clear两次?
clearAllIdleInteractivities(0);
clearAllIdleInteractivities(1);
phase.enableBp = false;
};
const onM2 = () => {
sendSelectBattleCmdResponse(2);
clearAllIdleInteractivities(0);
clearAllIdleInteractivities(0);
clearAllIdleInteractivities(1);
phase.enableM2 = false;
};
const onEp = () => {
sendSelectIdleCmdResponse(response);
clearAllIdleInteractivities(0);
clearAllIdleInteractivities(0);
clearAllIdleInteractivities(1);
phase.enableEp = false;
};
const onSurrender = () => {
......@@ -83,30 +70,16 @@ export const Menu = () => {
return (
<div id="controller">
<PhaseButton
icon={<Icon component={BattleSvg} style={{ fontSize: IconSize }} />}
enable={enableBp}
text="战斗阶段"
onClick={onBp}
/>
<PhaseButton
icon={<Icon component={Main2Svg} style={{ fontSize: IconSize }} />}
enable={enableM2}
text="主要阶段2"
onClick={onM2}
/>
<PhaseButton
icon={<Icon component={EpSvg} style={{ fontSize: IconSize }} />}
enable={enableEp}
text="结束回合"
onClick={onEp}
/>
<PhaseButton
icon={<Icon component={SurrenderSvg} style={{ fontSize: IconSize }} />}
enable={true}
text="投降"
onClick={onSurrender}
/>
<button disabled={!enableBp} onClick={onBp}>
战斗阶段
</button>
<button disabled={!enableM2} onClick={onM2}>
主要阶段2
</button>
<button disabled={!enableEp} onClick={onEp}>
结束回合
</button>
<button onClick={onSurrender}>投降</button>
<Modal
title="是否确认要投降?"
open={modalOpen}
......
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