Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
2e664d98
Commit
2e664d98
authored
Aug 07, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: try a new way of mora
parent
35d9e8ed
Pipeline
#22944
failed with stages
in 11 minutes and 33 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
54 deletions
+59
-54
src/ui/NewWaitRoom/index.tsx
src/ui/NewWaitRoom/index.tsx
+58
-53
src/ui/Shared/SpecialButton/index.module.scss
src/ui/Shared/SpecialButton/index.module.scss
+1
-1
No files found.
src/ui/NewWaitRoom/index.tsx
View file @
2e664d98
import
{
CheckCircleFilled
,
LogoutOutlined
}
from
"
@ant-design/icons
"
;
import
{
CheckCircleFilled
}
from
"
@ant-design/icons
"
;
import
{
sendHsNotReady
,
...
...
@@ -63,7 +63,7 @@ export const Component: React.FC = () => {
const
{
decks
}
=
useSnapshot
(
deckStore
);
const
[
deck
,
setDeck
]
=
useState
<
IDeck
>
(
JSON
.
parse
(
JSON
.
stringify
(
decks
[
0
])));
const
room
=
useSnapshot
(
roomStore
);
//
const ref = useRef<MoraButtonRef>(null);
const
ref
=
useRef
<
MoraButtonRef
>
(
null
);
// ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果
useEffect
(()
=>
{
...
...
@@ -71,6 +71,10 @@ export const Component: React.FC = () => {
window
.
myExtraDeckCodes
=
[...
deck
.
extra
];
},
[
deck
]);
const
onClick
=
async
()
=>
{
console
.
log
(
await
ref
.
current
?.
getMoraResult
());
};
return
(
<
ConfigProvider
theme=
{
theme
}
>
<
div
...
...
@@ -140,10 +144,15 @@ export const Component: React.FC = () => {
/>
<
PlayerZone
who=
{
Who
.
Op
}
player=
{
room
.
getOpPlayer
()
}
/>
</
div
>
<
SpecialButton
className=
{
styles
[
"
btns-action
"
]
}
>
开始游戏
</
SpecialButton
>
<
MoraPopover
ref=
{
ref
}
>
<
SpecialButton
className=
{
styles
[
"
btns-action
"
]
}
onClick=
{
onClick
}
>
<
IconFont
type=
"icon-play"
size=
{
12
}
/>
开始游戏
</
SpecialButton
>
</
MoraPopover
>
</
div
>
</
div
>
</
div
>
...
...
@@ -164,59 +173,55 @@ interface MoraButtonRef {
getMoraResult
:
()
=>
Promise
<
Mora
>
;
}
const
MoraButton
=
forwardRef
<
MoraButtonRef
,
{}
>
((
props
,
ref
)
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
const
MoraPopover
=
forwardRef
<
MoraButtonRef
,
React
.
PropsWithChildren
>
(
({
children
},
ref
)
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
const
resolve
=
useRef
<
(
mora
:
Mora
)
=>
void
>
(()
=>
{});
const
resolve
=
useRef
<
(
mora
:
Mora
)
=>
void
>
(()
=>
{});
useImperativeHandle
(
ref
,
()
=>
({
async
getMoraResult
()
{
setOpen
(
true
);
const
result
=
await
new
Promise
<
Mora
>
((
rs
)
=>
(
resolve
.
current
=
rs
));
setOpen
(
false
);
return
result
;
},
}));
useImperativeHandle
(
ref
,
()
=>
({
async
getMoraResult
()
{
setOpen
(
true
);
const
result
=
await
new
Promise
<
Mora
>
((
rs
)
=>
(
resolve
.
current
=
rs
));
setOpen
(
false
);
return
result
;
},
}));
const
onMoraClick
=
(
mora
:
Mora
)
=>
resolve
.
current
(
mora
);
const
onMoraClick
=
(
mora
:
Mora
)
=>
resolve
.
current
(
mora
);
const
map
=
{
[
Mora
.
Rock
]:
"
石头
"
,
[
Mora
.
Scissors
]:
"
剪刀
"
,
[
Mora
.
Paper
]:
"
布
"
,
};
const
map
=
{
[
Mora
.
Rock
]:
"
石头
"
,
[
Mora
.
Scissors
]:
"
剪刀
"
,
[
Mora
.
Paper
]:
"
布
"
,
};
return
(
<
Popover
overlayStyle=
{
{
backdropFilter
:
"
blur(10px)
"
}
}
content=
{
<
Space
>
{
[
Mora
.
Rock
,
Mora
.
Scissors
,
Mora
.
Paper
].
map
((
mora
)
=>
(
<
Button
key=
{
mora
}
size=
"large"
type=
"text"
icon=
{
<
IconFont
type=
{
`icon-hand-${mora}`
}
size=
{
16
}
/>
}
onClick=
{
()
=>
onMoraClick
(
mora
)
}
>
{
map
[
mora
]
}
</
Button
>
))
}
</
Space
>
}
open=
{
open
}
placement=
"bottom"
>
<
Button
size=
"large"
className=
{
styles
[
"
btn-join
"
]
}
icon=
{
<
IconFont
type=
"icon-mora"
size=
{
20
}
/>
}
return
(
<
Popover
overlayStyle=
{
{
backdropFilter
:
"
blur(10px)
"
}
}
content=
{
<
Space
>
{
[
Mora
.
Rock
,
Mora
.
Scissors
,
Mora
.
Paper
].
map
((
mora
)
=>
(
<
Button
key=
{
mora
}
size=
"large"
type=
"text"
icon=
{
<
IconFont
type=
{
`icon-hand-${mora}`
}
size=
{
16
}
/>
}
onClick=
{
()
=>
onMoraClick
(
mora
)
}
>
{
map
[
mora
]
}
</
Button
>
))
}
</
Space
>
}
open=
{
open
}
placement=
"bottom"
>
猜拳
</
Button
>
</
Popover
>
);
}
);
{
children
}
</
Popover
>
);
}
);
const
OrderPopup
:
React
.
FC
<
React
.
PropsWithChildren
<
{
open
:
boolean
}
>>
=
({
children
,
...
...
src/ui/Shared/SpecialButton/index.module.scss
View file @
2e664d98
...
...
@@ -5,7 +5,7 @@
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
4
px
;
gap
:
8
px
;
padding
:
12px
40px
;
border
:
3px
solid
hsla
(
0
,
0%
,
100%
,
0
.3
);
border-radius
:
8px
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment