自适应完成

This commit is contained in:
mmc
2026-05-14 12:44:18 +08:00
parent d7808a38e1
commit 5e397698d2
7 changed files with 1793 additions and 1409 deletions

View File

@@ -13,6 +13,8 @@ import {
message,
Typography,
Space,
TimePicker,
Divider,
} from 'antd';
import {
CloudOutlined,
@@ -25,131 +27,150 @@ import {
FileTextOutlined,
DeleteOutlined,
RestOutlined,
SettingOutlined,
UserOutlined,
NotificationOutlined,
ApiOutlined,
SafetyCertificateOutlined,
ToolOutlined,
RightOutlined,
} from '@ant-design/icons';
import {
Smartphone,
Mail,
Send,
MessageSquare,
ShieldCheck,
Users,
LineChart,
Wrench,
Cpu,
Camera,
Wind,
Box,
Activity,
Zap,
RefreshCw,
Shield,
Key,
Lock,
} from 'lucide-react';
import dayjs from 'dayjs';
const { Text } = Typography;
const { Text, Title } = Typography;
const BasicSettings = () => {
const [form] = Form.useForm();
// 响应式字体大小
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
const fontSmall = 'clamp(11px, 0.7vw, 12px)';
const fontTitle = 'clamp(14px, 0.85vw, 16px)';
const fontLarge = 'clamp(18px, 1.1vw, 22px)';
const handleSave = () => {
message.success('设置已保存');
};
// 设备接入状态数据
const deviceStatusData = [
{ name: '逆变器', count: '5/5', status: '正常', color: '#52c41a' },
{ name: '汇流箱', count: '20/20', status: '正常', color: '#52c41a' },
{ name: '摄像头', count: '12/12', status: '正常', color: '#52c41a' },
{ name: '无人机', count: '2/2', status: '正常', color: '#52c41a' },
{ name: 'API接口', count: '正常', status: '正常', color: '#52c41a' },
{ name: 'Modbus', count: '正常', status: '正常', color: '#52c41a' },
];
// 服务配置数据
const serviceConfigData = [
{ name: 'MQTT配置', value: 'tcp://localhost:1883', status: '离线', statusColor: '#8c8c8c' },
{ name: '视频服务配置', value: '待接入 RTSP / WebRTC 服务', status: '待处理', statusColor: '#fa8c16' },
{ name: 'AI服务配置', value: 'http://ai-service.local', status: '待处理', statusColor: '#fa8c16' },
{ name: 'API密钥管理', value: '正常', status: '正常', statusColor: '#52c41a' },
];
// 视频服务配置数据
const videoServiceData = [
{ name: '视频服务数', value: '1' },
{ name: '启用服务数', value: '1' },
{ name: '摄像头总数', value: '3' },
{ name: '离线摄像头', value: '3' },
{ name: '在线流数量', value: '0' },
{ name: '服务状态', value: 'ONLINE', statusColor: '#52c41a' },
{ name: 'API地址', value: 'http://127.0.0.1:9997' },
{ name: 'HLS地址', value: 'http://127.0.0.1:8888' },
{ name: 'WebRTC地址', value: 'http://127.0.0.1:8889' },
{ name: '检测结果', value: 'HTTP 401 - http://127.0.0.1...' },
];
// MQTT接入状态数据
const mqttStatusData = [
{ name: '启用状态', value: '已启用', statusColor: '#52c41a' },
{ name: '连接状态', value: '已连接', statusColor: '#52c41a' },
{ name: 'Broker', value: 'tcp://localhost:1883' },
{ name: '客户端ID', value: 'solar-platform-backend' },
{ name: '遥测主题', value: 'pv/+/device/+/telemetry' },
{ name: '状态主题', value: 'pv/+/device/+/status' },
{ name: '最近连接', value: '2026-05-07 18:30:40' },
{ name: '最近错误', value: '-' },
];
// MQTT消息日志数据
const mqttLogData = [
{ topic: 'pv/1/device/ROBOT-01/ack', device: 'ROBOT-01', type: 'ACK', parse: 'SUCCESS' },
{ topic: 'pv/1/device/ROBOT-01/ack', device: 'ROBOT-01', type: 'ACK', parse: 'SUCCESS' },
{ topic: 'pv/1/device/CAM-02/status', device: 'CAM-02', type: 'STATUS', parse: 'SUCCESS' },
{ topic: 'pv/1/device/INV-A02/telemetry', device: 'INV-A02', type: 'TELEMETRY', parse: 'SUCCESS' },
];
// WebSocket状态数据
const wsStatusData = [
{ name: '服务状态', value: '已启用', statusColor: '#52c41a' },
{ name: '前端连接', value: '已连接', statusColor: '#52c41a' },
{ name: 'Endpoint', value: '/ws/pv' },
{ name: '在线连接数', value: '2' },
{ name: '最近推送', value: '-' },
{ name: '推送时间', value: '-' },
{ name: '前端端点', value: 'ws://47.100.102.7:10469/de...' },
{ name: '最近错误', value: '-' },
];
// 顶部卡片数据
// 顶部统计卡片数据
const topCards = [
{
title: '当前版本',
value: 'v2.8.1',
tag: '最新版',
tagColor: 'blue',
icon: <CloudOutlined />,
color: '#1677ff',
bg: '#e6f4ff'
icon: <Cpu size={24} color="#1677ff" />,
bg: 'linear-gradient(135deg, #e6f4ff 0%, #bae0ff 100%)'
},
{
title: '在线用户',
value: '12',
trend: '↑ 2',
trendColor: '#52c41a',
icon: <TeamOutlined />,
color: '#52c41a',
bg: '#f6ffed'
icon: <Users size={24} color="#52c41a" />,
bg: 'linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%)'
},
{
title: '告警通道',
value: '3 / 4',
trend: '正常',
trendColor: '#52c41a',
icon: <BellOutlined />,
color: '#ff4d4f',
bg: '#fff2f0'
icon: <BellOutlined style={{ fontSize: 24, color: '#ff4d4f' }} />,
bg: 'linear-gradient(135deg, #fff2f0 0%, #ffccc7 100%)'
},
{
title: '数据备份状态',
value: '正常',
trend: '●',
trendColor: '#52c41a',
icon: <DatabaseOutlined />,
color: '#13c2c2',
bg: '#e6fffb'
icon: <DatabaseOutlined style={{ fontSize: 24, color: '#13c2c2' }} />,
bg: 'linear-gradient(135deg, #e6fffb 0%, #b5f5ec 100%)'
},
{
title: '最近更新',
value: '2025-05-20',
icon: <CalendarOutlined />,
color: '#722ed1',
bg: '#f9f0ff'
icon: <CalendarOutlined style={{ fontSize: 24, color: '#722ed1' }} />,
bg: 'linear-gradient(135deg, #f9f0ff 0%, #efdbff 100%)'
},
];
return (
<div style={{ padding: 24, background: '#f0f2f5', minHeight: '100vh' }}>
// 角色权限概览
const roleOverview = [
{
title: '超级管理员',
users: 2,
perms: 28,
tags: ['全部权限', '系统管理'],
color: '#1677ff',
bg: '#e6f4ff',
icon: <ShieldCheck size={20} color="#1677ff" />
},
{
title: '运维工程师',
users: 5,
perms: 18,
tags: ['设备管理', '工单管理'],
color: '#52c41a',
bg: '#f6ffed',
icon: <Wrench size={20} color="#52c41a" />
},
{
title: '巡检主管',
users: 8,
perms: 12,
tags: ['巡检管理', '告警处理'],
color: '#fa8c16',
bg: '#fff7e6',
icon: <Users size={20} color="#fa8c16" />
},
{
title: '数据分析师',
users: 3,
perms: 15,
tags: ['数据分析', '报表查看'],
color: '#722ed1',
bg: '#f9f0ff',
icon: <LineChart size={20} color="#722ed1" />
},
];
{/* 顶部卡片 —— 统一风格 + 自动换行 + 圆角8px */}
// 设备状态
const deviceStatuses = [
{ name: '逆变器', count: '5/5', status: '正常' },
{ name: '汇流箱', count: '20/20', status: '正常' },
{ name: '气象站', count: '1/1', status: '正常' },
{ name: '摄像头', count: '12/12', status: '正常' },
{ name: '无人机', count: '2/2', status: '正常' },
{ name: '机器人', count: '5/5', status: '正常' },
{ name: 'API接口', count: '正常', status: '正常' },
{ name: 'Modbus', count: '正常', status: '正常' },
];
return (
<div style={{ padding: 'clamp(12px, 1.5vw, 24px)', background: '#f5f7fa', minHeight: '100vh' }}>
{/* 顶部统计卡片 */}
<Row gutter={[16, 16]} style={{ marginBottom: 24, flexWrap: 'wrap' }}>
{topCards.map((item, idx) => (
<Col key={idx} style={{ minWidth: '160px', flex: '1 0 auto' }}>
@@ -181,224 +202,347 @@ const BasicSettings = () => {
</Row>
<Row gutter={16}>
{/* 左侧主内容 */}
<Col span={16}>
{/* 平台参数 */}
<AntdCard title="平台参数" style={{ marginBottom: 16, borderRadius: 8 }}>
{/* 左侧 */}
<Col xs={24} xl={17}>
{/* 基础配置 */}
<AntdCard
title={<Space><SettingOutlined style={{ color: '#1677ff' }} /><b>基础配置</b></Space>}
bordered={false}
style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
>
<Form form={form} layout="vertical">
<Row gutter={16}>
<Col span={12}>
<Row gutter={24}>
<Col xs={24} sm={12} md={8}>
<Form.Item label="系统名称" name="systemName">
<Input defaultValue="光伏场站智能监控与运维系统" />
<Input defaultValue="光伏电站智能监控与运维系统" />
</Form.Item>
</Col>
<Col span={12}>
<Col xs={24} sm={12} md={8}>
<Form.Item label="默认电站" name="defaultSite">
<Select defaultValue="1MW 光伏电站">
<Select.Option value="1MW">1MW 光伏电站</Select.Option>
</Select>
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={12}>
<Col xs={24} sm={12} md={8}>
<Form.Item label="默认语言" name="defaultLang">
<Select defaultValue="zh">
<Select.Option value="zh">中文</Select.Option>
<Select.Option value="en">English</Select.Option>
</Select>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label="时区" name="timezone">
<Select defaultValue="UTC+08:00">
<Select.Option value="8">UTC+08:00</Select.Option>
</Select>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label="首页默认页面" name="defaultPage">
<Select defaultValue="dashboard">
<Select.Option value="dashboard">总览首页</Select.Option>
</Select>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label="数据刷新频率" name="refreshRate">
<Select defaultValue="5分钟">
<Select.Option value="5">5分钟</Select.Option>
<Select defaultValue="5min">
<Select.Option value="5min">5 分钟</Select.Option>
</Select>
</Form.Item>
</Col>
<Col span={12}>
<Col xs={24} sm={12} md={8}>
<Form.Item label="地图服务" name="mapService">
<Select defaultValue="高德地图">
<Select.Option value="amap">高德地图</Select.Option>
<Select defaultValue="gaode">
<Select.Option value="gaode">高德地图</Select.Option>
</Select>
</Form.Item>
</Col>
<Col xs={24} md={16}>
<div style={{ display: 'flex', gap: 'clamp(8px, 1vw, 24px)', marginTop: 8, flexWrap: 'wrap' }}>
<Space>
<span style={{ fontSize: fontNormal }}>工单自动编号</span>
<Switch defaultChecked />
</Space>
<Space>
<span style={{ fontSize: fontNormal }}>AI建议自动生成</span>
<Switch defaultChecked />
</Space>
<Space>
<span style={{ fontSize: fontNormal }}>移动端同步</span>
<Switch defaultChecked />
</Space>
</div>
</Col>
</Row>
<Form.Item label="AI建议自动生成" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
<div style={{ marginTop: 16 }}>
<Button type="primary" onClick={handleSave} style={{ width: 120, borderRadius: 6, height: 36 }}>保存设置</Button>
<Button style={{ marginLeft: 12, borderRadius: 6, height: 36 }}>恢复默认</Button>
</div>
</Form>
</AntdCard>
{/* 通知与告警策略 */}
<AntdCard title="通知与告警策略" style={{ marginBottom: 16, borderRadius: 8 }}>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>短信</Text>
<Switch defaultChecked />
</div>
</Col>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>邮件</Text>
<Switch defaultChecked />
</div>
</Col>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>企业微信</Text>
<Switch defaultChecked />
</div>
</Col>
<AntdCard
title={<Space><BellOutlined style={{ color: '#1677ff' }} /><b>通知与告警策略</b></Space>}
bordered={false}
style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
>
<Row gutter={[16, 16]} style={{ marginBottom: 24 }}>
{[
{ label: '短信', icon: <Smartphone size={18} />, color: '#52c41a', status: '已启用' },
{ label: '邮件', icon: <Mail size={18} />, color: '#1677ff', status: '已启用' },
{ label: 'Telegram', icon: <Send size={18} />, color: '#13c2c2', status: '已启用' },
{ label: '系统通知', icon: <BellOutlined />, color: '#fa8c16', status: '已启用' },
].map((item, idx) => (
<Col xs={24} sm={12} lg={6} key={idx}>
<div style={{ display: 'flex', alignItems: 'center', padding: '12px 16px', background: '#f8fafc', borderRadius: 10, border: '1px solid #f1f5f9' }}>
<div style={{ width: 36, height: 36, borderRadius: '50%', background: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 2px 4px rgba(0,0,0,0.05)', marginRight: 12 }}>
{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: fontSmall, color: '#8c8c8c' }}>{item.label}</div>
<div style={{ fontSize: fontSmall, color: '#52c41a' }}>{item.status}</div>
</div>
<Switch size="small" defaultChecked />
</div>
</Col>
))}
</Row>
<Row gutter={16}>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>系统通知</Text>
<Switch defaultChecked />
</div>
</Col>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>严重告警立即通知</Text>
<Switch defaultChecked />
</div>
</Col>
<Col span={8}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', border: '1px solid #e8e8e8', borderRadius: 8 }}>
<Text strong>通信中断通知</Text>
<Switch defaultChecked />
</div>
<Row gutter={[32, 16]}>
<Col xs={24} sm={12} md={8}><Space><span>严重告警立即通知</span><Switch size="small" defaultChecked /></Space></Col>
<Col xs={24} sm={12} md={8}><Space><span>发电下降超过 15%</span><Switch size="small" defaultChecked /></Space></Col>
<Col xs={24} sm={12} md={8}><Space><span>通信中断通知</span><Switch size="small" defaultChecked /></Space></Col>
<Col xs={24} sm={12} md={8}><Space><span>每日汇总推送</span><Switch size="small" defaultChecked /></Space></Col>
<Col xs={24} md={16}>
<Space size="middle" style={{ flexWrap: 'wrap' }}>
<span>夜间免打扰</span>
<TimePicker.RangePicker size="small" defaultValue={[dayjs('23:00', 'HH:mm'), dayjs('07:00', 'HH:mm')]} format="HH:mm" />
<Switch size="small" />
</Space>
</Col>
</Row>
</AntdCard>
{/* 用户与权限预览 */}
<AntdCard title="用户与权限预览" style={{ marginBottom: 16, borderRadius: 8 }}>
<AntdCard
title={<Space><Users size={18} style={{ color: '#1677ff' }} /><b>用户与权限预览</b></Space>}
bordered={false}
style={{ borderRadius: 12, boxShadow: '0 2px 8px rgba(0,0,0,0.05)', marginBottom: 16 }}
>
<Table
size="small"
pagination={false}
scroll={{ x: 'max-content' }}
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
columns={[
{ title: '用户名', dataIndex: 'name' },
{ title: '角色', dataIndex: 'role' },
{ title: '手机号', dataIndex: 'phone' },
{ title: '状态', dataIndex: 'status', render: (text) => <span style={{ color: '#52c41a' }}>{text}</span> },
{ title: '用户名', dataIndex: 'name', key: 'name', fixed: 'left' },
{
title: '角色',
dataIndex: 'role',
key: 'role',
render: (role) => {
const config: any = {
'超级管理员': { color: '#1677ff', bg: '#e6f4ff' },
'运维工程师': { color: '#52c41a', bg: '#f6ffed' },
'巡检主管': { color: '#fa8c16', bg: '#fff7e6' },
'数据分析师': { color: '#722ed1', bg: '#f9f0ff' },
};
const s = config[role] || { color: '#8c8c8c', bg: '#f5f5f5' };
return <Tag bordered={false} style={{ color: s.color, background: s.bg, fontSize: fontSmall }}>{role}</Tag>;
}
},
{ title: '手机号', dataIndex: 'phone', key: 'phone' },
{ title: '邮箱', dataIndex: 'email', key: 'email' },
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: (status) => (
<Space size={4}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: status === '在线' ? '#52c41a' : '#bfbfbf' }} />
<span style={{ fontSize: fontSmall }}>{status}</span>
</Space>
)
},
{ title: '操作', key: 'action', render: () => <Button type="link" size="small">查看</Button>, fixed: 'right' },
]}
dataSource={[
{ name: '张运维', role: '超级管理员', phone: '138****0001', status: '在线' },
{ name: '李工程师', role: '运维工程师', phone: '139****0002', status: '在线' },
{ name: '王班长', role: '巡检主管', phone: '137****0003', status: '在线' },
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', status: '在线' },
{ name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsmart.com', status: '在线' },
{ name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsmart.com', status: '在线' },
{ name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsmart.com', status: '在线' },
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsmart.com', status: '在线' },
]}
/>
</AntdCard>
{/* MQTT接入状态 */}
<AntdCard title="MQTT接入状态" style={{ marginBottom: 16, borderRadius: 8 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 16 }}>来自 /pv/mqtt/status,后端未登录时显示预览兜底数据</div>
<Row gutter={16}>
{mqttStatusData.map((item, index) => (
<Col span={12} key={index}>
<div style={{ border: '1px solid #e8e8e8', borderRadius: 8, padding: 12, marginBottom: 16 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 4 }}>{item.name}</div>
<div style={{ fontSize: 16, fontWeight: 600, color: item.statusColor || '#333' }}>{item.value}</div>
</div>
</Col>
))}
</Row>
</AntdCard>
{/* MQTT消息日志 */}
<AntdCard title="MQTT消息日志" style={{ marginBottom: 16, borderRadius: 8 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 16 }}>阶段3A用于验证遥测原始消息落库</div>
<Table
size="small"
pagination={false}
columns={[
{ title: 'Topic', dataIndex: 'topic' },
{ title: '设备', dataIndex: 'device' },
{ title: '类型', dataIndex: 'type' },
{ title: '解析', dataIndex: 'parse' },
]}
dataSource={mqttLogData}
/>
</AntdCard>
<AntdCard title="系统维护" style={{ marginBottom: 0, borderRadius: 8 }}>
<Row gutter={16}>
<Col span={12} style={{ marginBottom: 16 }}>
<Button style={{ width: '100%' }} icon={<DeleteOutlined />}>清理缓存</Button>
</Col>
<Col span={12} style={{ marginBottom: 16 }}>
<Button style={{ width: '100%' }} icon={<RestOutlined />}>重启服务</Button>
</Col>
<Col span={12}>
<Button style={{ width: '100%' }} icon={<DownloadOutlined />}>备份下载</Button>
</Col>
<Col span={12}>
<Button style={{ width: '100%' }} icon={<FileTextOutlined />}>日志导出</Button>
</Col>
</Row>
</AntdCard>
</Col>
{/* 右侧边栏 */}
<Col span={8}>
{/* 右侧 */}
<Col xs={24} xl={7}>
{/* 角色权限概览 */}
<AntdCard
title={<Space><Users size={18} style={{ color: '#1677ff' }} /><b>角色权限概览</b></Space>}
bordered={false}
style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
bodyStyle={{ padding: '12px' }}
>
<Row gutter={[12, 12]}>
{roleOverview.map((role, idx) => (
<Col xs={24} sm={12} key={idx}>
<div style={{ background: role.bg, borderRadius: 10, padding: 10, height: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
{role.icon}
<RightOutlined style={{ fontSize: 10, color: role.color }} />
</div>
<div style={{ fontWeight: 600, fontSize: fontSmall, color: role.color, marginBottom: 4 }}>{role.title}</div>
<div style={{ fontSize: 10, color: '#8c8c8c', marginBottom: 8 }}>
用户 {role.users} 人 | 权限 {role.perms} 项
</div>
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
{role.tags.map((tag, tidx) => (
<span key={tidx} style={{ fontSize: 9, padding: '1px 4px', background: '#fff', color: role.color, borderRadius: 2, border: `1px solid ${role.color}40` }}>{tag}</span>
))}
</div>
</div>
</Col>
))}
</Row>
</AntdCard>
{/* 设备接入状态 */}
<AntdCard title="设备接入状态" style={{ marginBottom: 16, borderRadius: 8 }}>
<Row gutter={16}>
{deviceStatusData.map((item, index) => (
<Col span={12} key={index}>
<div style={{ border: '1px solid #e8e8e8', borderRadius: 8, padding: 12, marginBottom: 16 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 4 }}>{item.name}</div>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 4 }}>{item.count}</div>
<div style={{ color: item.color, fontSize: 13 }}>{item.status}</div>
<AntdCard
title={<Space><ApiOutlined style={{ color: '#1677ff' }} /><b>设备接入状态</b></Space>}
extra={<Button type="link" size="small">查看详情 <RightOutlined /></Button>}
bordered={false}
style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
bodyStyle={{ padding: '16px' }}
>
<div style={{ display: 'flex', gap: 20 }}>
<div style={{ flex: '0 0 100px' }}>
{deviceStatuses.map((item, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 6 }}>
<Space size={4}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: '#52c41a' }} />
<span style={{ fontSize: 11, color: '#595959' }}>{item.name}</span>
</Space>
<span style={{ fontSize: 11, fontWeight: 500 }}>{item.count}</span>
</div>
</Col>
))}
</Row>
</AntdCard>
{/* 服务配置展示 */}
<AntdCard title="服务配置展示" style={{ marginBottom: 16, borderRadius: 8 }}>
{serviceConfigData.map((item, index) => (
<div key={index} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 0', borderBottom: index !== serviceConfigData.length - 1 ? '1px solid #e8e8e8' : 'none' }}>
<div>
<div style={{ fontWeight: 500, marginBottom: 4 }}>{item.name}</div>
<div style={{ fontSize: 13 }}>{item.value}</div>
</div>
<Tag color={item.statusColor === '#52c41a' ? 'success' : item.statusColor === '#fa8c16' ? 'warning' : 'default'}>{item.status}</Tag>
))}
</div>
))}
<div style={{ flex: 1, position: 'relative', height: 160, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(22, 119, 255, 0.02)', borderRadius: 12 }}>
{/* SVG 拓扑图:使用百分比和 viewBox 保证缩放比一致性 */}
<svg width="100%" height="100%" viewBox="0 0 200 160" style={{ maxWidth: 240 }}>
<defs>
<filter id="glow" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur stdDeviation="3" result="blur" />
<feComposite in="SourceGraphic" in2="blur" operator="over" />
</filter>
</defs>
{/* 动态连线 */}
<g stroke="#1677ff40" strokeWidth="1" strokeDasharray="4 2">
<line x1="100" y1="80" x2="60" y2="40" />
<line x1="100" y1="80" x2="140" y2="40" />
<line x1="100" y1="80" x2="160" y2="80" />
<line x1="100" y1="80" x2="140" y2="120" />
<line x1="100" y1="80" x2="60" y2="120" />
<line x1="100" y1="80" x2="40" y2="80" />
</g>
{/* 中心核心节点 */}
<circle cx="100" cy="80" r="18" fill="#1677ff" filter="url(#glow)" />
<rect x="91" y="71" width="18" height="18" rx="3" fill="none" stroke="#fff" strokeWidth="1.5" />
<path d="M95 75h10M95 80h10M95 85h10" stroke="#fff" strokeWidth="1.2" />
{/* 周边子节点 */}
{[
{ x: 60, y: 40, icon: <Cpu size={12} />, label: '逆变器' },
{ x: 140, y: 40, icon: <Box size={12} />, label: '汇流箱' },
{ x: 160, y: 80, icon: <Wind size={12} />, label: '气象站' },
{ x: 140, y: 120, icon: <Camera size={12} />, label: '摄像头' },
{ x: 60, y: 120, icon: <Activity size={12} />, label: '机器人' },
{ x: 40, y: 80, icon: <Zap size={12} />, label: '接口' },
].map((node, i) => (
<g key={i}>
<circle cx={node.x} cy={node.y} r="12" fill="#fff" stroke="#e8e8e8" strokeWidth="1" />
<foreignObject x={node.x - 6} y={node.y - 6} width="12" height="12">
<div style={{ color: '#1677ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{node.icon}</div>
</foreignObject>
<text x={node.x} y={node.y + 20} textAnchor="middle" style={{ fontSize: 8, fill: '#8c8c8c' }}>{node.label}</text>
</g>
))}
</svg>
</div>
</div>
</AntdCard>
{/* 视频服务配置状态 */}
<AntdCard title="视频服务配置状态" style={{ marginBottom: 16, borderRadius: 8 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 16 }}>来自 /pv/video/summary 与 /pv/video/media-server/list</div>
<Row gutter={16}>
{videoServiceData.map((item, index) => (
<Col span={12} key={index}>
<div style={{ border: '1px solid #e8e8e8', borderRadius: 8, padding: 12, marginBottom: 16 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 4 }}>{item.name}</div>
<div style={{ fontSize: 16, fontWeight: 600, color: item.statusColor || '#333' }}>{item.value}</div>
{/* 数据与安全 */}
<AntdCard
title={<Space><Shield size={18} style={{ color: '#1677ff' }} /><b>数据与安全</b></Space>}
bordered={false}
style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
bodyStyle={{ padding: '16px' }}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(140px, 1fr))', gap: '16px 24px' }}>
{[
{ label: '数据保留', value: '3 年', icon: <DatabaseOutlined style={{ color: '#1677ff' }} /> },
{ label: '登录审计', value: '已开启', icon: <CheckCircleOutlined style={{ color: '#52c41a' }} />, color: '#52c41a' },
{ label: '每日自动备份', value: '02:00', icon: <RefreshCw size={14} color="#1677ff" /> },
{ label: 'API 密钥管理', value: '正常', icon: <Key size={14} color="#52c41a" />, color: '#52c41a' },
{ label: '最近备份时间', value: '2025-05-24 02:00', icon: <CalendarOutlined style={{ color: '#1677ff' }} />, isFull: true },
{ label: 'SSL 证书', value: '有效期至 2026-12-31', icon: <SafetyCertificateOutlined style={{ color: '#fa8c16' }} />, isFull: true },
{ label: '双因素认证', value: '已开启', icon: <Lock size={14} color="#52c41a" />, color: '#52c41a' },
].map((item, idx) => (
<div key={idx} style={{ gridColumn: item.isFull ? '1 / -1' : 'auto', display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ width: 24, height: 24, borderRadius: 6, background: '#f8fafc', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{item.icon}
</div>
</Col>
<div style={{ flex: 1 }}>
<div style={{ fontSize: fontSmall, color: '#8c8c8c' }}>{item.label}</div>
<div style={{ fontSize: fontNormal, fontWeight: 500, color: item.color || '#262626' }}>{item.value}</div>
</div>
</div>
))}
</Row>
<Button type="primary" style={{ width: '100%' }} onClick={() => message.info('检测视频服务')}>检测视频服务</Button>
</div>
</AntdCard>
{/* WebSocket实时推送 */}
<AntdCard title="WebSocket实时推送" style={{ marginBottom: 16, borderRadius: 8 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 16 }}>来自 /pv/ws/status,并显示前端本地连接状态</div>
<Row gutter={16}>
{wsStatusData.map((item, index) => (
<Col span={12} key={index}>
<div style={{ border: '1px solid #e8e8e8', borderRadius: 8, padding: 12, marginBottom: 16 }}>
<div style={{ fontSize: 13, color: '#666', marginBottom: 4 }}>{item.name}</div>
<div style={{ fontSize: 16, fontWeight: 600, color: item.statusColor || '#333' }}>{item.value}</div>
</div>
{/* 系统维护 */}
<AntdCard
title={<Space><Wrench size={18} style={{ color: '#1677ff' }} /><b>系统维护</b></Space>}
extra={<Button type="link" size="small" danger style={{ fontSize: fontSmall }}>操作需管理员权限</Button>}
bordered={false}
style={{ borderRadius: 12, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}
bodyStyle={{ padding: '16px' }}
>
<Row gutter={[12, 12]}>
{[
{ label: '清理缓存', icon: <DeleteOutlined />, color: '#1677ff' },
{ label: '重启服务', icon: <RefreshCw size={20} />, color: '#1677ff' },
{ label: '备份下载', icon: <DownloadOutlined />, color: '#1677ff' },
{ label: '日志导出', icon: <FileTextOutlined />, color: '#1677ff' },
].map((btn, idx) => (
<Col xs={12} sm={6} key={idx}>
<Button
style={{
width: '100%',
height: 'clamp(56px, 5vw, 64px)',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
gap: 4,
border: '1px solid #f0f0f0',
background: '#fff',
padding: '4px'
}}
>
<div style={{ color: btn.color, fontSize: 'clamp(16px, 1.2vw, 20px)' }}>{btn.icon}</div>
<div style={{ fontSize: fontSmall, color: '#595959' }}>{btn.label}</div>
</Button>
</Col>
))}
</Row>
</AntdCard>
</Col>
</Row>
</div>
@@ -406,3 +550,4 @@ const BasicSettings = () => {
};
export default BasicSettings;