fix(web): 首頁 Tab 切換同步修正 — activeTabId 追蹤 URL query 變化
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
OG T
2026-04-08 22:36:39 +08:00
parent 286df4b3e3
commit ef17720dfe

View File

@@ -733,9 +733,20 @@ export default function Home({ params }: { params: { locale: string } }) {
{ id: 'disposition', label: '處置統計', content: <DispositionTab /> },
]
// 判斷目前 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 (
<AppLayout locale={locale} showBackground={false} fullBleed>
@@ -746,8 +757,8 @@ export default function Home({ params }: { params: { locale: string } }) {
syncWithUrl={true}
/>
{/* Tab 1 戰情總覽: 顯示現有首頁完整內容 (不動任何東西) */}
{(currentTab === 'overview' || !currentTab) && (
{/* Tab 1 戰情總覽: 顯示現有首頁完整內容 */}
{activeTabId === 'overview' && (
<div style={{
display: 'flex',
flexDirection: 'column',