import React from 'react'; import { history, useLocation } from 'umi'; import { Dropdown, Space } from 'antd'; import { SwapOutlined } from '@ant-design/icons'; import type { MenuProps } from 'antd'; import './PlatformSwitcher.less'; // 船舶图标 const ShipIcon = () => ( ); // 仪表盘图标 const DashboardIcon = () => ( ); interface Platform { key: string; label: string; path: string; icon: React.ReactNode; description: string; theme: 'cyan' | 'ocean'; } const platforms: Platform[] = [ { key: 'dashboard', label: '无人机智慧城市', path: '/dashboard', icon: , description: '城市态势与空地协同', theme: 'cyan', }, { key: 'maritime', label: '海事智慧监控', path: '/maritime', icon: , description: '船舶追踪与海域监控', theme: 'ocean', }, ]; interface PlatformSwitcherProps { className?: string; } const PlatformSwitcher: React.FC = ({ className }) => { const location = useLocation(); // 确定当前平台 const currentPlatform = platforms.find(p => location.pathname.startsWith(p.path)) || platforms[0]; const isMaritime = currentPlatform.key === 'maritime'; const handlePlatformChange = (path: string) => { history.push(path); }; const menuItems: MenuProps['items'] = platforms.map(platform => ({ key: platform.key, label: ( {platform.icon} {platform.label} {platform.description} {platform.key === currentPlatform.key && ( ✓ )} ), onClick: () => handlePlatformChange(platform.path), })); return ( {currentPlatform.icon} {currentPlatform.label} ); }; export default PlatformSwitcher;