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
5247e0a3
Commit
5247e0a3
authored
Jul 25, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Start component
parent
189164b7
Pipeline
#22787
failed with stages
in 16 minutes and 51 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
28 deletions
+97
-28
src/stores/accountStore.ts
src/stores/accountStore.ts
+27
-0
src/stores/index.ts
src/stores/index.ts
+1
-0
src/ui/Start/index.scss
src/ui/Start/index.scss
+1
-0
src/ui/Start/index.tsx
src/ui/Start/index.tsx
+68
-28
No files found.
src/stores/accountStore.ts
0 → 100644
View file @
5247e0a3
import
{
proxy
}
from
"
valtio
"
;
import
{
NeosStore
}
from
"
./shared
"
;
export
interface
User
{
id
:
string
;
username
:
string
;
name
:
string
;
email
:
string
;
token
:
string
;
external_id
:
number
;
}
class
AccountStore
implements
NeosStore
{
user
?:
User
;
login
(
user
:
User
)
{
this
.
user
=
user
;
}
logout
()
{
this
.
user
=
undefined
;
}
reset
():
void
{
this
.
user
=
undefined
;
}
}
export
const
accountStore
=
proxy
(
new
AccountStore
());
src/stores/index.ts
View file @
5247e0a3
export
*
from
"
./accountStore
"
;
export
*
from
"
./cardStore
"
;
export
*
from
"
./cardStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./joinStore
"
;
export
*
from
"
./joinStore
"
;
...
...
src/ui/Start/index.scss
View file @
5247e0a3
...
@@ -72,6 +72,7 @@ body * {
...
@@ -72,6 +72,7 @@ body * {
background-color
:
transparent
;
background-color
:
transparent
;
border-style
:
none
;
border-style
:
none
;
color
:
rgba
(
255
,
255
,
255
,
.8
);
color
:
rgba
(
255
,
255
,
255
,
.8
);
font-family
:
var
(
--
theme-font
);
font-size
:
2
.5em
;
font-size
:
2
.5em
;
font-weight
:
bold
;
font-weight
:
bold
;
text-shadow
:
0
0
0
.5em
#a2162d
,
0
0
0
.5em
#f80000
d6
;
text-shadow
:
0
0
0
.5em
#a2162d
,
0
0
0
.5em
#f80000
d6
;
...
...
src/ui/Start/index.tsx
View file @
5247e0a3
import
"
./index.scss
"
;
import
"
./index.scss
"
;
import
React
from
"
react
"
;
import
React
,
{
useEffect
}
from
"
react
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
,
User
}
from
"
@/stores
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
const
Start
:
React
.
FC
=
()
=>
(
const
Start
:
React
.
FC
=
()
=>
{
const
sso
=
new
URL
(
location
.
href
).
searchParams
.
get
(
"
sso
"
);
const
user
:
User
|
undefined
=
sso
?
getSSOUser
(
new
URLSearchParams
(
atob
(
sso
)))
:
undefined
;
const
onLogin
=
()
=>
{
const
ssoUrl
=
getSSOUrl
(
location
.
href
);
window
.
location
.
href
=
ssoUrl
;
};
useEffect
(()
=>
{
if
(
user
)
{
accountStore
.
login
(
user
);
// TODO: navigate
}
},
[
user
])
return
(
<>
<>
<
div
className=
"mycard-header"
>
<
div
className=
"mycard-header"
>
<
a
className=
"mycard-logo"
href=
"https://mycard.moe/"
>
<
a
className=
"mycard-logo"
href=
"https://mycard.moe/"
>
...
@@ -28,11 +45,34 @@ const Start: React.FC = () => (
...
@@ -28,11 +45,34 @@ const Start: React.FC = () => (
alt=
"YGO NEOS"
alt=
"YGO NEOS"
/>
/>
</
h1
>
</
h1
>
<
button
>
PLAY NOW!
</
button
>
<
button
onClick=
{
onLogin
}
>
登陆萌卡进行游玩
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</>
</>
);
);
};
function
getSSOUrl
(
callbackUrl
:
string
):
string
{
let
params
=
new
URLSearchParams
();
params
.
set
(
"
return_sso_url
"
,
callbackUrl
);
const
payload
=
btoa
(
params
.
toString
());
const
url
=
new
URL
(
"
https://accounts.moecube.com
"
);
params
=
url
.
searchParams
;
params
.
set
(
"
sso
"
,
payload
);
return
url
.
toString
();
}
function
getSSOUser
(
searchParams
:
URLSearchParams
):
User
{
const
sso
=
{};
for
(
const
[
key
,
value
]
of
searchParams
)
{
// @ts-ignore
sso
[
key
]
=
value
;
}
return
sso
as
any
;
}
export
default
Start
;
export
default
Start
;
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