From 28d0a6a54c018e53cdc457899b38eba704380e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= <3311118881@qq.com> Date: Wed, 14 Aug 2024 19:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/{System.ts => Project.ts} | 0 src/hooks/useAuthRedirect.tsx | 4 +-- src/pages/Rss/index.tsx | 1 - src/pages/Setup/components/Layout/index.tsx | 4 +-- src/pages/Setup/components/Web/index.tsx | 2 +- src/types/project.d.ts | 28 ++++----------------- 6 files changed, 10 insertions(+), 29 deletions(-) rename src/api/{System.ts => Project.ts} (100%) diff --git a/src/api/System.ts b/src/api/Project.ts similarity index 100% rename from src/api/System.ts rename to src/api/Project.ts diff --git a/src/hooks/useAuthRedirect.tsx b/src/hooks/useAuthRedirect.tsx index 495d76c..c5fc290 100644 --- a/src/hooks/useAuthRedirect.tsx +++ b/src/hooks/useAuthRedirect.tsx @@ -2,7 +2,7 @@ import { useEffect } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { useUserStore } from '@/stores'; -// 如果即将去往的是 /login 页面并且有 token 情况就自动重定向到 /home,否则就跳转 +// 如果即将去往的是 /login 页面并且有 token 情况就自动重定向到 /,否则就跳转 const useAuthRedirect = () => { const store = useUserStore(); const navigate = useNavigate(); @@ -12,7 +12,7 @@ const useAuthRedirect = () => { const token = store.token; const isGoingToLogin = location.pathname === '/login'; - if (isGoingToLogin && token) navigate('/home'); + if (isGoingToLogin && token) navigate('/'); }, [location, navigate, store.token]); }; diff --git a/src/pages/Rss/index.tsx b/src/pages/Rss/index.tsx index 604d7ce..77c94fe 100644 --- a/src/pages/Rss/index.tsx +++ b/src/pages/Rss/index.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from 'react'; -import { MessageOutlined } from '@ant-design/icons'; import { Avatar, Card, List, Space, Spin } from 'antd'; import Title from '@/components/Title'; import { getRssListAPI } from '@/api/Rss'; diff --git a/src/pages/Setup/components/Layout/index.tsx b/src/pages/Setup/components/Layout/index.tsx index da95a2f..5f049be 100644 --- a/src/pages/Setup/components/Layout/index.tsx +++ b/src/pages/Setup/components/Layout/index.tsx @@ -1,8 +1,8 @@ import { useState, useEffect } from 'react'; import { notification, Divider, Input, Alert, Button, Spin } from 'antd'; import { PictureOutlined, LoadingOutlined } from '@ant-design/icons'; -import { editLayoutDataAPI, getLayoutDataAPI } from '@/api/System'; -import { Layout } from '@/types/system'; +import { editLayoutDataAPI, getLayoutDataAPI } from '@/api/Project'; +import { Layout } from '@/types/project'; const LayoutPage = () => { const [loading, setLoading] = useState(false); diff --git a/src/pages/Setup/components/Web/index.tsx b/src/pages/Setup/components/Web/index.tsx index b9d392d..99a035a 100644 --- a/src/pages/Setup/components/Web/index.tsx +++ b/src/pages/Setup/components/Web/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { Form, Input, Button, message } from 'antd'; -import { getWebDataAPI, editWebDataAPI } from '@/api/System'; +import { getWebDataAPI, editWebDataAPI } from '@/api/Project'; import { Web } from '@/types/project' const WebPage = () => { diff --git a/src/types/project.d.ts b/src/types/project.d.ts index 2363f47..271b92d 100644 --- a/src/types/project.d.ts +++ b/src/types/project.d.ts @@ -1,28 +1,10 @@ -// 磁盘 -export interface Disk { - diskFree: number; - diskPercent: number; - diskTotal: number; - diskUsed: number; -} - -// 内存 -export interface Memory { - memoryAvailable: number; - memoryPercent: number; - memoryTotal: number; - memoryUsed: number; -} - // 系统信息 export interface System { - boot_time: string; - cpu: number; - disk: Disk; - memory: Memory; - name: string; - run: number; - ip: number + osName: string, + osVersion: string, + totalMemory: number, + availableMemory: number, + memoryUsage: number } // 网站信息