feat(platform): separate history capability entry
This commit is contained in:
@@ -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<string, unknown> = {}): Re
|
||||
|
||||
function normalizeHistoryFilterValues(filters: Record<string, unknown> = {}): Record<string, string> {
|
||||
const normalized: Record<string, string> = {};
|
||||
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;
|
||||
|
||||
@@ -260,7 +260,7 @@ export function Dashboard({
|
||||
title: '历史数据查询',
|
||||
description: '查询位置历史、RAW 帧和解析字段,为车辆问题复盘提供证据链。',
|
||||
action: '查询历史',
|
||||
onClick: () => onOpenHistory()
|
||||
onClick: () => onOpenHistory({ tab: 'raw' })
|
||||
},
|
||||
{
|
||||
title: '告警事件触发与通知',
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user