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
466916de
Commit
466916de
authored
Aug 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize NewWaitRoom
parent
9fdbc15a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
37 deletions
+17
-37
src/ui/NewWaitRoom/index.tsx
src/ui/NewWaitRoom/index.tsx
+17
-37
No files found.
src/ui/NewWaitRoom/index.tsx
View file @
466916de
...
@@ -3,7 +3,6 @@ import { CheckCircleFilled } from "@ant-design/icons";
...
@@ -3,7 +3,6 @@ import { CheckCircleFilled } from "@ant-design/icons";
import
{
import
{
sendHsNotReady
,
sendHsNotReady
,
sendHsReady
,
sendHsReady
,
sendHsStart
,
sendHsToDuelList
,
sendHsToDuelList
,
sendHsToObserver
,
sendHsToObserver
,
sendUpdateDeck
,
sendUpdateDeck
,
...
@@ -22,13 +21,7 @@ import {
...
@@ -22,13 +21,7 @@ import {
Tooltip
,
Tooltip
,
}
from
"
antd
"
;
}
from
"
antd
"
;
import
classNames
from
"
classnames
"
;
import
classNames
from
"
classnames
"
;
import
{
import
{
forwardRef
,
useImperativeHandle
,
useRef
,
useState
}
from
"
react
"
;
forwardRef
,
useEffect
,
useImperativeHandle
,
useRef
,
useState
,
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
...
@@ -64,13 +57,9 @@ export const Component: React.FC = () => {
...
@@ -64,13 +57,9 @@ export const Component: React.FC = () => {
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
);
const
navigate
=
useNavigate
();
// ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果
// ref.current?.getMoraResult(); // 用这个来异步获取猜拳结果
useEffect
(()
=>
{
sendUpdateDeck
(
deck
);
window
.
myExtraDeckCodes
=
[...
deck
.
extra
];
},
[
deck
]);
const
onClick
=
async
()
=>
{
const
onClick
=
async
()
=>
{
console
.
log
(
await
ref
.
current
?.
getMoraResult
());
console
.
log
(
await
ref
.
current
?.
getMoraResult
());
};
};
...
@@ -97,6 +86,12 @@ export const Component: React.FC = () => {
...
@@ -97,6 +86,12 @@ export const Component: React.FC = () => {
className=
{
styles
[
"
btn
"
]
}
className=
{
styles
[
"
btn
"
]
}
danger
danger
icon=
{
<
IconFont
type=
"icon-exit"
size=
{
16
}
/>
}
icon=
{
<
IconFont
type=
"icon-exit"
size=
{
16
}
/>
}
onClick=
{
()
=>
{
// 断开websocket🔗,
socketMiddleWare
({
cmd
:
socketCmd
.
DISCONNECT
});
// 返回上一个路由
navigate
(
"
..
"
);
}
}
/>
/>
</
Tooltip
>
</
Tooltip
>
<
Button
<
Button
...
@@ -129,9 +124,15 @@ export const Component: React.FC = () => {
...
@@ -129,9 +124,15 @@ export const Component: React.FC = () => {
size=
"large"
size=
"large"
className=
{
styles
[
"
btn-join
"
]
}
className=
{
styles
[
"
btn-join
"
]
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
room
.
getMePlayer
()?.
state
===
PlayerState
.
NO_READY
if
(
?
sendHsReady
()
room
.
getMePlayer
()?.
state
===
PlayerState
.
NO_READY
:
sendHsNotReady
();
)
{
sendUpdateDeck
(
deck
);
window
.
myExtraDeckCodes
=
[...
deck
.
extra
];
sendHsReady
();
}
else
{
sendHsNotReady
();
}
}
}
}
}
>
>
{
room
.
getMePlayer
()?.
state
===
PlayerState
.
NO_READY
{
room
.
getMePlayer
()?.
state
===
PlayerState
.
NO_READY
...
@@ -306,7 +307,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
...
@@ -306,7 +307,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
})
=>
{
})
=>
{
const
snapDeck
=
useSnapshot
(
deckStore
);
const
snapDeck
=
useSnapshot
(
deckStore
);
const
snapRoom
=
useSnapshot
(
roomStore
);
const
snapRoom
=
useSnapshot
(
roomStore
);
const
navigate
=
useNavigate
();
return
(
return
(
<
Space
>
<
Space
>
<
Select
<
Select
...
@@ -345,26 +345,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
...
@@ -345,26 +345,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
))
}
))
}
</
Avatar
.
Group
>
</
Avatar
.
Group
>
</
Button
>
</
Button
>
{
/* <Button
size="large"
icon={<IconFont type="icon-play" size={12} />}
disabled={!snapRoom.isHost}
onClick={() => sendHsStart()}
>
开始游戏
</Button> */
}
{
/* <Button
size="large"
danger
onClick={() => {
// 断开websocket🔗,
socketMiddleWare({ cmd: socketCmd.DISCONNECT });
// 返回上一个路由
navigate("..");
}}
>
退出房间
</Button> */
}
</
Space
>
</
Space
>
);
);
};
};
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