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
c8f9e479
authored
Mar 05, 2024
by
Calcium-Ion
Committed by
GitHub
Mar 05, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81 from QuentinHsu/fix-display-home-content
fix: the content displayed on the homepage is incorrect
parents
ed4db24b
2c08dd9e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
49 deletions
+42
-49
web/src/components/SiderBar.js
+3
-1
web/src/pages/Home/index.js
+39
-48
No files found.
web/src/components/SiderBar.js
View file @
c8f9e479
import
React
,
{
useContext
,
useEffect
,
useLayoutEffect
,
useMemo
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
useEffect
,
useLayoutEffect
,
useMemo
,
useState
}
from
'react'
;
import
{
Link
,
useNavigate
}
from
'react-router-dom'
;
import
{
Link
,
useNavigate
}
from
'react-router-dom'
;
import
{
UserContext
}
from
'../context/User'
;
import
{
UserContext
}
from
'../context/User'
;
import
{
StatusContext
}
from
'../context/Status'
;
import
{
API
,
getLogo
,
getSystemName
,
isAdmin
,
isMobile
,
showError
,
showSuccess
}
from
'../helpers'
;
import
{
API
,
getLogo
,
getSystemName
,
isAdmin
,
isMobile
,
showError
,
showSuccess
}
from
'../helpers'
;
import
'../index.css'
;
import
'../index.css'
;
...
@@ -24,6 +25,7 @@ import {Nav, Avatar, Dropdown, Layout} from '@douyinfe/semi-ui';
...
@@ -24,6 +25,7 @@ import {Nav, Avatar, Dropdown, Layout} from '@douyinfe/semi-ui';
const
SiderBar
=
()
=>
{
const
SiderBar
=
()
=>
{
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
const
[
statusState
,
statusDispatch
]
=
useContext
(
StatusContext
);
const
defaultIsCollapsed
=
isMobile
()
||
localStorage
.
getItem
(
'default_collapse_sidebar'
)
===
'true'
;
const
defaultIsCollapsed
=
isMobile
()
||
localStorage
.
getItem
(
'default_collapse_sidebar'
)
===
'true'
;
let
navigate
=
useNavigate
();
let
navigate
=
useNavigate
();
...
@@ -118,7 +120,7 @@ const SiderBar = () => {
...
@@ -118,7 +120,7 @@ const SiderBar = () => {
const
{
success
,
data
}
=
res
.
data
;
const
{
success
,
data
}
=
res
.
data
;
if
(
success
)
{
if
(
success
)
{
localStorage
.
setItem
(
'status'
,
JSON
.
stringify
(
data
));
localStorage
.
setItem
(
'status'
,
JSON
.
stringify
(
data
));
//
statusDispatch({ type: 'set', payload: data });
statusDispatch
({
type
:
'set'
,
payload
:
data
});
localStorage
.
setItem
(
'system_name'
,
data
.
system_name
);
localStorage
.
setItem
(
'system_name'
,
data
.
system_name
);
localStorage
.
setItem
(
'logo'
,
data
.
logo
);
localStorage
.
setItem
(
'logo'
,
data
.
logo
);
localStorage
.
setItem
(
'footer_html'
,
data
.
footer_html
);
localStorage
.
setItem
(
'footer_html'
,
data
.
footer_html
);
...
...
web/src/pages/Home/index.js
View file @
c8f9e479
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
import
{
Card
,
Grid
,
Header
,
Segment
}
from
'semantic-ui-react
'
;
import
{
Card
,
Col
,
Row
}
from
'@douyinfe/semi-ui
'
;
import
{
API
,
showError
,
showNotice
,
timestamp2string
}
from
'../../helpers'
;
import
{
API
,
showError
,
showNotice
,
timestamp2string
}
from
'../../helpers'
;
import
{
StatusContext
}
from
'../../context/Status'
;
import
{
StatusContext
}
from
'../../context/Status'
;
import
{
marked
}
from
'marked'
;
import
{
marked
}
from
'marked'
;
const
Home
=
()
=>
{
const
Home
=
()
=>
{
const
[
statusState
,
statusDispatch
]
=
useContext
(
StatusContext
);
const
[
statusState
]
=
useContext
(
StatusContext
);
const
[
homePageContentLoaded
,
setHomePageContentLoaded
]
=
useState
(
false
);
const
[
homePageContentLoaded
,
setHomePageContentLoaded
]
=
useState
(
false
);
const
[
homePageContent
,
setHomePageContent
]
=
useState
(
''
);
const
[
homePageContent
,
setHomePageContent
]
=
useState
(
''
);
...
@@ -44,7 +44,7 @@ const Home = () => {
...
@@ -44,7 +44,7 @@ const Home = () => {
const
getStartTimeString
=
()
=>
{
const
getStartTimeString
=
()
=>
{
const
timestamp
=
statusState
?.
status
?.
start_time
;
const
timestamp
=
statusState
?.
status
?.
start_time
;
return
timestamp2string
(
timestamp
)
;
return
statusState
.
status
?
timestamp2string
(
timestamp
)
:
''
;
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -54,80 +54,71 @@ const Home = () => {
...
@@ -54,80 +54,71 @@ const Home = () => {
return
(
return
(
<>
<>
{
{
homePageContentLoaded
&&
homePageContent
===
''
?
<>
homePageContentLoaded
&&
homePageContent
===
''
?
<
Segment
>
<>
<
Header
as
=
'h3'
>
系统状况
<
/Header
>
<
Card
<
Grid
columns
=
{
2
}
stackable
>
bordered
=
{
false
}
<
Grid
.
Column
>
headerLine
=
{
false
}
<
Card
fluid
>
title
=
'系统状况'
<
Card
.
Content
>
bodyStyle
=
{{
padding
:
'10px 20px'
}}
<
Card
.
Header
>
系统信息
<
/Card.Header
>
>
<
Card
.
Meta
>
系统信息总览
<
/Card.Meta
>
<
Row
gutter
=
{
16
}
>
<
Card
.
Description
>
<
Col
span
=
{
12
}
>
<
Card
title
=
'系统信息'
headerExtraContent
=
{
<
span
style
=
{{
fontSize
:
'12px'
,
color
:
'var(--semi-color-text-1)'
}}
>
系统信息总览
<
/span>}
>
<
p
>
名称:
{
statusState
?.
status
?.
system_name
}
<
/p
>
<
p
>
名称:
{
statusState
?.
status
?.
system_name
}
<
/p
>
<
p
>
版本:
{
statusState
?.
status
?.
version
?
statusState
?.
status
?.
version
:
"unknown"
}
<
/p
>
<
p
>
版本:
{
statusState
?.
status
?.
version
?
statusState
?.
status
?.
version
:
'unknown'
}
<
/p
>
<
p
>
<
p
>
源码:
源码:
<
a
<
a
href
=
'https://github.com/songquanpeng/one-api'
href
=
'https://github.com/songquanpeng/one-api'
target
=
'_blank
'
target
=
'_blank'
rel
=
'noreferrer
'
>
>
https
:
//github.com/songquanpeng/one-api
https
:
//github.com/songquanpeng/one-api
<
/a
>
<
/a
>
<
/p
>
<
/p
>
<
p
>
启动时间:
{
getStartTimeString
()}
<
/p
>
<
p
>
启动时间:
{
getStartTimeString
()}
<
/p
>
<
/Card.Description
>
<
/Card.Content
>
<
/Card
>
<
/Card
>
<
/Grid.Column
>
<
/Col
>
<
Grid
.
Column
>
<
Col
span
=
{
12
}
>
<
Card
fluid
>
<
Card
<
Card
.
Content
>
title
=
'系统配置'
<
Card
.
Header
>
系统配置
<
/Card.Header
>
headerExtraContent
=
{
<
span
<
Card
.
Meta
>
系统配置总览
<
/Card.Meta
>
style
=
{{
fontSize
:
'12px'
,
color
:
'var(--semi-color-text-1)'
}}
>
系统配置总览
<
/span>}
>
<
Card
.
Description
>
<
p
>
<
p
>
邮箱验证:
邮箱验证:
{
statusState
?.
status
?.
email_verification
===
true
{
statusState
?.
status
?.
email_verification
===
true
?
'已启用'
:
'未启用'
}
?
'已启用'
:
'未启用'
}
<
/p
>
<
/p
>
<
p
>
<
p
>
GitHub
身份验证:
GitHub
身份验证:
{
statusState
?.
status
?.
github_oauth
===
true
{
statusState
?.
status
?.
github_oauth
===
true
?
'已启用'
:
'未启用'
}
?
'已启用'
:
'未启用'
}
<
/p
>
<
/p
>
<
p
>
<
p
>
微信身份验证:
微信身份验证:
{
statusState
?.
status
?.
wechat_login
===
true
{
statusState
?.
status
?.
wechat_login
===
true
?
'已启用'
:
'未启用'
}
?
'已启用'
:
'未启用'
}
<
/p
>
<
/p
>
<
p
>
<
p
>
Turnstile
用户校验:
Turnstile
用户校验:
{
statusState
?.
status
?.
turnstile_check
===
true
{
statusState
?.
status
?.
turnstile_check
===
true
?
'已启用'
:
'未启用'
}
?
'已启用'
:
'未启用'
}
<
/p
>
<
/p
>
<
p
>
<
p
>
Telegram
身份验证:
Telegram
身份验证:
{
statusState
?.
status
?.
telegram_oauth
===
true
{
statusState
?.
status
?.
telegram_oauth
===
true
?
'已启用'
?
'已启用'
:
'未启用'
}
:
'未启用'
}
<
/p
>
<
/p
>
<
/Card.Description
>
<
/Card.Content
>
<
/Card
>
<
/Card
>
<
/Grid.Column
>
<
/Col
>
<
/Grid
>
<
/Row
>
<
/Segment
>
<
/Card
>
<
/> : <
>
<
/
>
:
<>
{
{
homePageContent
.
startsWith
(
'https://'
)
?
<
iframe
homePageContent
.
startsWith
(
'https://'
)
?
src
=
{
homePageContent
}
<
iframe
src
=
{
homePageContent
}
style
=
{{
width
:
'100%'
,
height
:
'100vh'
,
border
:
'none'
}}
/>
:
style
=
{{
width
:
'100%'
,
height
:
'100vh'
,
border
:
'none'
}}
<
div
style
=
{{
fontSize
:
'larger'
}}
dangerouslySetInnerHTML
=
{{
__html
:
homePageContent
}}
><
/div
>
/> : <div style={{ fontSize: 'larger' }} dangerouslySetInnerHTML={{ __html: homePageContent }}></
div
>
}
}
<
/
>
<
/
>
}
}
...
...
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