import React from 'react'; import { Card, Tag, Badge, Tooltip } from 'antd'; import { CloudServerOutlined, GatewayOutlined, DatabaseOutlined, AudioOutlined, QuestionOutlined, } from '@ant-design/icons'; import { designTokens } from '../config/theme'; const DEVICE_TYPE_CONFIG = { server: { icon: , color: designTokens.colors.device.server, label: '服务器', }, switch: { icon: , color: designTokens.colors.device.switch, label: '交换机', }, router: { icon: , color: designTokens.colors.device.router, label: '路由器', }, storage: { icon: , color: designTokens.colors.device.storage, label: '存储设备', }, other: { icon: , color: designTokens.colors.device.other, label: '其他设备', }, }; const STATUS_CONFIG = { running: { color: '#10b981', text: '运行中', bg: '#ecfdf5' }, maintenance: { color: '#3b82f6', text: '维护中', bg: '#eff6ff' }, offline: { color: '#6b7280', text: '离线', bg: '#f3f4f6' }, fault: { color: '#ef4444', text: '故障', bg: '#fef2f2' }, idle: { color: '#36cfc9', text: '空闲', bg: '#e6fffb' }, }; function ServerNicCard({ server, onManage }) { const typeConfig = DEVICE_TYPE_CONFIG[server.type] || DEVICE_TYPE_CONFIG.other; const statusConfig = STATUS_CONFIG[server.status] || STATUS_CONFIG.offline; const nicCount = server.nicCount || server.nics?.length || 0; const totalPortCount = server.nics?.reduce((sum, nic) => sum + (nic.portCount || 0), 0) || 0; return (
{typeConfig.icon}
{server.name}
ID: {server.deviceId}
{typeConfig.icon} {typeConfig.label} {statusConfig.text}
{nicCount}
网卡
{totalPortCount}
端口
0 ? 'success' : 'default'} text={ {server.nicCount > 0 ? '已配置' : '未配置'} } />
{ e.stopPropagation(); onManage(); }} > 管理 →
); } export default React.memo(ServerNicCard);