From a96f1aaf478df50c42f362f9343a4bd6f02992e8 Mon Sep 17 00:00:00 2001 From: pengzhen02 Date: Fri, 13 Mar 2026 18:29:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E8=B7=AF=E7=94=B1=E5=88=B7=E6=96=B0=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E5=85=A8=E9=A1=B5=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 window.location.reload() 替换为 router.refresh() - 避免每次切换页面时完全刷新,提升性能 - 添加 router 依赖到 useEffect 依赖数组 --- frontend/src/components/templates/DashboardShell.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/templates/DashboardShell.tsx b/frontend/src/components/templates/DashboardShell.tsx index f88cd60df..69257740b 100644 --- a/frontend/src/components/templates/DashboardShell.tsx +++ b/frontend/src/components/templates/DashboardShell.tsx @@ -58,7 +58,8 @@ export function DashboardShell({ children }: { children: ReactNode }) { const handleStorage = (event: StorageEvent) => { if (event.key !== "openclaw_org_switch" || !event.newValue) return; - window.location.reload(); + // 使用客户端路由刷新替代全页刷新,提升性能 + router.refresh(); }; window.addEventListener("storage", handleStorage); @@ -67,7 +68,8 @@ export function DashboardShell({ children }: { children: ReactNode }) { if ("BroadcastChannel" in window) { channel = new BroadcastChannel("org-switch"); channel.onmessage = () => { - window.location.reload(); + // 使用客户端路由刷新替代全页刷新,提升性能 + router.refresh(); }; } @@ -75,7 +77,7 @@ export function DashboardShell({ children }: { children: ReactNode }) { window.removeEventListener("storage", handleStorage); channel?.close(); }; - }, []); + }, [router]); const toggleSidebar = useCallback( () => setSidebarState((prev) => ({ open: !prev.open, path: pathname })),