import React from 'react'; import { Spin, Empty } from 'antd'; import { EnvironmentOutlined, AimOutlined, ThunderboltOutlined, WifiOutlined, PlayCircleOutlined, EyeOutlined, CompassOutlined, DownOutlined, } from '@ant-design/icons'; import type { BoatRouteListVO, BoatWaypointVO, BoatTelemetryData } from '@/types/boatRoute'; import styles from './index.less'; interface LeftPanelProps { routes: BoatRouteListVO[]; routeWaypointsMap: Record; loading: boolean; selectedRouteId: string | null; onSelectRoute: (routeId: string | null) => void; deviceInfo: any; boatData: BoatTelemetryData | null; sseConnected: boolean; onStartSailing: (routeId: string) => Promise; onPreviewRoute: (routeId: string) => void; sailingLoading: boolean; } /** 格式化距离 */ const formatDistance = (meters?: number) => { if (!meters || meters <= 0) return null; return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`; }; /** 格式化时间(秒 → "XX分钟") */ const formatDuration = (seconds?: number) => { if (!seconds || seconds <= 0) return null; const min = Math.round(seconds / 60); return min > 0 ? `${min}分钟` : '<1分钟'; }; const LeftPanel: React.FC = ({ routes, routeWaypointsMap, loading, selectedRouteId, onSelectRoute, deviceInfo, boatData, sseConnected, onStartSailing, onPreviewRoute, sailingLoading, }) => { const battery = boatData?.battery ?? 0; const isOnline = sseConnected; return (
{/* ========== 设备状态卡片 ========== */}
设备状态 {isOnline ? '在线' : '离线'}
GPS 信号 {boatData?.longitude ? '强' : '弱'}
当前位置 {boatData?.longitude ? `${boatData.longitude.toFixed(2)}°E ${boatData.latitude.toFixed(2)}°N` : '--'}
电池电量
20 ? '#10b981' : '#ff4d4f', }} />
{battery}%
通信信号
{isOnline ? '4G LTE' : '无信号'}
{/* ========== 分隔线 ========== */}
{/* ========== 航线区域 ========== */}
浏览线路 {routes.length} 条航线
{loading ? (
) : routes.length === 0 ? (
) : (
{routes.map((route) => { const isSelected = selectedRouteId === route.routeId; const waypoints = routeWaypointsMap[route.routeId] || []; const duration = formatDuration(route.totalDuration); const distance = formatDistance(route.totalDistance); const wpCount = route.waypointCount || waypoints.length; return (
onSelectRoute(isSelected ? null : route.routeId)} >
{route.routeName}
就绪
{wpCount}个航点{distance ? ` · 约${distance}` : ''}{duration ? ` · 预计${duration}` : ''}
{/* 选中时显示操作按钮 */} {isSelected && (
e.stopPropagation()}>
)}
); })}
)} {routes.length > 2 &&
上下滑动查看更多航线
}
); }; export default LeftPanel;