feat(platform-web): link summary kpis to vehicle filters

This commit is contained in:
lingniu
2026-07-04 03:32:51 +08:00
parent 948dc774d0
commit a2ccc4a498
7 changed files with 141 additions and 18 deletions

View File

@@ -6,8 +6,11 @@ export type AppRoute = {
page?: PageKey;
keyword?: string;
protocol?: string;
filters?: Record<string, string>;
};
const filterKeys = ['coverage', 'serviceStatus', 'online', 'bindingStatus'] as const;
export function parseAppHash(hash: string): AppRoute {
const normalized = hash.trim().replace(/^#\/?/, '');
if (!normalized) {
@@ -20,7 +23,14 @@ export function parseAppHash(hash: string): AppRoute {
const params = new URLSearchParams(queryPart);
const keyword = params.get('keyword')?.trim() || undefined;
const protocol = params.get('protocol')?.trim() || undefined;
return { page: pagePart as PageKey, keyword, protocol };
const filters: Record<string, string> = {};
for (const key of filterKeys) {
const value = params.get(key)?.trim();
if (value) {
filters[key] = value;
}
}
return { page: pagePart as PageKey, keyword, protocol, filters };
}
export function buildAppHash(route: AppRoute): string {
@@ -34,6 +44,12 @@ export function buildAppHash(route: AppRoute): string {
if (protocol) {
params.set('protocol', protocol);
}
for (const key of filterKeys) {
const value = route.filters?.[key]?.trim();
if (value) {
params.set(key, value);
}
}
const query = params.toString();
return query ? `#/${page}?${query}` : `#/${page}`;
}