- 新增 fleetHealth / vehicleOps API、useVehicleHub 组合式与 VehicleHealthCard 卡片 - 新增 /admin/config/vehicle-hub 与 /monitor/vehicle-hub 双端路由及侧栏菜单 - car 类型补充 rawId/onboardUrl/lstatus 及 FleetHealthRow/VehicleCardModel - 后端 PageCatalog 注册「车辆运维」页,原「车辆维护」更名为「车辆维护策略」 Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
783 B
TypeScript
31 lines
783 B
TypeScript
import { reflectionApi } from './reflection'
|
|
|
|
export type VehicleMaintenanceMode = 'online' | 'offline' | 'repair' | 'blown'
|
|
|
|
const METHOD_MAP: Record<VehicleMaintenanceMode, string> = {
|
|
online: 'OnlineCar',
|
|
offline: 'OfflineCar',
|
|
repair: 'Repair',
|
|
blown: 'Blown'
|
|
}
|
|
|
|
export async function setVehicleMaintenance(
|
|
carId: number,
|
|
mode: VehicleMaintenanceMode
|
|
): Promise<boolean> {
|
|
const method = METHOD_MAP[mode]
|
|
if (!method) return false
|
|
try {
|
|
await reflectionApi.execute('car', carId, method)
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export function openOnboardWeb(url?: string | null, ip?: string | null): void {
|
|
const target = url ?? (ip ? `http://${ip}:8081` : null)
|
|
if (!target) return
|
|
window.open(target, '_blank', 'noopener,noreferrer')
|
|
}
|