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
8d69c4a7
Commit
8d69c4a7
authored
Sep 30, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize
parent
60b5b6ba
Pipeline
#23635
passed with stages
in 14 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
42 deletions
+34
-42
src/ui/Match/WatchModal.tsx
src/ui/Match/WatchModal.tsx
+23
-38
src/ui/Match/index.tsx
src/ui/Match/index.tsx
+11
-4
No files found.
src/ui/Match/WatchModal.tsx
View file @
8d69c4a7
import
{
App
,
List
,
Modal
}
from
"
antd
"
;
import
{
App
,
List
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
useWebSocket
,
{
ReadyState
}
from
"
react-use-websocket
"
;
import
useWebSocket
,
{
ReadyState
}
from
"
react-use-websocket
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
...
@@ -34,21 +33,17 @@ interface Options {
...
@@ -34,21 +33,17 @@ interface Options {
auto_death
:
boolean
;
auto_death
:
boolean
;
}
}
const
localStore
=
proxy
({
open
:
false
,
});
export
const
WatchModal
:
React
.
FC
=
()
=>
{
export
const
WatchModal
:
React
.
FC
=
()
=>
{
const
{
open
}
=
useSnapshot
(
localStore
);
const
[
rooms
,
setRooms
]
=
useState
<
Room
[]
>
([]);
const
[
rooms
,
setRooms
]
=
useState
<
Room
[]
>
([]);
const
{
message
}
=
App
.
useApp
();
const
{
message
}
=
App
.
useApp
();
const
url
=
new
URL
(
athleticWatchUrl
);
const
url
=
new
URL
(
athleticWatchUrl
);
url
.
searchParams
.
set
(
"
filter
"
,
"
started
"
);
url
.
searchParams
.
set
(
"
filter
"
,
"
started
"
);
const
{
readyState
}
=
useWebSocket
(
url
.
toString
(),
{
const
{
readyState
}
=
useWebSocket
(
url
.
toString
(),
{
onOpen
:
()
=>
console
.
log
(
"
watch websocket opened.
"
),
onClose
:
()
=>
console
.
log
(
"
watch websocket closed.
"
),
onMessage
:
(
event
)
=>
{
onMessage
:
(
event
)
=>
{
const
info
:
Info
=
JSON
.
parse
(
event
.
data
);
const
info
:
Info
=
JSON
.
parse
(
event
.
data
);
switch
(
info
.
event
)
{
switch
(
info
.
event
)
{
case
"
init
"
:
{
case
"
init
"
:
{
//@ts-ignore
//@ts-ignore
...
@@ -92,35 +87,25 @@ export const WatchModal: React.FC = () => {
...
@@ -92,35 +87,25 @@ export const WatchModal: React.FC = () => {
});
});
return
(
return
(
<
Modal
<
List
title=
"观看回放"
itemLayout=
"vertical"
open=
{
open
}
loading=
{
readyState
===
ReadyState
.
CONNECTING
}
centered
size=
"small"
footer=
{
<></>
}
pagination=
{
{
onCancel=
{
()
=>
(
localStore
.
open
=
false
)
}
position
:
"
bottom
"
,
>
align
:
"
center
"
,
<
List
pageSize
:
5
,
itemLayout=
"vertical"
simple
:
true
,
loading=
{
readyState
===
ReadyState
.
CONNECTING
}
}
}
size=
"small"
dataSource=
{
rooms
}
pagination=
{
{
renderItem=
{
(
room
)
=>
(
position
:
"
bottom
"
,
<
List
.
Item
key=
{
room
.
id
}
>
align
:
"
center
"
,
<
List
.
Item
.
Meta
pageSize
:
5
,
title=
{
`${room.users?.at(0)?.username} 与 ${room.users?.at(1)
simple
:
true
,
?.username} 的决斗`
}
}
}
/>
dataSource=
{
rooms
}
</
List
.
Item
>
renderItem=
{
(
room
)
=>
(
)
}
<
List
.
Item
key=
{
room
.
id
}
>
/>
<
List
.
Item
.
Meta
title=
{
`${room.users?.at(0)?.username}与${room.users?.at(1)
?.username}的决斗`
}
/>
</
List
.
Item
>
)
}
/>
</
Modal
>
);
);
};
};
export
const
watchOpen
=
()
=>
(
localStore
.
open
=
true
);
src/ui/Match/index.tsx
View file @
8d69c4a7
...
@@ -18,7 +18,7 @@ import styles from "./index.module.scss";
...
@@ -18,7 +18,7 @@ import styles from "./index.module.scss";
import
{
MatchModal
,
matchStore
}
from
"
./MatchModal
"
;
import
{
MatchModal
,
matchStore
}
from
"
./MatchModal
"
;
import
{
ReplayModal
,
replayOpen
}
from
"
./ReplayModal
"
;
import
{
ReplayModal
,
replayOpen
}
from
"
./ReplayModal
"
;
import
{
connectSrvpro
}
from
"
./util
"
;
import
{
connectSrvpro
}
from
"
./util
"
;
import
{
WatchModal
,
watchOpen
}
from
"
./WatchModal
"
;
import
{
WatchModal
}
from
"
./WatchModal
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
...
@@ -29,7 +29,7 @@ export const loader: LoaderFunction = () => {
...
@@ -29,7 +29,7 @@ export const loader: LoaderFunction = () => {
};
};
export
const
Component
:
React
.
FC
=
()
=>
{
export
const
Component
:
React
.
FC
=
()
=>
{
const
{
message
}
=
App
.
useApp
();
const
{
message
,
modal
}
=
App
.
useApp
();
const
serverList
=
NeosConfig
.
servers
;
const
serverList
=
NeosConfig
.
servers
;
const
server
=
`
${
serverList
[
0
].
ip
}
:
${
serverList
[
0
].
port
}
`
;
const
server
=
`
${
serverList
[
0
].
ip
}
:
${
serverList
[
0
].
port
}
`
;
const
{
decks
}
=
deckStore
;
const
{
decks
}
=
deckStore
;
...
@@ -143,7 +143,15 @@ export const Component: React.FC = () => {
...
@@ -143,7 +143,15 @@ export const Component: React.FC = () => {
title=
"MC观战列表"
title=
"MC观战列表"
desc=
"观看萌卡MyCard上正在进行的决斗。"
desc=
"观看萌卡MyCard上正在进行的决斗。"
icon=
{
<
PlayCircleFilled
/>
}
icon=
{
<
PlayCircleFilled
/>
}
onClick=
{
watchOpen
}
onClick=
{
()
=>
modal
.
info
({
icon
:
null
,
footer
:
<></>,
centered
:
true
,
maskClosable
:
true
,
content
:
<
WatchModal
/>,
})
}
/>
/>
<
Mode
<
Mode
title=
"单人模式"
title=
"单人模式"
...
@@ -174,7 +182,6 @@ export const Component: React.FC = () => {
...
@@ -174,7 +182,6 @@ export const Component: React.FC = () => {
</
div
>
</
div
>
<
MatchModal
/>
<
MatchModal
/>
<
ReplayModal
/>
<
ReplayModal
/>
<
WatchModal
/>
</>
</>
);
);
};
};
...
...
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