fix(platform): load vehicle context by source
This commit is contained in:
@@ -31,12 +31,17 @@ export default function App() {
|
||||
const [currentVehicleLabel, setCurrentVehicleLabel] = useState('');
|
||||
const [currentVehicleConsistency, setCurrentVehicleConsistency] = useState<VehicleSourceConsistency | undefined>();
|
||||
|
||||
const loadVehicleContext = useCallback(async (keyword: string) => {
|
||||
const loadVehicleContext = useCallback(async (keyword: string, protocol?: string) => {
|
||||
const lookupKey = keyword.trim();
|
||||
if (!lookupKey) {
|
||||
return undefined;
|
||||
}
|
||||
const overview = await api.vehicleServiceOverview(new URLSearchParams({ keyword: lookupKey }));
|
||||
const params = new URLSearchParams({ keyword: lookupKey });
|
||||
const source = protocol?.trim();
|
||||
if (source) {
|
||||
params.set('protocol', source);
|
||||
}
|
||||
const overview = await api.vehicleServiceOverview(params);
|
||||
const nextKey = overview.vin || lookupKey;
|
||||
const resolved = Boolean(overview.vin);
|
||||
setCurrentVehicleStatus(overview.serviceStatus ?? serviceStatusFromOverview(overview));
|
||||
@@ -62,7 +67,7 @@ export default function App() {
|
||||
if (initialRoute.page !== 'detail' || !initialRoute.keyword) {
|
||||
return;
|
||||
}
|
||||
loadVehicleContext(initialRoute.keyword).catch((error) => {
|
||||
loadVehicleContext(initialRoute.keyword, initialRoute.protocol).catch((error) => {
|
||||
Toast.error(error instanceof Error ? error.message : '车辆查询失败');
|
||||
});
|
||||
}, [initialRoute.keyword, initialRoute.page, loadVehicleContext]);
|
||||
@@ -169,7 +174,7 @@ export default function App() {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const context = await loadVehicleContext(lookupKey);
|
||||
const context = await loadVehicleContext(lookupKey, nextProtocol);
|
||||
const resolved = context?.resolved;
|
||||
const nextKey = context?.nextKey ?? lookupKey;
|
||||
setActiveVin(nextKey);
|
||||
|
||||
Reference in New Issue
Block a user