Commit 2e664d98 authored by timel's avatar timel

feat: try a new way of mora

parent 35d9e8ed
Pipeline #22944 failed with stages
in 11 minutes and 33 seconds
import { CheckCircleFilled, LogoutOutlined } from "@ant-design/icons"; import { CheckCircleFilled } from "@ant-design/icons";
import { import {
sendHsNotReady, sendHsNotReady,
...@@ -63,7 +63,7 @@ export const Component: React.FC = () => { ...@@ -63,7 +63,7 @@ export const Component: React.FC = () => {
const { decks } = useSnapshot(deckStore); const { decks } = useSnapshot(deckStore);
const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0]))); const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0])));
const room = useSnapshot(roomStore); const room = useSnapshot(roomStore);
// const ref = useRef<MoraButtonRef>(null); const ref = useRef<MoraButtonRef>(null);
// ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果 // ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果
useEffect(() => { useEffect(() => {
...@@ -71,6 +71,10 @@ export const Component: React.FC = () => { ...@@ -71,6 +71,10 @@ export const Component: React.FC = () => {
window.myExtraDeckCodes = [...deck.extra]; window.myExtraDeckCodes = [...deck.extra];
}, [deck]); }, [deck]);
const onClick = async () => {
console.log(await ref.current?.getMoraResult());
};
return ( return (
<ConfigProvider theme={theme}> <ConfigProvider theme={theme}>
<div <div
...@@ -140,10 +144,15 @@ export const Component: React.FC = () => { ...@@ -140,10 +144,15 @@ export const Component: React.FC = () => {
/> />
<PlayerZone who={Who.Op} player={room.getOpPlayer()} /> <PlayerZone who={Who.Op} player={room.getOpPlayer()} />
</div> </div>
<MoraPopover ref={ref}>
<SpecialButton className={styles["btns-action"]}> <SpecialButton
className={styles["btns-action"]}
onClick={onClick}
>
<IconFont type="icon-play" size={12} />
开始游戏 开始游戏
</SpecialButton> </SpecialButton>
</MoraPopover>
</div> </div>
</div> </div>
</div> </div>
...@@ -164,7 +173,8 @@ interface MoraButtonRef { ...@@ -164,7 +173,8 @@ interface MoraButtonRef {
getMoraResult: () => Promise<Mora>; getMoraResult: () => Promise<Mora>;
} }
const MoraButton = forwardRef<MoraButtonRef, {}>((props, ref) => { const MoraPopover = forwardRef<MoraButtonRef, React.PropsWithChildren>(
({ children }, ref) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const resolve = useRef<(mora: Mora) => void>(() => {}); const resolve = useRef<(mora: Mora) => void>(() => {});
...@@ -207,16 +217,11 @@ const MoraButton = forwardRef<MoraButtonRef, {}>((props, ref) => { ...@@ -207,16 +217,11 @@ const MoraButton = forwardRef<MoraButtonRef, {}>((props, ref) => {
open={open} open={open}
placement="bottom" placement="bottom"
> >
<Button {children}
size="large"
className={styles["btn-join"]}
icon={<IconFont type="icon-mora" size={20} />}
>
猜拳
</Button>
</Popover> </Popover>
); );
}); }
);
const OrderPopup: React.FC<React.PropsWithChildren<{ open: boolean }>> = ({ const OrderPopup: React.FC<React.PropsWithChildren<{ open: boolean }>> = ({
children, children,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 4px; gap: 8px;
padding: 12px 40px; padding: 12px 40px;
border: 3px solid hsla(0, 0%, 100%, 0.3); border: 3px solid hsla(0, 0%, 100%, 0.3);
border-radius: 8px; border-radius: 8px;
......
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