From a6ad49dba09652e1773ecf2b130bfcd5a7dd5ed0 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sun, 17 Aug 2025 10:49:09 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E2=9A=A1=EF=B8=8F=20perf:=20Defer=20?= =?UTF-8?q?Visactor=20chart=20libs=20to=20dashboard;=20minimize=20home=20b?= =?UTF-8?q?undle"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b67a42e0a8643c9209601585d1d371ef7102bfb3. --- web/src/components/dashboard/ChartsPanel.jsx | 46 ++++++++----------- web/src/components/dashboard/StatsCards.jsx | 17 +++---- .../personal/cards/AccountManagement.js | 2 +- .../personal/cards/NotificationSettings.js | 2 +- .../personal/components/UserInfoHeader.js | 22 ++++++--- web/src/hooks/dashboard/useDashboardCharts.js | 17 ++----- 6 files changed, 46 insertions(+), 60 deletions(-) diff --git a/web/src/components/dashboard/ChartsPanel.jsx b/web/src/components/dashboard/ChartsPanel.jsx index 26a43b63..595e2e02 100644 --- a/web/src/components/dashboard/ChartsPanel.jsx +++ b/web/src/components/dashboard/ChartsPanel.jsx @@ -17,7 +17,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ -import React, { Suspense } from 'react'; +import React from 'react'; import { Card, Tabs, TabPane } from '@douyinfe/semi-ui'; import { PieChart } from 'lucide-react'; import { @@ -25,9 +25,7 @@ import { IconPulse, IconPieChart2Stroked } from '@douyinfe/semi-icons'; -const LazyVChart = React.lazy(() => - import('@visactor/react-vchart').then(m => ({ default: m.VChart })) -); +import { VChart } from '@visactor/react-vchart'; const ChartsPanel = ({ activeChartTab, @@ -88,36 +86,28 @@ const ChartsPanel = ({ >
{activeChartTab === '1' && ( - - - + )} {activeChartTab === '2' && ( - - - + )} {activeChartTab === '3' && ( - - - + )} {activeChartTab === '4' && ( - - - + )}
diff --git a/web/src/components/dashboard/StatsCards.jsx b/web/src/components/dashboard/StatsCards.jsx index cfbcdea3..ae614eb5 100644 --- a/web/src/components/dashboard/StatsCards.jsx +++ b/web/src/components/dashboard/StatsCards.jsx @@ -17,12 +17,9 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ -import React, { Suspense } from 'react'; +import React from 'react'; import { Card, Avatar, Skeleton } from '@douyinfe/semi-ui'; - -const LazyVChart = React.lazy(() => - import('@visactor/react-vchart').then(m => ({ default: m.VChart })) -); +import { VChart } from '@visactor/react-vchart'; const StatsCards = ({ groupedStatsData, @@ -77,12 +74,10 @@ const StatsCards = ({ {(loading || (item.trendData && item.trendData.length > 0)) && (
- - - +
)} diff --git a/web/src/components/settings/personal/cards/AccountManagement.js b/web/src/components/settings/personal/cards/AccountManagement.js index 59f53cb8..b2c9017e 100644 --- a/web/src/components/settings/personal/cards/AccountManagement.js +++ b/web/src/components/settings/personal/cards/AccountManagement.js @@ -71,7 +71,7 @@ const AccountManagement = ({ - + {/* 账户绑定 Tab */} {() => ( - + {/* 通知配置 Tab */} { + const theme = useTheme(); const getUsername = () => { if (userState.user) { @@ -42,7 +44,16 @@ const UserInfoHeader = ({ t, userState }) => { }; return ( - + {/* 装饰性背景元素 */}
@@ -50,13 +61,12 @@ const UserInfoHeader = ({ t, userState }) => {
-
+
{getAvatarText()} @@ -103,7 +113,7 @@ const UserInfoHeader = ({ t, userState }) => { {/* 右上角统计信息(Semi UI 卡片) */}
- +
diff --git a/web/src/hooks/dashboard/useDashboardCharts.js b/web/src/hooks/dashboard/useDashboardCharts.js index ec99f3aa..a5ce0b19 100644 --- a/web/src/hooks/dashboard/useDashboardCharts.js +++ b/web/src/hooks/dashboard/useDashboardCharts.js @@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import { useState, useCallback, useEffect } from 'react'; +import { initVChartSemiTheme } from '@visactor/vchart-semi-theme'; import { modelColorMap, renderNumber, @@ -417,19 +418,9 @@ export const useDashboardCharts = ( // ========== 初始化图表主题 ========== useEffect(() => { - // 动态加载 visactor 主题,避免首页首屏加载 - let canceled = false; - (async () => { - try { - const mod = await import('@visactor/vchart-semi-theme'); - if (!canceled && mod?.initVChartSemiTheme) { - mod.initVChartSemiTheme({ isWatchingThemeSwitch: true }); - } - } catch (e) { - // 忽略加载失败,图表页再尝试 - } - })(); - return () => { canceled = true; }; + initVChartSemiTheme({ + isWatchingThemeSwitch: true, + }); }, []); return {