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
ab0be43d
Commit
ab0be43d
authored
Aug 06, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MatchModal.tsx
parent
d6f16bf0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
1 deletion
+121
-1
src/stores/index.ts
src/stores/index.ts
+0
-1
src/ui/NewMatch/Modal.module.scss
src/ui/NewMatch/Modal.module.scss
+14
-0
src/ui/NewMatch/Modal.tsx
src/ui/NewMatch/Modal.tsx
+104
-0
src/ui/NewMatch/index.tsx
src/ui/NewMatch/index.tsx
+3
-0
No files found.
src/stores/index.ts
View file @
ab0be43d
...
...
@@ -2,7 +2,6 @@ export * from "./accountStore";
export
*
from
"
./cardStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./deckStore
"
;
export
*
from
"
./deckStore
"
;
export
*
from
"
./matStore
"
;
export
*
from
"
./placeStore
"
;
export
*
from
"
./replayStore
"
;
...
...
src/ui/NewMatch/Modal.module.scss
0 → 100644
View file @
ab0be43d
.inputs-container
{
display
:
flex
;
flex-direction
:
column
;
flex-wrap
:
wrap
;
justify-content
:
center
;
.input
{
font-size
:
18px
;
font-family
:
var
(
--
theme-font
);
color
:
#2885ff
f2
;
height
:
50px
;
margin
:
4px
;
}
}
src/ui/NewMatch/Modal.tsx
0 → 100644
View file @
ab0be43d
import
{
Button
,
Input
,
Modal
}
from
"
antd
"
;
import
React
,
{
ChangeEvent
,
useEffect
,
useState
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
styles
from
"
./Modal.module.scss
"
;
const
NeosConfig
=
useConfig
();
const
serverConfig
=
NeosConfig
.
servers
;
const
{
defaults
:
{
defaultPlayer
,
defaultPassword
},
automation
:
{
isAiMode
},
}
=
useConfig
();
interface
Props
{
open
?:
boolean
;
}
const
defaultProps
:
Props
=
{
open
:
false
,
};
export
const
localStore
=
proxy
<
Props
>
(
defaultProps
);
export
const
MatchModal
:
React
.
FC
=
({})
=>
{
const
{
open
}
=
useSnapshot
(
localStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
[
player
,
setPlayer
]
=
useState
(
user
?.
name
??
defaultPlayer
);
const
[
passwd
,
setPasswd
]
=
useState
(
defaultPassword
);
const
[
server
,
setServer
]
=
useState
(
`
${
serverConfig
[
0
].
ip
}
:
${
serverConfig
[
0
].
port
}
`
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
let
handlePlayerChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setPlayer
(
event
.
target
.
value
);
};
let
handleServerChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setServer
(
event
.
target
.
value
);
};
let
handlePasswdChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setPasswd
(
event
.
target
.
value
);
};
// 因为萌卡服务器的房间密码会有`#`等特殊字符,因此这里用`encodeURIComponent`做下转义
const
handleSubmit
=
()
=>
{
setConfirmLoading
(
true
);
// TODO: 这里应该进行WASM,websocket等的初始化,成功加入房间后才跳转
// navigate(`/room/${player}/${encodeURIComponent(passwd)}/${server}`);
};
useEffect
(()
=>
{
// 如果开启了AI模式,直接进入房间
if
(
isAiMode
)
{
handleSubmit
();
}
},
[]);
return
(
<
Modal
open=
{
open
}
title=
"请输入自定义房间信息"
onCancel=
{
()
=>
(
localStore
.
open
=
false
)
}
footer=
{
<
Button
onClick=
{
handleSubmit
}
loading=
{
confirmLoading
}
>
加入房间
</
Button
>
}
confirmLoading=
{
confirmLoading
}
centered
>
<
div
className=
{
styles
[
"
inputs-container
"
]
}
>
<
Input
className=
{
styles
.
input
}
type=
"text"
placeholder=
"玩家昵称"
value=
{
player
}
onChange=
{
handlePlayerChange
}
required
/>
<
Input
className=
{
styles
.
input
}
type=
"text"
placeholder=
"服务器(IP+端口)"
value=
{
server
}
onChange=
{
handleServerChange
}
required
/>
<
Input
className=
{
styles
.
input
}
type=
"password"
autoCorrect=
"off"
placeholder=
"房间密码(可选)"
value=
{
passwd
}
onChange=
{
handlePasswdChange
}
/>
</
div
>
</
Modal
>
);
};
src/ui/NewMatch/index.tsx
View file @
ab0be43d
...
...
@@ -7,6 +7,7 @@ import { accountStore, type User } from "@/stores";
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
styles
from
"
./index.module.scss
"
;
import
{
localStore
,
MatchModal
}
from
"
./Modal
"
;
export
const
loader
:
LoaderFunction
=
()
=>
{
const
sso
=
new
URLSearchParams
(
location
.
search
).
get
(
"
sso
"
);
...
...
@@ -71,6 +72,7 @@ export const Component: React.FC = () => {
title=
"自定义房间"
desc=
"创建一个自定义的对战房间,便捷地与好友进行对战,甚至是举办一场竞技比赛。"
icon=
{
<
SettingFilled
/>
}
onClick=
{
()
=>
(
localStore
.
open
=
true
)
}
/>
<
Mode
title=
"录像回放"
...
...
@@ -85,6 +87,7 @@ export const Component: React.FC = () => {
</
div
>
</
div
>
</
div
>
<
MatchModal
/>
</>
);
};
...
...
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