diff --git a/vehicle-data-platform/apps/web/src/App.tsx b/vehicle-data-platform/apps/web/src/App.tsx index 4db56d30..c306316d 100644 --- a/vehicle-data-platform/apps/web/src/App.tsx +++ b/vehicle-data-platform/apps/web/src/App.tsx @@ -299,12 +299,18 @@ export default function App() { const nextFilters = normalizeHistoryFilterValues(filters); const nextVin = nextFilters.keyword?.trim() || analysisVin; const nextProtocol = nextFilters.protocol?.trim() ?? activeProtocol; + const nextTab = nextFilters.tab === 'raw' ? 'raw' : 'location'; setAnalysisVin(nextVin); setActiveProtocol(nextProtocol); - setHistoryTab('location'); + setHistoryTab(nextTab); setHistoryFilters({ ...nextFilters, keyword: nextVin, protocol: nextProtocol }); setActivePage('history'); const { keyword, protocol, ...restFilters } = nextFilters; + if (nextTab === 'raw') { + restFilters.tab = nextTab; + } else { + delete restFilters.tab; + } replaceHash('history', keyword ?? nextVin, protocol ?? nextProtocol, restFilters); }; @@ -466,7 +472,7 @@ function normalizeMileageFilterValues(filters: Record = {}): Re function normalizeHistoryFilterValues(filters: Record = {}): Record { const normalized: Record = {}; - for (const key of ['keyword', 'protocol', 'dateFrom', 'dateTo', 'fields'] as const) { + for (const key of ['keyword', 'protocol', 'dateFrom', 'dateTo', 'fields', 'tab'] as const) { const value = String(filters[key] ?? '').trim(); if (value) { normalized[key] = value; diff --git a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx index 14e6ea23..c8bd93d2 100644 --- a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx +++ b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx @@ -260,7 +260,7 @@ export function Dashboard({ title: '历史数据查询', description: '查询位置历史、RAW 帧和解析字段,为车辆问题复盘提供证据链。', action: '查询历史', - onClick: () => onOpenHistory() + onClick: () => onOpenHistory({ tab: 'raw' }) }, { title: '告警事件触发与通知', diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index 76d4cce6..784da571 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -395,11 +395,13 @@ test('dashboard exposes vehicle data center capability matrix', async () => { await renderDashboard(); fireEvent.click(screen.getByRole('button', { name: '能力入口 轨迹回放' })); expect(window.location.hash.startsWith('#/history')).toBe(true); + expect(new URLSearchParams(window.location.hash.split('?')[1] ?? '').get('tab')).toBeNull(); cleanup(); await renderDashboard(); fireEvent.click(screen.getByRole('button', { name: '能力入口 历史数据查询' })); expect(window.location.hash.startsWith('#/history')).toBe(true); + expect(new URLSearchParams(window.location.hash.split('?')[1] ?? '').get('tab')).toBe('raw'); cleanup(); await renderDashboard();