From a8eb0057e392cc8201ac88fbf3a759c51608fc53 Mon Sep 17 00:00:00 2001 From: tisonhuang Date: Sun, 1 Mar 2026 17:55:49 +0800 Subject: [PATCH] perf(export): keep page alive across route switches --- src/App.scss | 13 +++++++++++++ src/App.tsx | 16 +++++++++++++++- src/pages/ExportPage.tsx | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/App.scss b/src/App.scss index 3c137bd..5cffbbd 100644 --- a/src/App.scss +++ b/src/App.scss @@ -69,6 +69,19 @@ flex: 1; overflow: auto; padding: 24px; + position: relative; +} + +.export-keepalive-page { + height: 100%; + + &.hidden { + display: none; + } +} + +.export-route-anchor { + display: none; } @keyframes appFadeIn { diff --git a/src/App.tsx b/src/App.tsx index c999a80..adc32cc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -61,7 +61,9 @@ function App() { const isVideoPlayerWindow = location.pathname === '/video-player-window' const isChatHistoryWindow = location.pathname.startsWith('/chat-history/') const isNotificationWindow = location.pathname === '/notification-window' + const isExportRoute = location.pathname === '/export' const [themeHydrated, setThemeHydrated] = useState(false) + const [hasVisitedExport, setHasVisitedExport] = useState(isExportRoute) // 锁定状态 // const [isLocked, setIsLocked] = useState(false) // Moved to store @@ -99,6 +101,12 @@ function App() { } }, [isOnboardingWindow]) + useEffect(() => { + if (isExportRoute) { + setHasVisitedExport(true) + } + }, [isExportRoute]) + // 应用主题 useEffect(() => { const mq = window.matchMedia('(prefers-color-scheme: dark)') @@ -454,6 +462,12 @@ function App() {
+ {hasVisitedExport && ( +
+ +
+ )} + } /> } /> @@ -468,7 +482,7 @@ function App() { } /> } /> - } /> +