import { Button, Input, Nav, Space, Tag, Toast } from '@douyinfe/semi-ui'; import { IconActivity, IconBarChartHStroked, IconHistogram, IconHome, IconMapPin, IconSearch, IconServer, IconSetting, IconBell, IconPulse } from '@douyinfe/semi-icons'; import type { ReactNode } from 'react'; import { useState } from 'react'; import type { VehicleSourceConsistency, VehicleServiceStatus } from '../api/types'; import { isAMapConfigured } from '../config/appConfig'; export type PageKey = 'dashboard' | 'vehicles' | 'map' | 'realtime' | 'detail' | 'history' | 'history-query' | 'mileage' | 'quality' | 'notification-rules' | 'ops-quality'; const navItems = [ { itemKey: 'dashboard', text: '运营驾驶舱', icon: }, { itemKey: 'vehicles', text: '车辆中心', icon: }, { itemKey: 'map', text: '地图态势', icon: }, { itemKey: 'realtime', text: '实时监控', icon: }, { itemKey: 'detail', text: '车辆档案', icon: }, { itemKey: 'history', text: '轨迹回放', icon: }, { itemKey: 'history-query', text: '历史查询', icon: }, { itemKey: 'mileage', text: '统计分析', icon: }, { itemKey: 'quality', text: '告警事件', icon: }, { itemKey: 'notification-rules', text: '通知规则', icon: }, { itemKey: 'ops-quality', text: '运维质量', icon: } ]; function linkHealthClassName(count: number | null) { if (count == null) { return ''; } return count > 0 ? 'vp-link-health-button-warning' : 'vp-link-health-button-ok'; } export function AppShell({ activePage, linkIssueCount, platformRelease, currentVehicleStatus, currentVehicleLabel, currentVehicleConsistency, onChange, onVehicleSearch, children }: { activePage: PageKey; linkIssueCount: number | null; platformRelease?: string; currentVehicleStatus?: VehicleServiceStatus; currentVehicleLabel?: string; currentVehicleConsistency?: VehicleSourceConsistency; onChange: (page: PageKey) => void; onVehicleSearch: (keyword: string) => void | Promise; children: ReactNode; }) { const [keyword, setKeyword] = useState(''); const [searching, setSearching] = useState(false); const amapConfigured = isAMapConfigured(); const search = () => { const value = keyword.trim(); if (!value) { Toast.warning('请输入 VIN / 车牌 / 手机号'); return; } setSearching(true); Promise.resolve(onVehicleSearch(value)).finally(() => setSearching(false)); }; return (
} placeholder="搜索 VIN / 车牌 / 手机号" value={keyword} onChange={setKeyword} onEnterPress={search} style={{ width: 320 }} /> {currentVehicleLabel ? {currentVehicleLabel} : null} {currentVehicleStatus ? ( 当前车辆:{currentVehicleStatus.title} ) : null} {currentVehicleConsistency ? ( 一致性:{currentVehicleConsistency.title || `${currentVehicleConsistency.onlineSourceCount}/${currentVehicleConsistency.sourceCount} 来源`} ) : null} 生产环境 {platformRelease ? 版本 {platformRelease} : null} 多源接入 / 一个车辆服务 {amapConfigured ? '地图就绪' : '地图待配置'}
{children}
); }