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
baichixing
Neos
Commits
ce54ee25
Commit
ce54ee25
authored
Aug 20, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持萌卡账号登出
parent
ca83bae4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
81 additions
and
33 deletions
+81
-33
neos.config.json
neos.config.json
+2
-1
neos.config.prod.json
neos.config.prod.json
+2
-1
src/api/cookies.ts
src/api/cookies.ts
+4
-0
src/api/mycard/account.ts
src/api/mycard/account.ts
+26
-0
src/api/mycard/index.ts
src/api/mycard/index.ts
+1
-0
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+24
-4
src/ui/Match/index.tsx
src/ui/Match/index.tsx
+6
-6
src/ui/Start/index.tsx
src/ui/Start/index.tsx
+2
-13
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+14
-8
No files found.
neos.config.json
View file @
ce54ee25
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"replayUrl"
:
"replay.neos.moe"
,
"accountUrl"
:
"https://accounts.moecube.com"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
"logoutUrl"
:
"https://accounts.moecube.com/signout"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
"streamInterval"
:
20
,
"streamInterval"
:
20
,
"startDelay"
:
1000
,
"startDelay"
:
1000
,
...
...
neos.config.prod.json
View file @
ce54ee25
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"replayUrl"
:
"replay.neos.moe"
,
"accountUrl"
:
"https://accounts.moecube.com"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
"logoutUrl"
:
"https://accounts.moecube.com/signout"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
"profileUrl"
:
"https://accounts.moecube.com/profiles"
,
"streamInterval"
:
20
,
"streamInterval"
:
20
,
"startDelay"
:
1000
,
"startDelay"
:
1000
,
...
...
src/api/cookies.ts
View file @
ce54ee25
...
@@ -15,3 +15,7 @@ export const setCookie = <T>(key: CookieKeys, value: T) => {
...
@@ -15,3 +15,7 @@ export const setCookie = <T>(key: CookieKeys, value: T) => {
expires
:
new
Date
(
Date
.
now
()
+
1000
*
60
*
60
*
24
*
60
),
// 两个月的cookie,应该很充裕
expires
:
new
Date
(
Date
.
now
()
+
1000
*
60
*
60
*
24
*
60
),
// 两个月的cookie,应该很充裕
});
});
};
};
export
const
removeCookie
=
(
key
:
CookieKeys
)
=>
{
cookies
.
remove
(
key
);
};
src/api/mycard/account.ts
0 → 100644
View file @
ce54ee25
/** 构建一个单点登录(Single Sign-On,简称SSO)的URL */
import
{
useConfig
}
from
"
@/config
"
;
const
NeosConfig
=
useConfig
();
export
function
getSSOSignInUrl
(
callbackUrl
:
string
):
string
{
const
params
=
new
URLSearchParams
({
sso
:
btoa
(
new
URLSearchParams
({
return_sso_url
:
callbackUrl
}).
toString
()),
});
const
url
=
new
URL
(
NeosConfig
.
loginUrl
);
url
.
search
=
params
.
toString
();
return
url
.
toString
();
}
export
function
getSSOSignOutUrl
(
callbackUrl
:
string
):
string
{
const
params
=
new
URLSearchParams
({
redirect
:
callbackUrl
,
});
const
url
=
new
URL
(
NeosConfig
.
logoutUrl
);
url
.
search
=
params
.
toString
();
return
url
.
toString
();
}
src/api/mycard/index.ts
View file @
ce54ee25
// Collection of APIs provided by MyCard
// Collection of APIs provided by MyCard
export
*
from
"
./account
"
;
export
*
from
"
./match
"
;
export
*
from
"
./match
"
;
src/ui/Layout/index.tsx
View file @
ce54ee25
...
@@ -9,6 +9,12 @@ import {
...
@@ -9,6 +9,12 @@ import {
}
from
"
react-router-dom
"
;
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
CookieKeys
,
getSSOSignInUrl
,
getSSOSignOutUrl
,
removeCookie
,
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
accountStore
}
from
"
@/stores
"
;
...
@@ -49,16 +55,26 @@ const HeaderBtn: React.FC<
...
@@ -49,16 +55,26 @@ const HeaderBtn: React.FC<
export
const
Component
=
()
=>
{
export
const
Component
=
()
=>
{
// 捕获SSO登录
// 捕获SSO登录
const
l
ocation
=
useLocation
();
const
routerL
ocation
=
useLocation
();
useEffect
(()
=>
{
useEffect
(()
=>
{
location
.
search
&&
handleSSOLogin
(
l
ocation
.
search
);
routerLocation
.
search
&&
handleSSOLogin
(
routerL
ocation
.
search
);
},
[
l
ocation
.
search
]);
},
[
routerL
ocation
.
search
]);
// 根据是否登录,显示内容
// 根据是否登录,显示内容
const
logined
=
Boolean
(
useSnapshot
(
accountStore
).
user
);
const
logined
=
Boolean
(
useSnapshot
(
accountStore
).
user
);
const
{
pathname
}
=
useLocation
()
;
const
{
pathname
}
=
routerLocation
;
const
pathnamesHideHeader
=
[
"
/waitroom
"
,
"
/duel
"
];
const
pathnamesHideHeader
=
[
"
/waitroom
"
,
"
/duel
"
];
const
callbackUrl
=
`
${
location
.
origin
}
/match/`
;
const
onLogin
=
()
=>
location
.
replace
(
getSSOSignInUrl
(
callbackUrl
));
const
onLogout
=
()
=>
{
removeCookie
(
CookieKeys
.
USER
);
accountStore
.
logout
();
// 跳转SSO登出
location
.
replace
(
getSSOSignOutUrl
(
callbackUrl
));
};
return
(
return
(
<>
<>
{
!
pathnamesHideHeader
.
includes
(
pathname
)
&&
(
{
!
pathnamesHideHeader
.
includes
(
pathname
)
&&
(
...
@@ -112,6 +128,10 @@ export const Component = () => {
...
@@ -112,6 +128,10 @@ export const Component = () => {
</
a
>
</
a
>
),
),
},
},
{
label
:
logined
?
"
退出登录
"
:
"
登录萌卡
"
,
onClick
:
logined
?
onLogout
:
onLogin
,
},
].
map
((
x
,
key
)
=>
({
...
x
,
key
})),
].
map
((
x
,
key
)
=>
({
...
x
,
key
})),
}
}
}
}
>
>
...
...
src/ui/Match/index.tsx
View file @
ce54ee25
...
@@ -11,7 +11,7 @@ import { useSnapshot } from "valtio";
...
@@ -11,7 +11,7 @@ import { useSnapshot } from "valtio";
import
{
match
}
from
"
@/api
"
;
import
{
match
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
,
deckStore
,
IDeck
,
roomStore
}
from
"
@/stores
"
;
import
{
accountStore
,
deckStore
,
roomStore
}
from
"
@/stores
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
styles
from
"
./index.module.scss
"
;
import
styles
from
"
./index.module.scss
"
;
...
@@ -27,12 +27,12 @@ export const Component: React.FC = () => {
...
@@ -27,12 +27,12 @@ export const Component: React.FC = () => {
const
[
server
,
setServer
]
=
useState
(
const
[
server
,
setServer
]
=
useState
(
`
${
serverList
[
0
].
ip
}
:
${
serverList
[
0
].
port
}
`
,
`
${
serverList
[
0
].
ip
}
:
${
serverList
[
0
].
port
}
`
,
);
);
const
{
decks
}
=
useSnapshot
(
deckStore
)
;
const
{
decks
}
=
deckStore
;
const
[
deck
,
setDeck
]
=
useState
<
IDeck
>
(
JSON
.
parse
(
JSON
.
stringify
(
decks
[
0
]))
);
const
[
deck
Name
,
setDeckName
]
=
useState
(
decks
.
at
(
0
)?.
deckName
??
""
);
const
user
=
accountStore
.
user
;
const
user
=
accountStore
.
user
;
const
{
joined
}
=
useSnapshot
(
roomStore
);
const
{
joined
}
=
useSnapshot
(
roomStore
);
const
[
singleLoading
,
setSingleLoading
]
=
useState
(
false
);
// 单人模式的loading状态
const
[
singleLoading
,
setSingleLoading
]
=
useState
(
false
);
// 单人模式的loading状态
const
[
matchLoading
,
setMatchLoading
]
=
useState
(
false
);
const
[
matchLoading
,
setMatchLoading
]
=
useState
(
false
);
// 匹配模式的loading状态
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
// 竞技匹配
// 竞技匹配
...
@@ -107,13 +107,13 @@ export const Component: React.FC = () => {
...
@@ -107,13 +107,13 @@ export const Component: React.FC = () => {
<
Select
<
Select
title=
"卡组"
title=
"卡组"
showSearch
showSearch
value=
{
deck
.
deck
Name
}
value=
{
deckName
}
style=
{
{
width
:
200
}
}
style=
{
{
width
:
200
}
}
onChange=
{
(
value
)
=>
{
onChange=
{
(
value
)
=>
{
// @ts-ignore
// @ts-ignore
const
item
=
deckStore
.
get
(
value
);
const
item
=
deckStore
.
get
(
value
);
if
(
item
)
{
if
(
item
)
{
setDeck
(
item
);
setDeck
Name
(
item
.
deckName
);
}
else
{
}
else
{
message
.
error
(
`Deck ${value} not found`
);
message
.
error
(
`Deck ${value} not found`
);
}
}
...
...
src/ui/Start/index.tsx
View file @
ce54ee25
...
@@ -2,6 +2,7 @@ import { RightOutlined } from "@ant-design/icons";
...
@@ -2,6 +2,7 @@ import { RightOutlined } from "@ant-design/icons";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
getSSOSignInUrl
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
Background
,
SpecialButton
}
from
"
@/ui/Shared
"
;
import
{
Background
,
SpecialButton
}
from
"
@/ui/Shared
"
;
...
@@ -49,7 +50,7 @@ const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
...
@@ -49,7 +50,7 @@ const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
const
loginViaSSO
=
()
=>
const
loginViaSSO
=
()
=>
// 跳转回match页
// 跳转回match页
location
.
replace
(
getSSO
Url
(
`
${
location
.
origin
}
/match/}
`
));
location
.
replace
(
getSSO
SignInUrl
(
`
${
location
.
origin
}
/match/
`
));
const
goToMatch
=
()
=>
navigate
(
"
/match
"
);
const
goToMatch
=
()
=>
navigate
(
"
/match
"
);
...
@@ -60,15 +61,3 @@ const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
...
@@ -60,15 +61,3 @@ const LoginBtn: React.FC<{ logined: boolean }> = ({ logined }) => {
</
SpecialButton
>
</
SpecialButton
>
);
);
};
};
/** 构建一个单点登录(Single Sign-On,简称SSO)的URL */
function
getSSOUrl
(
callbackUrl
:
string
):
string
{
const
params
=
new
URLSearchParams
({
sso
:
btoa
(
new
URLSearchParams
({
return_sso_url
:
callbackUrl
}).
toString
()),
});
const
url
=
new
URL
(
NeosConfig
.
accountUrl
);
url
.
search
=
params
.
toString
();
return
url
.
toString
();
}
src/ui/WaitRoom/index.tsx
View file @
ce54ee25
...
@@ -43,8 +43,10 @@ export const Component: React.FC = () => {
...
@@ -43,8 +43,10 @@ export const Component: React.FC = () => {
const
{
message
}
=
App
.
useApp
();
const
{
message
}
=
App
.
useApp
();
const
{
user
}
=
useSnapshot
(
accountStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
);
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
);
const
{
decks
}
=
useSnapshot
(
deckStore
);
const
{
decks
}
=
deckStore
;
const
[
deck
,
setDeck
]
=
useState
<
IDeck
>
(
JSON
.
parse
(
JSON
.
stringify
(
decks
[
0
])));
const
defaultDeck
=
decks
.
length
>
0
?
JSON
.
parse
(
JSON
.
stringify
(
decks
[
0
]))
:
undefined
;
const
[
deck
,
setDeck
]
=
useState
<
IDeck
|
undefined
>
(
defaultDeck
);
const
room
=
useSnapshot
(
roomStore
);
const
room
=
useSnapshot
(
roomStore
);
const
{
errorMsg
}
=
room
;
const
{
errorMsg
}
=
room
;
const
me
=
room
.
getMePlayer
();
const
me
=
room
.
getMePlayer
();
...
@@ -104,12 +106,16 @@ export const Component: React.FC = () => {
...
@@ -104,12 +106,16 @@ export const Component: React.FC = () => {
className=
{
styles
[
"
btn-join
"
]
}
className=
{
styles
[
"
btn-join
"
]
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
if
(
me
?.
state
===
PlayerState
.
NO_READY
)
{
if
(
me
?.
state
===
PlayerState
.
NO_READY
)
{
if
(
deck
)
{
sendUpdateDeck
(
deck
);
sendUpdateDeck
(
deck
);
// 设置side里面的卡组
// 设置side里面的卡组
sideStore
.
deck
=
deck
;
sideStore
.
deck
=
deck
;
// 设置额外卡组数据
// 设置额外卡组数据
window
.
myExtraDeckCodes
=
[...
deck
.
extra
];
window
.
myExtraDeckCodes
=
[...
deck
.
extra
];
sendHsReady
();
sendHsReady
();
}
else
{
message
.
error
(
"
请先选择卡组
"
);
}
}
else
{
}
else
{
sendHsNotReady
();
sendHsNotReady
();
}
}
...
...
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