feat: able to use any link as about page (#60)
This commit is contained in:
parent
57cb150177
commit
2cdc718fde
@ -121,14 +121,14 @@ const OtherSetting = () => {
|
|||||||
value={inputs.HomePageContent}
|
value={inputs.HomePageContent}
|
||||||
name='HomePageContent'
|
name='HomePageContent'
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
style={{ minHeight: 300, fontFamily: 'JetBrains Mono, Consolas' }}
|
style={{ minHeight: 150, 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}
|
||||||
|
@ -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 = () => {
|
|||||||
|
|
||||||
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
|
||||||
</Segment>
|
src={about}
|
||||||
|
style={{ width: '100%', height: '100vh', border: 'none' }}
|
||||||
|
/> : <Segment>
|
||||||
|
<div style={{ fontSize: 'larger' }} dangerouslySetInnerHTML={{ __html: about }}></div>
|
||||||
|
</Segment>
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user