feat: 可视化大屏展示
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
/* 平台切换器样式 */
|
||||
|
||||
.platform-switcher {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 14px;
|
||||
background: rgba(0, 212, 255, 0.08);
|
||||
border: 1px solid rgba(0, 212, 255, 0.2);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 212, 255, 0.15);
|
||||
border-color: rgba(0, 212, 255, 0.35);
|
||||
}
|
||||
|
||||
&--ocean {
|
||||
background: rgba(0, 150, 200, 0.1);
|
||||
border-color: rgba(0, 180, 230, 0.25);
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 150, 200, 0.18);
|
||||
border-color: rgba(0, 180, 230, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
|
||||
&--cyan {
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
&--ocean {
|
||||
color: #00b4d8;
|
||||
}
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
&__arrow {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
&:hover &__arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 下拉菜单样式 */
|
||||
.platform-switcher-dropdown {
|
||||
:global(.ant-dropdown-menu) {
|
||||
background: rgba(15, 25, 45, 0.95) !important;
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(0, 180, 230, 0.2);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
padding: 8px;
|
||||
min-width: 260px;
|
||||
}
|
||||
|
||||
:global(.ant-dropdown-menu-item) {
|
||||
padding: 0 !important;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 4px;
|
||||
background: transparent !important;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 150, 200, 0.15) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.platform-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 14px;
|
||||
gap: 12px;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s;
|
||||
|
||||
&.active {
|
||||
background: rgba(0, 180, 230, 0.12);
|
||||
}
|
||||
|
||||
&__icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&--cyan {
|
||||
background: rgba(0, 212, 255, 0.15);
|
||||
color: #00d4ff;
|
||||
box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
|
||||
}
|
||||
|
||||
&--ocean {
|
||||
background: rgba(0, 180, 230, 0.15);
|
||||
color: #00b4d8;
|
||||
box-shadow: 0 0 12px rgba(0, 180, 230, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
font-size: 11px;
|
||||
color: rgba(200, 230, 255, 0.5);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__check {
|
||||
color: #00e5a0;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
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 = () => (
|
||||
<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
|
||||
<path d="M20 21c-1.39 0-2.78-.47-4-1.32-2.44 1.71-5.56 1.71-8 0C6.78 20.53 5.39 21 4 21H2v2h2c1.38 0 2.74-.35 4-.99 2.52 1.29 5.48 1.29 8 0 1.26.64 2.63.99 4 .99h2v-2h-2zM3.95 19H4c1.6 0 3.02-.88 4-2 .98 1.12 2.4 2 4 2s3.02-.88 4-2c.98 1.12 2.4 2 4 2h.05l1.89-6.68c.08-.26.06-.54-.06-.78s-.34-.42-.6-.5L20 10.62V6c0-1.1-.9-2-2-2h-3V1H9v3H6c-1.1 0-2 .9-2 2v4.62l-1.29.42c-.26.08-.48.26-.6.5s-.15.52-.06.78L3.95 19zM6 6h12v3.97L12 8 6 9.97V6z"/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// 仪表盘图标
|
||||
const DashboardIcon = () => (
|
||||
<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
|
||||
<path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
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: <DashboardIcon />,
|
||||
description: '设备监控与任务管理',
|
||||
theme: 'cyan',
|
||||
},
|
||||
{
|
||||
key: 'maritime',
|
||||
label: '海事智慧监控',
|
||||
path: '/maritime',
|
||||
icon: <ShipIcon />,
|
||||
description: '船舶追踪与海域监控',
|
||||
theme: 'ocean',
|
||||
},
|
||||
];
|
||||
|
||||
interface PlatformSwitcherProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const PlatformSwitcher: React.FC<PlatformSwitcherProps> = ({ 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: (
|
||||
<div className={`platform-menu-item ${platform.key === currentPlatform.key ? 'active' : ''}`}>
|
||||
<span className={`platform-menu-item__icon platform-menu-item__icon--${platform.theme}`}>
|
||||
{platform.icon}
|
||||
</span>
|
||||
<div className="platform-menu-item__content">
|
||||
<div className="platform-menu-item__label">{platform.label}</div>
|
||||
<div className="platform-menu-item__desc">{platform.description}</div>
|
||||
</div>
|
||||
{platform.key === currentPlatform.key && (
|
||||
<span className="platform-menu-item__check">✓</span>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
onClick: () => handlePlatformChange(platform.path),
|
||||
}));
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
menu={{ items: menuItems }}
|
||||
placement="bottomLeft"
|
||||
trigger={['click']}
|
||||
overlayClassName="platform-switcher-dropdown"
|
||||
>
|
||||
<div className={`platform-switcher ${isMaritime ? 'platform-switcher--ocean' : ''} ${className || ''}`}>
|
||||
<Space>
|
||||
<span className={`platform-switcher__icon platform-switcher__icon--${currentPlatform.theme}`}>
|
||||
{currentPlatform.icon}
|
||||
</span>
|
||||
<span className="platform-switcher__label">{currentPlatform.label}</span>
|
||||
<SwapOutlined className="platform-switcher__arrow" />
|
||||
</Space>
|
||||
</div>
|
||||
</Dropdown>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlatformSwitcher;
|
||||
Reference in New Issue
Block a user