Footer.js 1.6 KB

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