From 30c15ec8fdd00307006432142053ff25b5722884 Mon Sep 17 00:00:00 2001 From: lingniu Date: Sun, 5 Jul 2026 19:11:10 +0800 Subject: [PATCH] feat(platform): preserve vehicle context in topbar tasks --- vehicle-data-platform/apps/web/src/layout/AppShell.tsx | 4 ++-- vehicle-data-platform/apps/web/src/test/App.test.tsx | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vehicle-data-platform/apps/web/src/layout/AppShell.tsx b/vehicle-data-platform/apps/web/src/layout/AppShell.tsx index e9b3ac28..a680b74e 100644 --- a/vehicle-data-platform/apps/web/src/layout/AppShell.tsx +++ b/vehicle-data-platform/apps/web/src/layout/AppShell.tsx @@ -272,7 +272,7 @@ export function AppShell({ {amapConfigured ? '高德地图就绪' : '高德地图待配置'}
{quickActions.map((item) => ( - ))} @@ -281,7 +281,7 @@ export function AppShell({ size="small" aria-label={`顶部${alertLabel}`} className={alertClassName} - onClick={() => onChange('alert-events')} + onClick={() => (onCustomerTask ?? onChange)('alert-events')} > {alertLabel} 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 ed0d9ce1..2fa71129 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -2946,6 +2946,15 @@ test('shows resolved vehicle service status after topbar search', async () => { expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/vehicle-service/overview?keyword=%E7%B2%A4AG18312'), undefined); expect(fetchMock).not.toHaveBeenCalledWith(expect.stringContaining('/api/vehicles/resolve'), undefined); + fireEvent.click(screen.getByRole('button', { name: '顶部地图态势' })); + expect(window.location.hash).toBe('#/map?keyword=LB9A32A24R0LS1426&protocol=JT808'); + fireEvent.click(screen.getByRole('button', { name: '顶部实时监控' })); + expect(window.location.hash).toBe('#/realtime?keyword=LB9A32A24R0LS1426&protocol=JT808'); + fireEvent.click(screen.getByRole('button', { name: '顶部数据导出' })); + expect(window.location.hash).toBe('#/history-query?keyword=LB9A32A24R0LS1426&protocol=JT808&tab=raw'); + fireEvent.click(await screen.findByRole('button', { name: '顶部告警事件正常' })); + expect(window.location.hash).toBe('#/alert-events?keyword=LB9A32A24R0LS1426&protocol=JT808'); + fireEvent.click(screen.getByRole('button', { name: '客户任务 轨迹回放 这段时间怎么跑' })); expect(window.location.hash).toBe('#/history?keyword=LB9A32A24R0LS1426&protocol=JT808'); fireEvent.click(screen.getByRole('button', { name: '客户任务 统计查询 里程怎么算' }));