Files
new-api/web/src/components/Footer.js

74 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-06-17 11:03:01 +08:00
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { getFooterHTML, getSystemName } from '../helpers';
2024-05-24 21:27:13 +08:00
import { Layout, Tooltip } from '@douyinfe/semi-ui';
2023-04-22 20:39:27 +08:00
2024-09-17 19:55:18 +08:00
const FooterBar = () => {
const { t } = useTranslation();
const systemName = getSystemName();
2023-06-17 11:03:01 +08:00
const [footer, setFooter] = useState(getFooterHTML());
let remainCheckTimes = 5;
const loadFooter = () => {
let footer_html = localStorage.getItem('footer_html');
if (footer_html) {
setFooter(footer_html);
}
};
2024-05-24 21:27:13 +08:00
const defaultFooter = (
<div className='custom-footer'>
<a
href='https://github.com/Calcium-Ion/new-api'
target='_blank'
rel='noreferrer'
>
New API {import.meta.env.VITE_REACT_APP_VERSION}{' '}
</a>
{t('由')}{' '}
2024-05-24 21:27:13 +08:00
<a
href='https://github.com/Calcium-Ion'
target='_blank'
rel='noreferrer'
>
Calcium-Ion
</a>{' '}
{t('开发,基于')}{' '}
2024-05-24 21:27:13 +08:00
<a
href='https://github.com/songquanpeng/one-api'
target='_blank'
rel='noreferrer'
>
One API
</a>
</div>
);
2023-06-17 11:03:01 +08:00
useEffect(() => {
const timer = setInterval(() => {
if (remainCheckTimes <= 0) {
clearInterval(timer);
return;
}
remainCheckTimes--;
loadFooter();
}, 200);
return () => clearTimeout(timer);
}, []);
2023-04-22 20:39:27 +08:00
return (
2024-09-17 19:55:18 +08:00
<div style={{ textAlign: 'center' }}>
{footer ? (
<div
className='custom-footer'
dangerouslySetInnerHTML={{ __html: footer }}
></div>
) : (
defaultFooter
)}
</div>
2023-04-22 20:39:27 +08:00
);
};
2024-09-17 19:55:18 +08:00
export default FooterBar;