From ef17720dfebd9f652fb7fd7655fdb19c5da9e756 Mon Sep 17 00:00:00 2001 From: OG T Date: Wed, 8 Apr 2026 22:36:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E9=A6=96=E9=A0=81=20Tab=20?= =?UTF-8?q?=E5=88=87=E6=8F=9B=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E2=80=94=20activeTabId=20=E8=BF=BD=E8=B9=A4=20URL=20query=20?= =?UTF-8?q?=E8=AE=8A=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/app/[locale]/page.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/web/src/app/[locale]/page.tsx b/apps/web/src/app/[locale]/page.tsx index 9a69f1c8..928edefc 100644 --- a/apps/web/src/app/[locale]/page.tsx +++ b/apps/web/src/app/[locale]/page.tsx @@ -733,9 +733,20 @@ export default function Home({ params }: { params: { locale: string } }) { { id: 'disposition', label: '處置統計', content: }, ] - // 判斷目前 Tab - const searchParams = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : null - const currentTab = searchParams?.get('tab') || 'overview' + // Sprint 5: 從 URL 讀取當前 Tab + const [activeTabId, setActiveTabId] = useState('overview') + + // 每 100ms 檢查 URL query 變化(PageTabs 用 router.push 更新) + useEffect(() => { + const check = () => { + const params = new URLSearchParams(window.location.search) + const tab = params.get('tab') || 'overview' + setActiveTabId(prev => prev !== tab ? tab : prev) + } + check() + const interval = setInterval(check, 100) + return () => clearInterval(interval) + }, []) return ( @@ -746,8 +757,8 @@ export default function Home({ params }: { params: { locale: string } }) { syncWithUrl={true} /> - {/* Tab 1 戰情總覽: 顯示現有首頁完整內容 (不動任何東西) */} - {(currentTab === 'overview' || !currentTab) && ( + {/* Tab 1 戰情總覽: 顯示現有首頁完整內容 */} + {activeTabId === 'overview' && (