2025-07-19 03:30:44 +08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
|
import { API, showError } from '../../helpers';
|
|
|
|
|
|
import { marked } from 'marked';
|
2025-05-20 11:31:03 +08:00
|
|
|
|
import { Empty } from '@douyinfe/semi-ui';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
import {
|
|
|
|
|
|
IllustrationConstruction,
|
|
|
|
|
|
IllustrationConstructionDark,
|
|
|
|
|
|
} from '@douyinfe/semi-illustrations';
|
2025-05-20 11:31:03 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
const About = () => {
|
2025-05-20 11:31:03 +08:00
|
|
|
|
const { t } = useTranslation();
|
2023-04-22 20:39:27 +08:00
|
|
|
|
const [about, setAbout] = useState('');
|
2023-05-14 16:13:42 +08:00
|
|
|
|
const [aboutLoaded, setAboutLoaded] = useState(false);
|
2025-05-20 11:31:03 +08:00
|
|
|
|
const currentYear = new Date().getFullYear();
|
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);
|
2025-05-20 11:31:03 +08:00
|
|
|
|
setAbout(t('加载关于内容失败...'));
|
2023-04-22 20:39:27 +08:00
|
|
|
|
}
|
2023-05-14 16:13:42 +08:00
|
|
|
|
setAboutLoaded(true);
|
2023-04-22 20:39:27 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
displayAbout().then();
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2025-05-20 11:31:03 +08:00
|
|
|
|
const emptyStyle = {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
padding: '24px',
|
2025-05-20 11:31:03 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const customDescription = (
|
|
|
|
|
|
<div style={{ textAlign: 'center' }}>
|
|
|
|
|
|
<p>{t('可在设置页面设置关于内容,支持 HTML & Markdown')}</p>
|
|
|
|
|
|
{t('New API项目仓库地址:')}
|
2025-06-07 22:50:31 +08:00
|
|
|
|
<a
|
|
|
|
|
|
href='https://github.com/QuantumNous/new-api'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
2025-05-20 11:31:03 +08:00
|
|
|
|
https://github.com/QuantumNous/new-api
|
2025-06-07 22:50:31 +08:00
|
|
|
|
</a>
|
2025-05-20 11:31:03 +08:00
|
|
|
|
<p>
|
2025-06-07 22:50:31 +08:00
|
|
|
|
<a
|
2025-08-30 21:15:10 +08:00
|
|
|
|
href='https://github.com/QuantumNous/new-api'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
|
|
|
|
|
NewAPI
|
2025-08-30 21:15:10 +08:00
|
|
|
|
</a>{' '}
|
|
|
|
|
|
{t('© {{currentYear}}', { currentYear })}{' '}
|
|
|
|
|
|
<a
|
|
|
|
|
|
href='https://github.com/QuantumNous'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
|
|
|
|
|
QuantumNous
|
2025-08-30 21:15:10 +08:00
|
|
|
|
</a>{' '}
|
|
|
|
|
|
{t('| 基于')}{' '}
|
|
|
|
|
|
<a
|
|
|
|
|
|
href='https://github.com/songquanpeng/one-api/releases/tag/v0.5.4'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
|
|
|
|
|
One API v0.5.4
|
2025-08-30 21:15:10 +08:00
|
|
|
|
</a>{' '}
|
|
|
|
|
|
© 2023{' '}
|
|
|
|
|
|
<a
|
|
|
|
|
|
href='https://github.com/songquanpeng'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:55:12 +08:00
|
|
|
|
>
|
|
|
|
|
|
JustSong
|
|
|
|
|
|
</a>
|
2025-05-20 11:31:03 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
2025-06-07 22:50:31 +08:00
|
|
|
|
{t('本项目根据')}
|
|
|
|
|
|
<a
|
2025-08-30 21:15:10 +08:00
|
|
|
|
href='https://github.com/songquanpeng/one-api/blob/v0.5.4/LICENSE'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
2025-06-07 22:55:12 +08:00
|
|
|
|
{t('MIT许可证')}
|
2025-06-07 22:50:31 +08:00
|
|
|
|
</a>
|
|
|
|
|
|
{t('授权,需在遵守')}
|
|
|
|
|
|
<a
|
2025-08-30 21:15:10 +08:00
|
|
|
|
href='https://www.gnu.org/licenses/agpl-3.0.html'
|
|
|
|
|
|
target='_blank'
|
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
|
className='!text-semi-color-primary'
|
2025-06-07 22:50:31 +08:00
|
|
|
|
>
|
2025-07-20 15:52:57 +08:00
|
|
|
|
{t('AGPL v3.0协议')}
|
2025-06-07 22:50:31 +08:00
|
|
|
|
</a>
|
|
|
|
|
|
{t('的前提下使用。')}
|
2025-05-20 11:31:03 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2023-04-22 20:39:27 +08:00
|
|
|
|
return (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='mt-[60px] px-2'>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
{aboutLoaded && about === '' ? (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex justify-center items-center h-screen p-8'>
|
2025-05-20 11:31:03 +08:00
|
|
|
|
<Empty
|
2025-08-30 21:15:10 +08:00
|
|
|
|
image={
|
|
|
|
|
|
<IllustrationConstruction style={{ width: 150, height: 150 }} />
|
|
|
|
|
|
}
|
|
|
|
|
|
darkModeImage={
|
|
|
|
|
|
<IllustrationConstructionDark
|
|
|
|
|
|
style={{ width: 150, height: 150 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
2025-05-20 11:31:03 +08:00
|
|
|
|
description={t('管理员暂时未设置任何关于内容')}
|
|
|
|
|
|
style={emptyStyle}
|
|
|
|
|
|
>
|
|
|
|
|
|
{customDescription}
|
|
|
|
|
|
</Empty>
|
|
|
|
|
|
</div>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
) : (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{about.startsWith('https://') ? (
|
|
|
|
|
|
<iframe
|
2023-05-14 18:58:54 +08:00
|
|
|
|
src={about}
|
|
|
|
|
|
style={{ width: '100%', height: '100vh', border: 'none' }}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{ fontSize: 'larger' }}
|
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: about }}
|
|
|
|
|
|
></div>
|
|
|
|
|
|
)}
|
2023-05-14 18:58:54 +08:00
|
|
|
|
</>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
)}
|
2025-06-25 15:26:51 +08:00
|
|
|
|
</div>
|
2023-04-22 20:39:27 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default About;
|