Footer.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { useEffect, useState } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { getFooterHTML, getSystemName } from '../helpers';
  4. import { Layout, Tooltip } from '@douyinfe/semi-ui';
  5. const FooterBar = () => {
  6. const { t } = useTranslation();
  7. const systemName = getSystemName();
  8. const [footer, setFooter] = useState(getFooterHTML());
  9. let remainCheckTimes = 5;
  10. const loadFooter = () => {
  11. let footer_html = localStorage.getItem('footer_html');
  12. if (footer_html) {
  13. setFooter(footer_html);
  14. }
  15. };
  16. const defaultFooter = (
  17. <div className='custom-footer'>
  18. <a
  19. href='https://github.com/Calcium-Ion/new-api'
  20. target='_blank'
  21. rel='noreferrer'
  22. >
  23. New API {import.meta.env.VITE_REACT_APP_VERSION}{' '}
  24. </a>
  25. {t('由')}{' '}
  26. <a
  27. href='https://github.com/Calcium-Ion'
  28. target='_blank'
  29. rel='noreferrer'
  30. >
  31. Calcium-Ion
  32. </a>{' '}
  33. {t('开发,基于')}{' '}
  34. <a
  35. href='https://github.com/songquanpeng/one-api'
  36. target='_blank'
  37. rel='noreferrer'
  38. >
  39. One API
  40. </a>
  41. </div>
  42. );
  43. useEffect(() => {
  44. const timer = setInterval(() => {
  45. if (remainCheckTimes <= 0) {
  46. clearInterval(timer);
  47. return;
  48. }
  49. remainCheckTimes--;
  50. loadFooter();
  51. }, 200);
  52. return () => clearTimeout(timer);
  53. }, []);
  54. return (
  55. <div style={{ textAlign: 'center' }}>
  56. {footer ? (
  57. <div
  58. className='custom-footer'
  59. dangerouslySetInnerHTML={{ __html: footer }}
  60. ></div>
  61. ) : (
  62. defaultFooter
  63. )}
  64. </div>
  65. );
  66. };
  67. export default FooterBar;