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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
love_飞影
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
Changes
2
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
{
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
"
]
}
</
SpecialButton
>
onClick=
{
onClick
}
>
<
IconFont
type=
"icon-play"
size=
{
12
}
/>
开始游戏
</
SpecialButton
>
</
MoraPopover
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -164,59 +173,55 @@ interface MoraButtonRef {
...
@@ -164,59 +173,55 @@ interface MoraButtonRef {
getMoraResult
:
()
=>
Promise
<
Mora
>
;
getMoraResult
:
()
=>
Promise
<
Mora
>
;
}
}
const
MoraButton
=
forwardRef
<
MoraButtonRef
,
{}
>
((
props
,
ref
)
=>
{
const
MoraPopover
=
forwardRef
<
MoraButtonRef
,
React
.
PropsWithChildren
>
(
const
[
open
,
setOpen
]
=
useState
(
false
);
({
children
},
ref
)
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
const
resolve
=
useRef
<
(
mora
:
Mora
)
=>
void
>
(()
=>
{});
const
resolve
=
useRef
<
(
mora
:
Mora
)
=>
void
>
(()
=>
{});
useImperativeHandle
(
ref
,
()
=>
({
useImperativeHandle
(
ref
,
()
=>
({
async
getMoraResult
()
{
async
getMoraResult
()
{
setOpen
(
true
);
setOpen
(
true
);
const
result
=
await
new
Promise
<
Mora
>
((
rs
)
=>
(
resolve
.
current
=
rs
));
const
result
=
await
new
Promise
<
Mora
>
((
rs
)
=>
(
resolve
.
current
=
rs
));
setOpen
(
false
);
setOpen
(
false
);
return
result
;
return
result
;
},
},
}));
}));
const
onMoraClick
=
(
mora
:
Mora
)
=>
resolve
.
current
(
mora
);
const
onMoraClick
=
(
mora
:
Mora
)
=>
resolve
.
current
(
mora
);
const
map
=
{
const
map
=
{
[
Mora
.
Rock
]:
"
石头
"
,
[
Mora
.
Rock
]:
"
石头
"
,
[
Mora
.
Scissors
]:
"
剪刀
"
,
[
Mora
.
Scissors
]:
"
剪刀
"
,
[
Mora
.
Paper
]:
"
布
"
,
[
Mora
.
Paper
]:
"
布
"
,
};
};
return
(
return
(
<
Popover
<
Popover
overlayStyle=
{
{
backdropFilter
:
"
blur(10px)
"
}
}
overlayStyle=
{
{
backdropFilter
:
"
blur(10px)
"
}
}
content=
{
content=
{
<
Space
>
<
Space
>
{
[
Mora
.
Rock
,
Mora
.
Scissors
,
Mora
.
Paper
].
map
((
mora
)
=>
(
{
[
Mora
.
Rock
,
Mora
.
Scissors
,
Mora
.
Paper
].
map
((
mora
)
=>
(
<
Button
<
Button
key=
{
mora
}
key=
{
mora
}
size=
"large"
size=
"large"
type=
"text"
type=
"text"
icon=
{
<
IconFont
type=
{
`icon-hand-${mora}`
}
size=
{
16
}
/>
}
icon=
{
<
IconFont
type=
{
`icon-hand-${mora}`
}
size=
{
16
}
/>
}
onClick=
{
()
=>
onMoraClick
(
mora
)
}
onClick=
{
()
=>
onMoraClick
(
mora
)
}
>
>
{
map
[
mora
]
}
{
map
[
mora
]
}
</
Button
>
</
Button
>
))
}
))
}
</
Space
>
</
Space
>
}
}
open=
{
open
}
open=
{
open
}
placement=
"bottom"
placement=
"bottom"
>
<
Button
size=
"large"
className=
{
styles
[
"
btn-join
"
]
}
icon=
{
<
IconFont
type=
"icon-mora"
size=
{
20
}
/>
}
>
>
猜拳
{
children
}
</
Button
>
</
Popover
>
</
Popover
>
);
);
}
}
);
);
const
OrderPopup
:
React
.
FC
<
React
.
PropsWithChildren
<
{
open
:
boolean
}
>>
=
({
const
OrderPopup
:
React
.
FC
<
React
.
PropsWithChildren
<
{
open
:
boolean
}
>>
=
({
children
,
children
,
...
...
src/ui/Shared/SpecialButton/index.module.scss
View file @
2e664d98
...
@@ -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
:
4
px
;
gap
:
8
px
;
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
;
...
...
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