Commit 0f8e3afa authored by timel's avatar timel Committed by Chunchi Che

feat: update select action modal

parent 7ace8dc5
...@@ -19,13 +19,7 @@ import { NewSelectActionsModal } from "./Message/NewSelectActionModal"; ...@@ -19,13 +19,7 @@ import { NewSelectActionsModal } from "./Message/NewSelectActionModal";
const NeosDuel = () => { const NeosDuel = () => {
return ( return (
<> <>
<NewSelectActionsModal <NewSelectActionsModal />
isValid
isChain
selecteds={[]}
selectables={[]}
mustSelects={[]}
/>
<Alert /> <Alert />
<Menu /> <Menu />
<LifeBar /> <LifeBar />
...@@ -33,7 +27,7 @@ const NeosDuel = () => { ...@@ -33,7 +27,7 @@ const NeosDuel = () => {
<CardModal /> <CardModal />
<CardListModal /> <CardListModal />
<HintNotification /> <HintNotification />
<SelectActionsModal /> {/* <SelectActionsModal /> */}
<YesNoModal /> <YesNoModal />
<PositionModal /> <PositionModal />
<OptionModal /> <OptionModal />
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
Segmented, Segmented,
Space, Space,
Typography, Typography,
Tooltip,
} from "antd"; } from "antd";
import { type FC, useState, useEffect } from "react"; import { type FC, useState, useEffect } from "react";
import { useSnapshot, proxy } from "valtio"; import { useSnapshot, proxy } from "valtio";
...@@ -33,7 +34,6 @@ const FINISH_RESPONSE = -1; ...@@ -33,7 +34,6 @@ const FINISH_RESPONSE = -1;
const defaultProps = { const defaultProps = {
isOpen: false, isOpen: false,
title: "是否要进行连锁", // 模态框标题
isValid: false, // FIXME 看起来是最小化用的,看情况是否需要删掉 isValid: false, // FIXME 看起来是最小化用的,看情况是否需要删掉
isChain: false, isChain: false,
min: 0, min: 0,
...@@ -52,7 +52,6 @@ const localStore = proxy(defaultProps); ...@@ -52,7 +52,6 @@ const localStore = proxy(defaultProps);
export const NewSelectActionsModal: FC = () => { export const NewSelectActionsModal: FC = () => {
const { const {
title,
isOpen, isOpen,
isValid, isValid,
isChain, isChain,
...@@ -75,6 +74,8 @@ export const NewSelectActionsModal: FC = () => { ...@@ -75,6 +74,8 @@ export const NewSelectActionsModal: FC = () => {
const preHintMsg = hint?.esHint || ""; const preHintMsg = hint?.esHint || "";
const selectHintMsg = hint?.esSelectHint || "请选择卡片"; const selectHintMsg = hint?.esSelectHint || "请选择卡片";
const minMaxText = min === max ? min : `${min}-${max}`;
// 判断是否可以提交 // 判断是否可以提交
useEffect(() => { useEffect(() => {
const [sumLevel1, sumLevel2] = (["level1", "level2"] as const).map((key) => const [sumLevel1, sumLevel2] = (["level1", "level2"] as const).map((key) =>
...@@ -129,7 +130,13 @@ export const NewSelectActionsModal: FC = () => { ...@@ -129,7 +130,13 @@ export const NewSelectActionsModal: FC = () => {
return ( return (
<NewModal <NewModal
title={title} title={
<>
<span>{preHintMsg}</span>
<span>{selectHintMsg}</span>
<span>(请选择 {single ? 1 : minMaxText} 张卡)</span>
</>
} // TODO: 这里可以再细化一些
width={600} width={600}
okButtonProps={{ okButtonProps={{
disabled: !submitable, disabled: !submitable,
...@@ -172,18 +179,21 @@ export const NewSelectActionsModal: FC = () => { ...@@ -172,18 +179,21 @@ export const NewSelectActionsModal: FC = () => {
}} }}
> >
{options[1].map((card, j) => ( {options[1].map((card, j) => (
<CheckCard <Tooltip title={card.effectDesc} placement="bottom" key={j}>
cover={<YgoCard code={card.meta.id} />} <div>
style={{ <CheckCard
width: 80, cover={<YgoCard code={card.meta.id} />}
aspectRatio: 5.9 / 8.6, style={{
marginInlineEnd: 0, width: 80,
marginBlockEnd: 0, aspectRatio: 5.9 / 8.6,
flexShrink: 0, marginInlineEnd: 0,
}} marginBlockEnd: 0,
key={j} flexShrink: 0,
value={card} }}
/> value={card}
/>
</div>
</Tooltip>
))} ))}
</CheckCard.Group> </CheckCard.Group>
</div> </div>
...@@ -231,8 +241,6 @@ const config = useConfig(); ...@@ -231,8 +241,6 @@ const config = useConfig();
let rs: (v?: any) => void = () => {}; let rs: (v?: any) => void = () => {};
type Result = Option[];
export const displaySelectActionsModal = async ( export const displaySelectActionsModal = async (
args: Partial<Omit<typeof defaultProps, "isOpen">> args: Partial<Omit<typeof defaultProps, "isOpen">>
) => { ) => {
...@@ -242,8 +250,7 @@ export const displaySelectActionsModal = async ( ...@@ -242,8 +250,7 @@ export const displaySelectActionsModal = async (
// @ts-ignore // @ts-ignore
localStore[key] = value; localStore[key] = value;
}); });
await new Promise<Result>((resolve) => (rs = resolve)); // 等待在组件内resolve await new Promise<void>((resolve) => (rs = resolve)); // 等待在组件内resolve
console.log("here");
localStore.isOpen = false; localStore.isOpen = false;
}; };
......
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