2023-04-22 20:39:27 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
|
import { Header, Segment } from 'semantic-ui-react';
|
|
|
|
|
|
import { API, showError } from '../../helpers';
|
|
|
|
|
|
import { marked } from 'marked';
|
2023-12-05 21:09:48 +08:00
|
|
|
|
import {Layout} from "@douyinfe/semi-ui";
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
const About = () => {
|
|
|
|
|
|
const [about, setAbout] = useState('');
|
2023-05-14 16:13:42 +08:00
|
|
|
|
const [aboutLoaded, setAboutLoaded] = useState(false);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
const displayAbout = async () => {
|
2023-05-14 16:13:42 +08:00
|
|
|
|
setAbout(localStorage.getItem('about') || '');
|
2023-04-22 20:39:27 +08:00
|
|
|
|
const res = await API.get('/api/about');
|
|
|
|
|
|
const { success, message, data } = res.data;
|
|
|
|
|
|
if (success) {
|
2023-05-14 18:58:54 +08:00
|
|
|
|
let aboutContent = data;
|
|
|
|
|
|
if (!data.startsWith('https://')) {
|
|
|
|
|
|
aboutContent = marked.parse(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
setAbout(aboutContent);
|
|
|
|
|
|
localStorage.setItem('about', aboutContent);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showError(message);
|
|
|
|
|
|
setAbout('加载关于内容失败...');
|
|
|
|
|
|
}
|
2023-05-14 16:13:42 +08:00
|
|
|
|
setAboutLoaded(true);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
displayAbout().then();
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<>
|
2023-05-14 18:58:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
aboutLoaded && about === '' ? <>
|
2023-12-05 21:09:48 +08:00
|
|
|
|
<Layout>
|
|
|
|
|
|
<Layout.Header>
|
|
|
|
|
|
<h3>关于</h3>
|
|
|
|
|
|
</Layout.Header>
|
|
|
|
|
|
<Layout.Content>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
可在设置页面设置关于内容,支持 HTML & Markdown
|
|
|
|
|
|
</p>
|
|
|
|
|
|
new-api项目仓库地址:
|
|
|
|
|
|
<a href='https://github.com/Calcium-Ion/new-api'>
|
|
|
|
|
|
https://github.com/Calcium-Ion/new-api
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
NewAPI © 2023 CalciumIon | 基于 One API v0.5.4 © 2023 JustSong。本项目根据MIT许可证授权。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</Layout.Content>
|
|
|
|
|
|
</Layout>
|
2023-05-14 18:58:54 +08:00
|
|
|
|
</> : <>
|
|
|
|
|
|
{
|
|
|
|
|
|
about.startsWith('https://') ? <iframe
|
|
|
|
|
|
src={about}
|
|
|
|
|
|
style={{ width: '100%', height: '100vh', border: 'none' }}
|
2023-07-23 13:25:28 +08:00
|
|
|
|
/> : <div style={{ fontSize: 'larger' }} dangerouslySetInnerHTML={{ __html: about }}></div>
|
2023-05-14 18:58:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
2023-04-22 20:39:27 +08:00
|
|
|
|
</>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default About;
|