Footer.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import React, { useEffect, useState } from 'react';
  2. import { getFooterHTML, getSystemName } from '../helpers';
  3. import { Layout } 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. useEffect(() => {
  15. const timer = setInterval(() => {
  16. if (remainCheckTimes <= 0) {
  17. clearInterval(timer);
  18. return;
  19. }
  20. remainCheckTimes--;
  21. loadFooter();
  22. }, 200);
  23. return () => clearTimeout(timer);
  24. }, []);
  25. return (
  26. <Layout>
  27. <Layout.Content style={{ textAlign: 'center' }}>
  28. {footer ? (
  29. <div
  30. className="custom-footer"
  31. dangerouslySetInnerHTML={{ __html: footer }}
  32. ></div>
  33. ) : (
  34. <div className="custom-footer">
  35. <a
  36. href="https://github.com/Calcium-Ion/new-api"
  37. target="_blank" rel="noreferrer"
  38. >
  39. New API {import.meta.env.VITE_REACT_APP_VERSION}{' '}
  40. </a>
  41. 由{' '}
  42. <a href="https://github.com/Calcium-Ion" target="_blank" rel="noreferrer">
  43. Calcium-Ion
  44. </a>{' '}
  45. 开发,基于{' '}
  46. <a href="https://github.com/songquanpeng/one-api" target="_blank" rel="noreferrer">
  47. One API v0.5.4
  48. </a>{' '}
  49. ,本项目根据{' '}
  50. <a href="https://opensource.org/licenses/mit-license.php">
  51. MIT 许可证
  52. </a>{' '}
  53. 授权
  54. </div>
  55. )}
  56. </Layout.Content>
  57. </Layout>
  58. );
  59. };
  60. export default Footer;