feat(platform): preserve vehicle context in customer tasks

This commit is contained in:
lingniu
2026-07-05 19:07:50 +08:00
parent e48ea7d22a
commit 08c275af34
4 changed files with 53 additions and 5 deletions

View File

@@ -329,10 +329,12 @@ export default function App() {
const context = await loadVehicleContext(lookupKey, nextProtocol);
const resolved = context?.resolved;
const nextKey = context?.nextKey ?? lookupKey;
const resolvedProtocol = nextProtocol || context?.overview.primaryProtocol?.trim() || '';
setActiveVin(nextKey);
setActiveProtocol(nextProtocol);
setAnalysisVin(nextKey);
setActiveProtocol(resolvedProtocol);
setActivePage('detail');
replaceHash('detail', nextKey, nextProtocol);
replaceHash('detail', nextKey, resolvedProtocol);
if (!resolved) {
Toast.warning('未匹配到车辆身份,已打开问题排查视图');
}
@@ -443,6 +445,40 @@ export default function App() {
replaceHash('mileage', keyword ?? nextVin, protocol ?? nextProtocol, restFilters);
};
const openCustomerTask = (page: PageKey) => {
const keyword = (activeVin || analysisVin).trim();
const protocol = activeProtocol.trim();
if (!keyword) {
navigatePage(page);
return;
}
if (page === 'map') {
openMap({ keyword, protocol });
return;
}
if (page === 'realtime') {
openRealtime({ keyword, protocol });
return;
}
if (page === 'history') {
openHistoryWithFilters({ keyword, protocol });
return;
}
if (page === 'history-query') {
openRawWithFilters({ keyword, protocol, tab: 'raw' });
return;
}
if (page === 'mileage') {
openMileageWithFilters({ keyword, protocol });
return;
}
if (page === 'alert-events' || page === 'quality') {
openQuality({ keyword, protocol });
return;
}
navigatePage(page);
};
const updateVehicleDetailQuery = (keyword: string, protocol?: string) => {
const nextKeyword = keyword.trim();
const nextProtocol = protocol?.trim() ?? '';
@@ -476,7 +512,7 @@ export default function App() {
};
return (
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} activeAlertRuleCount={activeAlertRuleCount} p0AlertRuleCount={p0AlertRuleCount} platformRelease={platformRelease} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} onChange={navigatePage} onVehicleSearch={openVehicle}>
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} activeAlertRuleCount={activeAlertRuleCount} p0AlertRuleCount={p0AlertRuleCount} platformRelease={platformRelease} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} onChange={navigatePage} onCustomerTask={openCustomerTask} onVehicleSearch={openVehicle}>
{pages[activePage]}
</AppShell>
);