♻️Refactor: About Page
This commit is contained in:
@@ -135,7 +135,7 @@ const LoginForm = () => {
|
|||||||
centered: true,
|
centered: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
navigate('/console/token');
|
navigate('/console');
|
||||||
} else {
|
} else {
|
||||||
showError(message);
|
showError(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
Divider,
|
Divider,
|
||||||
Form,
|
Form,
|
||||||
Icon,
|
Icon,
|
||||||
Layout,
|
|
||||||
Modal,
|
Modal,
|
||||||
} from '@douyinfe/semi-ui';
|
} from '@douyinfe/semi-ui';
|
||||||
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
||||||
|
|||||||
@@ -436,7 +436,7 @@
|
|||||||
"系统设置": "System Settings",
|
"系统设置": "System Settings",
|
||||||
"其他设置": "Other Settings",
|
"其他设置": "Other Settings",
|
||||||
"项目仓库地址": "Project Repository Address",
|
"项目仓库地址": "Project Repository Address",
|
||||||
"可在设置页面设置关于内容,支持 HTML & Markdown": "You can set the content about in the settings page, support HTML & Markdown",
|
"可在设置页面设置关于内容,支持 HTML & Markdown": "The About content can be set on the settings page, supporting HTML & Markdown",
|
||||||
"由": "developed by",
|
"由": "developed by",
|
||||||
"开发,基于": "based on",
|
"开发,基于": "based on",
|
||||||
"MIT 协议": "MIT License",
|
"MIT 协议": "MIT License",
|
||||||
@@ -866,7 +866,6 @@
|
|||||||
"查看全部": "View all",
|
"查看全部": "View all",
|
||||||
"高延迟": "high latency",
|
"高延迟": "high latency",
|
||||||
"异常": "abnormal",
|
"异常": "abnormal",
|
||||||
"API地址": "API address",
|
|
||||||
"的未命名令牌": "unnamed token",
|
"的未命名令牌": "unnamed token",
|
||||||
"令牌更新成功!": "Token updated successfully!",
|
"令牌更新成功!": "Token updated successfully!",
|
||||||
"(origin) Discord原链接": "(origin) Discord original link",
|
"(origin) Discord原链接": "(origin) Discord original link",
|
||||||
@@ -1403,5 +1402,9 @@
|
|||||||
"版权所有": "All rights reserved",
|
"版权所有": "All rights reserved",
|
||||||
"设计与开发由": "Designed & Developed with love by",
|
"设计与开发由": "Designed & Developed with love by",
|
||||||
"演示站点": "Demo Site",
|
"演示站点": "Demo Site",
|
||||||
"页面未找到,请检查您的浏览器地址是否正确": "Page not found, please check if your browser address is correct"
|
"页面未找到,请检查您的浏览器地址是否正确": "Page not found, please check if your browser address is correct",
|
||||||
|
"New API项目仓库地址:": "New API project repository address: ",
|
||||||
|
"NewAPI © {{currentYear}} QuantumNous | 基于 One API v0.5.4 © 2023 JustSong。": "NewAPI © {{currentYear}} QuantumNous | Based on One API v0.5.4 © 2023 JustSong.",
|
||||||
|
"本项目根据MIT许可证授权,需在遵守Apache-2.0协议的前提下使用。": "This project is licensed under the MIT License and must be used in compliance with the Apache-2.0 License.",
|
||||||
|
"管理员暂时未设置任何关于内容": "The administrator has not set any custom About content yet"
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { API, showError } from '../../helpers';
|
import { API, showError } from '../../helpers';
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import { Layout } from '@douyinfe/semi-ui';
|
import { Empty } from '@douyinfe/semi-ui';
|
||||||
|
import { IllustrationConstruction, IllustrationConstructionDark } from '@douyinfe/semi-illustrations';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const About = () => {
|
const About = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const [about, setAbout] = useState('');
|
const [about, setAbout] = useState('');
|
||||||
const [aboutLoaded, setAboutLoaded] = useState(false);
|
const [aboutLoaded, setAboutLoaded] = useState(false);
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
const displayAbout = async () => {
|
const displayAbout = async () => {
|
||||||
setAbout(localStorage.getItem('about') || '');
|
setAbout(localStorage.getItem('about') || '');
|
||||||
@@ -20,7 +25,7 @@ const About = () => {
|
|||||||
localStorage.setItem('about', aboutContent);
|
localStorage.setItem('about', aboutContent);
|
||||||
} else {
|
} else {
|
||||||
showError(message);
|
showError(message);
|
||||||
setAbout('加载关于内容失败...');
|
setAbout(t('加载关于内容失败...'));
|
||||||
}
|
}
|
||||||
setAboutLoaded(true);
|
setAboutLoaded(true);
|
||||||
};
|
};
|
||||||
@@ -29,30 +34,39 @@ const About = () => {
|
|||||||
displayAbout().then();
|
displayAbout().then();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const emptyStyle = {
|
||||||
|
padding: '24px'
|
||||||
|
};
|
||||||
|
|
||||||
|
const customDescription = (
|
||||||
|
<div style={{ textAlign: 'center' }}>
|
||||||
|
<p>{t('可在设置页面设置关于内容,支持 HTML & Markdown')}</p>
|
||||||
|
{t('New API项目仓库地址:')}
|
||||||
|
<Link to='https://github.com/QuantumNous/new-api' target="_blank">
|
||||||
|
https://github.com/QuantumNous/new-api
|
||||||
|
</Link>
|
||||||
|
<p>
|
||||||
|
{t('NewAPI © {{currentYear}} QuantumNous | 基于 One API v0.5.4 © 2023 JustSong。', { currentYear })}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{t('本项目根据MIT许可证授权,需在遵守Apache-2.0协议的前提下使用。')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{aboutLoaded && about === '' ? (
|
{aboutLoaded && about === '' ? (
|
||||||
<>
|
<div className="flex justify-center items-center h-screen p-8">
|
||||||
<Layout>
|
<Empty
|
||||||
<Layout.Header>
|
image={<IllustrationConstruction style={{ width: 150, height: 150 }} />}
|
||||||
<h3>关于</h3>
|
darkModeImage={<IllustrationConstructionDark style={{ width: 150, height: 150 }} />}
|
||||||
</Layout.Header>
|
description={t('管理员暂时未设置任何关于内容')}
|
||||||
<Layout.Content>
|
style={emptyStyle}
|
||||||
<p>可在设置页面设置关于内容,支持 HTML & Markdown</p>
|
>
|
||||||
New-API项目仓库地址:
|
{customDescription}
|
||||||
<a href='https://github.com/Calcium-Ion/new-api'>
|
</Empty>
|
||||||
https://github.com/Calcium-Ion/new-api
|
</div>
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
NewAPI © 2023 CalciumIon | 基于 One API v0.5.4 © 2023
|
|
||||||
JustSong。
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
本项目根据MIT许可证授权,需在遵守Apache-2.0协议的前提下使用。
|
|
||||||
</p>
|
|
||||||
</Layout.Content>
|
|
||||||
</Layout>
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{about.startsWith('https://') ? (
|
{about.startsWith('https://') ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user