mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-11-04 15:53:42 +08:00 
			
		
		
		
	fix: fix footer not updated asap
This commit is contained in:
		@@ -1,11 +1,31 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import React, { useEffect, useState } from 'react';
 | 
			
		||||
 | 
			
		||||
import { Container, Segment } from 'semantic-ui-react';
 | 
			
		||||
import { getFooterHTML, getSystemName } from '../helpers';
 | 
			
		||||
 | 
			
		||||
const Footer = () => {
 | 
			
		||||
  const systemName = getSystemName();
 | 
			
		||||
  const footer = getFooterHTML();
 | 
			
		||||
  const [footer, setFooter] = useState(getFooterHTML());
 | 
			
		||||
  let remainCheckTimes = 5;
 | 
			
		||||
 | 
			
		||||
  const loadFooter = () => {
 | 
			
		||||
    let footer_html = localStorage.getItem('footer_html');
 | 
			
		||||
    if (footer_html) {
 | 
			
		||||
      setFooter(footer_html);
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    const timer = setInterval(() => {
 | 
			
		||||
      if (remainCheckTimes <= 0) {
 | 
			
		||||
        clearInterval(timer);
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      remainCheckTimes--;
 | 
			
		||||
      loadFooter();
 | 
			
		||||
    }, 200);
 | 
			
		||||
    return () => clearTimeout(timer);
 | 
			
		||||
  }, []);
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <Segment vertical>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import React, { useEffect, useState } from 'react';
 | 
			
		||||
import { Button, Divider, Form, Grid, Header, Modal } from 'semantic-ui-react';
 | 
			
		||||
import { Button, Divider, Form, Grid, Header, Message, Modal } from 'semantic-ui-react';
 | 
			
		||||
import { API, showError, showSuccess } from '../helpers';
 | 
			
		||||
import { marked } from 'marked';
 | 
			
		||||
 | 
			
		||||
@@ -10,13 +10,13 @@ const OtherSetting = () => {
 | 
			
		||||
    About: '',
 | 
			
		||||
    SystemName: '',
 | 
			
		||||
    Logo: '',
 | 
			
		||||
    HomePageContent: '',
 | 
			
		||||
    HomePageContent: ''
 | 
			
		||||
  });
 | 
			
		||||
  let [loading, setLoading] = useState(false);
 | 
			
		||||
  const [showUpdateModal, setShowUpdateModal] = useState(false);
 | 
			
		||||
  const [updateData, setUpdateData] = useState({
 | 
			
		||||
    tag_name: '',
 | 
			
		||||
    content: '',
 | 
			
		||||
    content: ''
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const getOptions = async () => {
 | 
			
		||||
@@ -43,7 +43,7 @@ const OtherSetting = () => {
 | 
			
		||||
    setLoading(true);
 | 
			
		||||
    const res = await API.put('/api/option/', {
 | 
			
		||||
      key,
 | 
			
		||||
      value,
 | 
			
		||||
      value
 | 
			
		||||
    });
 | 
			
		||||
    const { success, message } = res.data;
 | 
			
		||||
    if (success) {
 | 
			
		||||
@@ -97,7 +97,7 @@ const OtherSetting = () => {
 | 
			
		||||
    } else {
 | 
			
		||||
      setUpdateData({
 | 
			
		||||
        tag_name: tag_name,
 | 
			
		||||
        content: marked.parse(body),
 | 
			
		||||
        content: marked.parse(body)
 | 
			
		||||
      });
 | 
			
		||||
      setShowUpdateModal(true);
 | 
			
		||||
    }
 | 
			
		||||
@@ -153,7 +153,7 @@ const OtherSetting = () => {
 | 
			
		||||
              style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
 | 
			
		||||
            />
 | 
			
		||||
          </Form.Group>
 | 
			
		||||
          <Form.Button onClick={()=>submitOption('HomePageContent')}>保存首页内容</Form.Button>
 | 
			
		||||
          <Form.Button onClick={() => submitOption('HomePageContent')}>保存首页内容</Form.Button>
 | 
			
		||||
          <Form.Group widths='equal'>
 | 
			
		||||
            <Form.TextArea
 | 
			
		||||
              label='关于'
 | 
			
		||||
@@ -165,6 +165,7 @@ const OtherSetting = () => {
 | 
			
		||||
            />
 | 
			
		||||
          </Form.Group>
 | 
			
		||||
          <Form.Button onClick={submitAbout}>保存关于</Form.Button>
 | 
			
		||||
          <Message>移除 One API 的版权标识必须首先获得授权,后续版本将通过授权码强制执行。</Message>
 | 
			
		||||
          <Form.Group widths='equal'>
 | 
			
		||||
            <Form.Input
 | 
			
		||||
              label='页脚'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user