Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d85e25fc
authored
Apr 08, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Integrate SetupCheck component for improved setup validation in routing
parent
9dc851d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
web/src/App.js
+3
-2
web/src/components/SetupCheck.js
+19
-0
web/src/pages/Home/index.js
+2
-5
No files found.
web/src/App.js
View file @
d85e25fc
...
...
@@ -26,6 +26,7 @@ import Playground from './pages/Playground/Playground.js';
import
OAuth2Callback
from
"./components/OAuth2Callback.js"
;
import
PersonalSetting
from
'./components/PersonalSetting.js'
;
import
Setup
from
'./pages/Setup/index.js'
;
import
SetupCheck
from
'./components/SetupCheck'
;
const
Home
=
lazy
(()
=>
import
(
'./pages/Home'
));
const
Detail
=
lazy
(()
=>
import
(
'./pages/Detail'
));
...
...
@@ -35,7 +36,7 @@ function App() {
const
location
=
useLocation
();
return
(
<>
<
SetupCheck
>
<
Routes
>
<
Route
path
=
'/'
...
...
@@ -286,7 +287,7 @@ function App() {
/
>
<
Route
path
=
'*'
element
=
{
<
NotFound
/>
}
/
>
<
/Routes
>
<
/
>
<
/
SetupCheck
>
);
}
...
...
web/src/components/SetupCheck.js
0 → 100644
View file @
d85e25fc
import
React
,
{
useContext
,
useEffect
}
from
'react'
;
import
{
Navigate
,
useLocation
}
from
'react-router-dom'
;
import
{
StatusContext
}
from
'../context/Status'
;
const
SetupCheck
=
({
children
})
=>
{
const
[
statusState
]
=
useContext
(
StatusContext
);
const
location
=
useLocation
();
useEffect
(()
=>
{
if
(
statusState
?.
status
?.
setup
===
false
&&
location
.
pathname
!==
'/setup'
)
{
window
.
location
.
href
=
'/setup'
;
}
},
[
statusState
?.
status
?.
setup
,
location
.
pathname
]);
return
children
;
};
export
default
SetupCheck
;
\ No newline at end of file
web/src/pages/Home/index.js
View file @
d85e25fc
...
...
@@ -66,13 +66,9 @@ const Home = () => {
};
useEffect
(()
=>
{
if
(
statusState
.
status
?.
setup
===
false
)
{
window
.
location
.
href
=
'/setup'
;
return
;
}
displayNotice
().
then
();
displayHomePageContent
().
then
();
});
}
,
[]
);
return
(
<>
...
...
@@ -116,6 +112,7 @@ const Home = () => {
https
:
//github.com/Calcium-Ion/new-api
<
/a
>
<
/p
>
<
p
>
{
t
(
'协议'
)}
:
<
a
...
...
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