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
09ed2897
authored
May 14, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to use any link as about page (#60)
parent
6cc47841
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
web/src/components/OtherSetting.js
+2
-2
web/src/pages/About/index.js
+17
-7
No files found.
web/src/components/OtherSetting.js
View file @
09ed2897
...
@@ -121,14 +121,14 @@ const OtherSetting = () => {
...
@@ -121,14 +121,14 @@ const OtherSetting = () => {
value
=
{
inputs
.
HomePageContent
}
value
=
{
inputs
.
HomePageContent
}
name
=
'HomePageContent'
name
=
'HomePageContent'
onChange
=
{
handleInputChange
}
onChange
=
{
handleInputChange
}
style
=
{{
minHeight
:
30
0
,
fontFamily
:
'JetBrains Mono, Consolas'
}}
style
=
{{
minHeight
:
15
0
,
fontFamily
:
'JetBrains Mono, Consolas'
}}
/
>
/
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Button
onClick
=
{()
=>
submitOption
(
'HomePageContent'
)}
>
保存首页内容
<
/Form.Button
>
<
Form
.
Button
onClick
=
{()
=>
submitOption
(
'HomePageContent'
)}
>
保存首页内容
<
/Form.Button
>
<
Form
.
Group
widths
=
'equal'
>
<
Form
.
Group
widths
=
'equal'
>
<
Form
.
TextArea
<
Form
.
TextArea
label
=
'关于'
label
=
'关于'
placeholder
=
'在此输入新的关于内容,支持 Markdown & HTML 代码'
placeholder
=
'在此输入新的关于内容,支持 Markdown & HTML 代码
。如果输入的是一个链接,则会使用该链接作为 iframe 的 src 属性,这允许你设置任意网页作为关于页面。
'
value
=
{
inputs
.
About
}
value
=
{
inputs
.
About
}
name
=
'About'
name
=
'About'
onChange
=
{
handleInputChange
}
onChange
=
{
handleInputChange
}
...
...
web/src/pages/About/index.js
View file @
09ed2897
...
@@ -12,9 +12,12 @@ const About = () => {
...
@@ -12,9 +12,12 @@ const About = () => {
const
res
=
await
API
.
get
(
'/api/about'
);
const
res
=
await
API
.
get
(
'/api/about'
);
const
{
success
,
message
,
data
}
=
res
.
data
;
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
if
(
success
)
{
let
HTMLAbout
=
marked
.
parse
(
data
);
let
aboutContent
=
data
;
setAbout
(
HTMLAbout
);
if
(
!
data
.
startsWith
(
'https://'
))
{
localStorage
.
setItem
(
'about'
,
HTMLAbout
);
aboutContent
=
marked
.
parse
(
data
);
}
setAbout
(
aboutContent
);
localStorage
.
setItem
(
'about'
,
aboutContent
);
}
else
{
}
else
{
showError
(
message
);
showError
(
message
);
setAbout
(
'加载关于内容失败...'
);
setAbout
(
'加载关于内容失败...'
);
...
@@ -28,20 +31,27 @@ const About = () => {
...
@@ -28,20 +31,27 @@ const About = () => {
return
(
return
(
<>
<>
<
Segment
>
{
{
aboutLoaded
&&
about
===
''
?
<>
aboutLoaded
&&
about
===
''
?
<>
<
Segment
>
<
Header
as
=
'h3'
>
关于
<
/Header
>
<
Header
as
=
'h3'
>
关于
<
/Header
>
<
p
>
可在设置页面设置关于内容,支持
HTML
&
Markdown
<
/p
>
<
p
>
可在设置页面设置关于内容,支持
HTML
&
Markdown
<
/p
>
项目仓库地址:
项目仓库地址:
<
a
href
=
"https://github.com/songquanpeng/one-api"
>
<
a
href
=
'https://github.com/songquanpeng/one-api'
>
https
:
//github.com/songquanpeng/one-api
https
:
//github.com/songquanpeng/one-api
<
/a
>
<
/a
>
<
/Segment
>
<
/> : <
>
<
/> : <
>
<
div
dangerouslySetInnerHTML
=
{{
__html
:
about
}}
><
/div
>
{
about
.
startsWith
(
'https://'
)
?
<
iframe
src
=
{
about
}
style
=
{{
width
:
'100%'
,
height
:
'100vh'
,
border
:
'none'
}}
/> : <Segment
>
<
div
style
=
{{
fontSize
:
'larger'
}}
dangerouslySetInnerHTML
=
{{
__html
:
about
}}
><
/div
>
<
/Segment
>
}
<
/
>
<
/
>
}
}
<
/Segment
>
<
/
>
<
/
>
);
);
};
};
...
...
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