Footer.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { useEffect, useState } from 'react';
  2. import { getFooterHTML, getSystemName } from '../helpers';
  3. import { Layout, Tooltip } from '@douyinfe/semi-ui';
  4. const Footer = () => {
  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. <Layout>
  54. <Layout.Content style={{ textAlign: 'center' }}>
  55. {footer ? (
  56. <Tooltip content={defaultFooter}>
  57. <div
  58. className='custom-footer'
  59. dangerouslySetInnerHTML={{ __html: footer }}
  60. ></div>
  61. </Tooltip>
  62. ) : (
  63. defaultFooter
  64. )}
  65. </Layout.Content>
  66. </Layout>
  67. );
  68. };
  69. export default Footer;