import React, { useMemo } from 'react'; import { Spin, Empty } from 'antd'; import { ClockCircleOutlined, EnvironmentOutlined, SendOutlined, NodeIndexOutlined, } from '@ant-design/icons'; import type { BoatRouteListVO, BoatWaypointVO } from '@/types/boatRoute'; import styles from './index.less'; interface LeftPanelProps { routes: BoatRouteListVO[]; routeWaypointsMap: Record; loading: boolean; selectedRouteId: string | null; onSelectRoute: (routeId: string | null) => void; } /** 格式化时间(秒 → "XX分钟") */ const formatDuration = (seconds?: number) => { if (!seconds || seconds <= 0) return null; const min = Math.round(seconds / 60); return min > 0 ? `${min}分钟` : '<1分钟'; }; /** 格式化距离 */ const formatDistance = (meters?: number) => { if (!meters || meters <= 0) return null; return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`; }; const LeftPanel: React.FC = ({ routes, routeWaypointsMap, loading, selectedRouteId, onSelectRoute, }) => { return (
游览线路
选择线路开始游览
{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 waypointNames = waypoints .filter((wp) => wp.pointName) .map((wp) => wp.pointName); return (
onSelectRoute(isSelected ? null : route.routeId)} > {/* 线路名称 */}
{route.routeName}
{/* 时长 + 距离 标签 */}
{duration && ( {duration} )} {distance && ( {distance} )} {route.waypointCount || waypoints.length}个景点
{/* 航点路径 */} {waypointNames.length > 0 && (
{waypointNames.map((name, idx) => ( {name} {idx < waypointNames.length - 1 && ( → )} ))}
)}
); }) )}
); }; export default LeftPanel;