Footer.js 1.9 KB

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