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
3aea11bc
Commit
3aea11bc
authored
Aug 07, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: mora
parent
f8b686d1
Pipeline
#22931
failed with stages
in 14 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
9 deletions
+30
-9
src/ui/NewWaitRoom/index.tsx
src/ui/NewWaitRoom/index.tsx
+30
-9
No files found.
src/ui/NewWaitRoom/index.tsx
View file @
3aea11bc
...
...
@@ -4,7 +4,7 @@ import { ygopro } from "@/api";
import
PlayerState
=
ygopro
.
StocHsPlayerChange
.
State
;
import
{
Avatar
,
Button
,
ConfigProvider
,
Popover
,
Skeleton
,
Space
}
from
"
antd
"
;
import
classNames
from
"
classnames
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
forwardRef
,
useImperativeHandle
,
useRef
,
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
...
...
@@ -36,6 +36,8 @@ export const Component: React.FC = () => {
const
{
user
}
=
useSnapshot
(
accountStore
);
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
);
const
room
=
useSnapshot
(
roomStore
);
// const ref = useRef<MoraButtonRef>(null);
// ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果
return
(
<
ConfigProvider
theme=
{
theme
}
>
...
...
@@ -51,7 +53,6 @@ export const Component: React.FC = () => {
icon=
{
<
IconFont
type=
"icon-side-bar-fill"
size=
{
16
}
/>
}
onClick=
{
()
=>
setCollapsed
(
!
collapsed
)
}
/>
<
Chat
/>
</
div
>
<
div
className=
{
styles
.
main
}
>
...
...
@@ -70,6 +71,7 @@ export const Component: React.FC = () => {
<
Button
size=
"large"
className=
{
styles
[
"
btn-join
"
]
}
>
决斗准备
</
Button
>
{
/* <MoraButton ref={ref} /> */
}
</>
}
/>
...
...
@@ -87,11 +89,28 @@ enum Mora {
Paper
=
"
paper
"
,
}
const
MoraButton
:
React
.
FC
<
{
onClick
?:
()
=>
Promise
<
Mora
>
;
}
>
=
()
=>
{
// TODO: 实现这个onclick
// 防抖
// TODO: 可能有更好的设计,不一定是放在这个按钮这儿
// 思路不变,先暂时这么写
interface
MoraButtonRef
{
getMoraResult
:
()
=>
Promise
<
Mora
>
;
}
const
MoraButton
=
forwardRef
<
MoraButtonRef
,
{}
>
((
props
,
ref
)
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
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
;
},
}));
const
onMoraClick
=
(
mora
:
Mora
)
=>
resolve
.
current
(
mora
);
const
map
=
{
[
Mora
.
Rock
]:
"
石头
"
,
...
...
@@ -106,16 +125,18 @@ const MoraButton: React.FC<{
<
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
>
}
trigger=
"focus"
open=
{
open
}
placement=
"bottom"
>
<
Button
...
...
@@ -127,7 +148,7 @@ const MoraButton: React.FC<{
</
Button
>
</
Popover
>
);
};
}
)
;
const
OrderPopup
:
React
.
FC
<
React
.
PropsWithChildren
<
{
open
:
boolean
}
>>
=
({
children
,
...
...
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