From b965abc3cb55b5ff4ead2810520c3827f548e438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 24 Dec 2025 13:56:34 +0800 Subject: [PATCH] Refactor dashboard and components, remove echarts Replaces echarts-based usage pie chart with a custom SVG implementation, removing the echarts dependency. Improves caching for version and system info requests, simplifies page background to static elements, and switches dashboard state to use localStorage for persistence. Also removes polling from hitokoto and updates button styling in system info. --- packages/napcat-webui-frontend/package.json | 3 +- .../src/components/hitokoto.tsx | 1 - .../src/components/page_background.tsx | 27 +-- .../src/components/system_info.tsx | 22 +- .../src/components/usage_pie.tsx | 212 ++++++++---------- .../src/pages/dashboard/index.tsx | 6 +- 6 files changed, 113 insertions(+), 158 deletions(-) diff --git a/packages/napcat-webui-frontend/package.json b/packages/napcat-webui-frontend/package.json index 273a6d1a..3d6f512f 100644 --- a/packages/napcat-webui-frontend/package.json +++ b/packages/napcat-webui-frontend/package.json @@ -59,7 +59,6 @@ "axios": "^1.7.9", "clsx": "^2.1.1", "crypto-js": "^4.2.0", - "echarts": "^5.5.1", "event-source-polyfill": "^1.0.31", "framer-motion": "^12.0.6", "monaco-editor": "^0.52.2", @@ -124,4 +123,4 @@ "react-dom": "$react-dom" } } -} +} \ No newline at end of file diff --git a/packages/napcat-webui-frontend/src/components/hitokoto.tsx b/packages/napcat-webui-frontend/src/components/hitokoto.tsx index d4e2d080..9cd1742d 100644 --- a/packages/napcat-webui-frontend/src/components/hitokoto.tsx +++ b/packages/napcat-webui-frontend/src/components/hitokoto.tsx @@ -19,7 +19,6 @@ export default function Hitokoto () { loading, run, } = useRequest(() => request.get('https://hitokoto.152710.xyz/'), { - pollingInterval: 10000, throttleWait: 1000, }); const backupData = { diff --git a/packages/napcat-webui-frontend/src/components/page_background.tsx b/packages/napcat-webui-frontend/src/components/page_background.tsx index a6b03417..f1106ddc 100644 --- a/packages/napcat-webui-frontend/src/components/page_background.tsx +++ b/packages/napcat-webui-frontend/src/components/page_background.tsx @@ -1,34 +1,15 @@ -import { motion } from 'motion/react'; const PageBackground = () => { return (
- {/* 动态呼吸光斑 - ACG风格 */} - - -
diff --git a/packages/napcat-webui-frontend/src/components/system_info.tsx b/packages/napcat-webui-frontend/src/components/system_info.tsx index 0d408f74..cd638ff7 100644 --- a/packages/napcat-webui-frontend/src/components/system_info.tsx +++ b/packages/napcat-webui-frontend/src/components/system_info.tsx @@ -293,7 +293,11 @@ const UpdateDialogContent: React.FC<{ const NewVersionTip = (props: NewVersionTipProps) => { const { currentVersion } = props; const dialog = useDialog(); - const { data: latestVersion, error } = useRequest(WebUIManager.getLatestTag); + const { data: latestVersion, error } = useRequest(WebUIManager.getLatestTag, { + cacheKey: 'napcat-latest-tag', + staleTime: 10 * 60 * 1000, + cacheTime: 30 * 60 * 1000, + }); const [updateStatus, setUpdateStatus] = useState('idle'); if (error || !latestVersion || !currentVersion || latestVersion === currentVersion) { @@ -362,9 +366,7 @@ const NewVersionTip = (props: NewVersionTipProps) => {