卡片的自适应修改

This commit is contained in:
mmc
2026-05-14 09:37:15 +08:00
parent c0e8a1cd3e
commit 2ae097eed0
10 changed files with 874 additions and 790 deletions

View File

@@ -13,7 +13,6 @@ import {
message,
Typography,
Space,
Modal,
} from 'antd';
import {
CloudOutlined,
@@ -22,7 +21,6 @@ import {
DatabaseOutlined,
CalendarOutlined,
CheckCircleOutlined,
SyncOutlined,
DownloadOutlined,
FileTextOutlined,
DeleteOutlined,
@@ -101,305 +99,306 @@ const BasicSettings = () => {
{ name: '最近错误', value: '-' },
];
// 顶部卡片数据
const topCards = [
{
title: '当前版本',
value: 'v2.8.1',
tag: '最新版',
tagColor: 'blue',
icon: <CloudOutlined />,
color: '#1677ff',
bg: '#e6f4ff'
},
{
title: '在线用户',
value: '12',
trend: '↑ 2',
trendColor: '#52c41a',
icon: <TeamOutlined />,
color: '#52c41a',
bg: '#f6ffed'
},
{
title: '告警通道',
value: '3 / 4',
trend: '正常',
trendColor: '#52c41a',
icon: <BellOutlined />,
color: '#ff4d4f',
bg: '#fff2f0'
},
{
title: '数据备份状态',
value: '正常',
trend: '●',
trendColor: '#52c41a',
icon: <DatabaseOutlined />,
color: '#13c2c2',
bg: '#e6fffb'
},
{
title: '最近更新',
value: '2025-05-20',
icon: <CalendarOutlined />,
color: '#722ed1',
bg: '#f9f0ff'
},
];
return (
<div style={{ padding: 24, background: '#f0f2f5', minHeight: '100vh' }}>
{/* 顶部卡片 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#e6f4ff', borderRadius: 8, padding: 8 }}>
<CloudOutlined style={{ color: '#1677ff', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>当前版本</div>
<div style={{ fontWeight: 600 }}>v2.8.1 <Tag color="blue">最新版</Tag></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#f6ffed', borderRadius: 8, padding: 8 }}>
<TeamOutlined style={{ color: '#52c41a', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>在线用户</div>
<div style={{ fontWeight: 600 }}>12 <span style={{ color: '#52c41a', fontSize: 12 }}>↑ 2</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#fff2f0', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>告警通道</div>
<div style={{ fontWeight: 600 }}>3 / 4 <span style={{ color: '#52c41a', fontSize: 12 }}>正常</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#e6fffb', borderRadius: 8, padding: 8 }}>
<DatabaseOutlined style={{ color: '#13c2c2', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>数据备份状态</div>
<div style={{ fontWeight: 600 }}>正常 <span style={{ color: '#52c41a', fontSize: 12 }}>●</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={4}>
<AntdCard size="small">
<Space>
<div style={{ background: '#f9f0ff', borderRadius: 8, padding: 8 }}>
<CalendarOutlined style={{ color: '#722ed1', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>最近更新</div>
<div style={{ fontWeight: 600 }}>2025-05-20</div>
</div>
</Space>
</AntdCard>
</Col>
{/* 顶部卡片 —— 统一风格 + 自动换行 + 圆角8px */}
<Row gutter={[16, 16]} style={{ marginBottom: 24, flexWrap: 'wrap' }}>
{topCards.map((item, idx) => (
<Col key={idx} style={{ minWidth: '160px', flex: '1 0 auto' }}>
<AntdCard
size="small"
style={{ borderRadius: 8, width: '100%' }}
bodyStyle={{ padding: '12px' }}
>
<Space>
<div style={{ background: item.bg, borderRadius: 8, padding: 8 }}>
{item.icon}
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>{item.title}</div>
<div style={{ fontWeight: 600, display: 'flex', alignItems: 'center', gap: 6 }}>
{item.value}
{item.tag && <Tag color={item.tagColor} style={{ margin: 0 }}>{item.tag}</Tag>}
{item.trend && (
<span style={{ color: item.trendColor, fontSize: 12 }}>
{item.trend}
</span>
)}
</div>
</div>
</Space>
</AntdCard>
</Col>
))}
</Row>
<Row
gutter={16}
style={{
display: 'flex',
alignItems: 'stretch', // 关键:等高
}}
>
<Row gutter={16}>
{/* 左侧主内容 */}
<Col span={16} style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ flex: 1 }}>
{/* 平台参数 */}
<AntdCard title="平台参数" style={{ marginBottom: 16 }}>
<Form form={form} layout="vertical">
<Row gutter={16}>
<Col span={12}>
<Form.Item label="系统名称" name="systemName">
<Input defaultValue="光伏场站智能监控与运维系统" />
</Form.Item>
</Col>
<Col span={12}>
<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}>
<Form.Item label="数据刷新频率" name="refreshRate">
<Select defaultValue="5分钟">
<Select.Option value="5">5分钟</Select.Option>
</Select>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label="地图服务" name="mapService">
<Select defaultValue="高德地图">
<Select.Option value="amap">高德地图</Select.Option>
</Select>
</Form.Item>
</Col>
</Row>
<Form.Item label="AI建议自动生成" valuePropName="checked">
<Col span={16}>
{/* 平台参数 */}
<AntdCard title="平台参数" style={{ marginBottom: 16, borderRadius: 8 }}>
<Form form={form} layout="vertical">
<Row gutter={16}>
<Col span={12}>
<Form.Item label="系统名称" name="systemName">
<Input defaultValue="光伏场站智能监控与运维系统" />
</Form.Item>
</Col>
<Col span={12}>
<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}>
<Form.Item label="数据刷新频率" name="refreshRate">
<Select defaultValue="5分钟">
<Select.Option value="5">5分钟</Select.Option>
</Select>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label="地图服务" name="mapService">
<Select defaultValue="高德地图">
<Select.Option value="amap">高德地图</Select.Option>
</Select>
</Form.Item>
</Col>
</Row>
<Form.Item label="AI建议自动生成" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</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 />
</Form.Item>
</Form>
</AntdCard>
</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>
</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>
</Col>
</Row>
</AntdCard>
{/* 通知与告警策略 */}
<AntdCard title="通知与告警策略" style={{ marginBottom: 16 }}>
<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>
</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>
</Col>
</Row>
</AntdCard>
{/* 用户与权限预览 */}
<AntdCard title="用户与权限预览" style={{ marginBottom: 16, borderRadius: 8 }}>
<Table
size="small"
pagination={false}
columns={[
{ title: '用户名', dataIndex: 'name' },
{ title: '角色', dataIndex: 'role' },
{ title: '手机号', dataIndex: 'phone' },
{ title: '状态', dataIndex: 'status', render: (text) => <span style={{ color: '#52c41a' }}>{text}</span> },
]}
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: '在线' },
]}
/>
</AntdCard>
{/* 用户与权限预览 */}
<AntdCard title="用户与权限预览" style={{ marginBottom: 16 }}>
<Table
size="small"
pagination={false}
columns={[
{ title: '用户名', dataIndex: 'name' },
{ title: '角色', dataIndex: 'role' },
{ title: '手机号', dataIndex: 'phone' },
{ title: '状态', dataIndex: 'status', render: (text) => <span style={{ color: '#52c41a' }}>{text}</span> },
]}
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: '在线' },
]}
/>
</AntdCard>
{/* MQTT接入状态 */}
<AntdCard title="MQTT接入状态" style={{ marginBottom: 16 }}>
<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 }}>来自 /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>
{/* MQTT消息日志 */}
<AntdCard title="MQTT消息日志" style={{ marginBottom: 16 }}>
<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 }}>
<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>
</div>
</Col>
{/* 右侧边栏 */}
<Col span={8} style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ flex: 1 }}>
{/* 设备接入状态 */}
<AntdCard title="设备接入状态" style={{ marginBottom: 16 }}>
<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>
</div>
</Col>
))}
</Row>
</AntdCard>
<Col span={8}>
{/* 服务配置展示 */}
<AntdCard title="服务配置展示" style={{ marginBottom: 16 }}>
{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>
{/* 设备接入状态 */}
<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>
</div>
<Tag color={item.statusColor === '#52c41a' ? 'success' : item.statusColor === '#fa8c16' ? 'warning' : 'default'}>{item.status}</Tag>
</div>
</Col>
))}
</AntdCard>
</Row>
</AntdCard>
{/* 视频服务配置状态 */}
<AntdCard title="视频服务配置状态" style={{ marginBottom: 16 }}>
<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>
</div>
</Col>
))}
</Row>
<Button type="primary" style={{ width: '100%' }} onClick={() => message.info('检测视频服务')}>检测视频服务</Button>
</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>
))}
</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>
</div>
</Col>
))}
</Row>
<Button type="primary" style={{ width: '100%' }} onClick={() => message.info('检测视频服务')}>检测视频服务</Button>
</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>
</Col>
))}
</Row>
</AntdCard>
{/* WebSocket实时推送 */}
<AntdCard title="WebSocket实时推送" style={{ marginBottom: 16 }}>
<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>
</Col>
))}
</Row>
</AntdCard>
{/* 系统维护 */}
</div>
</Col>
</Row>
</div>