feat(platform): expose vehicle operations shortcuts

This commit is contained in:
lingniu
2026-07-04 14:14:06 +08:00
parent 67ebf89db9
commit d6c2edce7e
2 changed files with 49 additions and 6 deletions

View File

@@ -109,10 +109,17 @@ export function AppShell({
<Tag color="blue"></Tag>
<Tag color="grey"> / </Tag>
<Tag color={amapConfigured ? 'green' : 'orange'}>{amapConfigured ? '地图就绪' : '地图待配置'}</Tag>
<Button size="small" onClick={() => onChange('realtime')}></Button>
<Button size="small" onClick={() => onChange('history')}></Button>
<Button size="small" className={linkHealthClassName(linkIssueCount)} onClick={() => onChange('quality')}>
{linkIssueCount == null ? '链路监控' : linkIssueCount > 0 ? `链路 ${linkIssueCount} 项关注` : '链路正常'}
<Button size="small" aria-label="顶部实时监控" onClick={() => onChange('realtime')}></Button>
<Button size="small" aria-label="顶部轨迹回放" onClick={() => onChange('history')}></Button>
<Button size="small" aria-label="顶部历史查询" onClick={() => onChange('history')}></Button>
<Button size="small" aria-label="顶部统计查询" onClick={() => onChange('mileage')}></Button>
<Button
size="small"
aria-label={linkIssueCount == null ? '顶部告警通知' : linkIssueCount > 0 ? `顶部告警通知 ${linkIssueCount}项关注` : '顶部告警通知正常'}
className={linkHealthClassName(linkIssueCount)}
onClick={() => onChange('quality')}
>
{linkIssueCount == null ? '告警通知' : linkIssueCount > 0 ? `告警通知 ${linkIssueCount}项关注` : '告警通知正常'}
</Button>
</Space>
</header>

View File

@@ -29,6 +29,36 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
})
} as Response;
}
if (path.includes('/api/mileage/summary')) {
return {
ok: true,
json: async () => ({
data: { vehicleCount: 0, recordCount: 0, sourceCount: 0, totalMileageKm: 0, averageMileagePerVin: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/summary')) {
return {
ok: true,
json: async () => ({
data: { issueVehicleCount: 0, issueRecordCount: 0, errorCount: 0, warningCount: 0, protocols: [], issueTypes: [] },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/notification-plan')) {
return {
ok: true,
json: async () => ({
data: { rules: [], policies: [], priorityIssues: [], activeRuleCount: 0, p0RuleCount: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
@@ -42,10 +72,16 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
render(<App />);
expect(await screen.findByText('地图就绪')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '实时地图' }));
fireEvent.click(screen.getByRole('button', { name: '顶部实时监控' }));
expect(window.location.hash).toBe('#/realtime');
fireEvent.click(screen.getByRole('button', { name: '地图回放' }));
fireEvent.click(screen.getByRole('button', { name: '顶部轨迹回放' }));
expect(window.location.hash.startsWith('#/history')).toBe(true);
fireEvent.click(screen.getByRole('button', { name: '顶部历史查询' }));
expect(window.location.hash.startsWith('#/history')).toBe(true);
fireEvent.click(screen.getByRole('button', { name: '顶部统计查询' }));
expect(window.location.hash.startsWith('#/mileage')).toBe(true);
fireEvent.click(await screen.findByRole('button', { name: '顶部告警通知正常' }));
expect(window.location.hash).toBe('#/quality');
});
test('shows vehicle service status distribution on dashboard', async () => {