增加视频管理和日志管理

This commit is contained in:
mmc
2026-08-10 14:51:11 +08:00
parent 3cc738195f
commit 7d81362a88
14 changed files with 533 additions and 9 deletions

View File

@@ -169,6 +169,9 @@ const BasicSettings = () => {
return (
<div className="normal-spacing" style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>基础设置</Typography.Title>
</div>
{/* 顶部统计卡片 */}

View File

@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import {
Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber,
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox,
Typography,
} from 'antd';
import {
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
@@ -494,6 +495,9 @@ export default function DeviceAccessPage() {
return (
<div className="p-0 pt-[8px] bg-[#f5f7fa] min-h-screen">
{contextHolder}
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>设备接入</Typography.Title>
</div>
<Card className="mb-4">
<Tabs activeKey={activeTab} onChange={setActiveTab}>
<TabPane tab={<span><VideoCameraOutlined />设备管理</span>} key="device" />

View File

@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import {
Tabs,
Typography,
} from 'antd';
import SerialNumGenerate from "./SerialNumGenerate"
@@ -77,6 +78,9 @@ export default function DeviceManagementPage() {
return (
<div style={{ padding: "8px 0px", paddingTop: 0 }}>
<div style={{ padding: '0px 0px 4px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>设备管理</Typography.Title>
</div>
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
@@ -88,6 +92,7 @@ export default function DeviceManagementPage() {
<Tabs.TabPane key="camera" tab="摄像头管理" />
<Tabs.TabPane key="serialGenerate" tab="机器人生成" />
</Tabs>
{renderTabContent()}
</div >
);

View File

@@ -0,0 +1,155 @@
import React, { useState, useMemo } from 'react';
import {
Card as AntdCard, Table, Select, Input, Button, Tag, Space, Typography, Row, Col, DatePicker, message
} from 'antd';
import {
FileTextOutlined, SearchOutlined, ReloadOutlined, DownloadOutlined,
InfoCircleOutlined, WarningOutlined, ExclamationCircleOutlined, CheckCircleOutlined
} from '@ant-design/icons';
import dayjs from 'dayjs';
const { Title, Text } = Typography;
const { RangePicker } = DatePicker;
// ======================
// 日志管理(仅 admin 可见)
// 说明:当前为前端展示页,数据使用本地 mock。
// 接入真实数据时,可对接命令服务日志 GET /api/commands(设备控制流水)、
// 状态服务历史 GET /api/status/:deviceId/history,或后端 /system/operlog 操作日志接口。
// ======================
const MOCK_LOGS = [
{ id: 1, time: '2026-08-10 13:02:11', level: 'info', source: '系统', operator: '系统', message: '机器人智慧服务系统 Alpha 三服务(接入/状态/命令)启动完成' },
{ id: 2, time: '2026-08-10 12:58:40', level: 'action', source: '命令服务', operator: '张运维', message: '向 ROBOT-001 下发移动命令(seq=d6b5d545),执行结果:成功' },
{ id: 3, time: '2026-08-10 12:51:22', level: 'action', source: '用户管理', operator: '张运维', message: '新增运维工程师账号「李工」,角色:运维工程师' },
{ id: 4, time: '2026-08-10 12:40:05', level: 'warning', source: '设备接入', operator: '系统', message: 'DRONE-001 心跳超时(>60s),已自动置为离线' },
{ id: 5, time: '2026-08-10 12:33:18', level: 'error', source: '命令服务', operator: '系统', message: 'ROBOT-002 执行「自主巡检」超时,已自动重试 1 次后仍失败' },
{ id: 6, time: '2026-08-10 12:20:09', level: 'action', source: '系统设置', operator: '张运维', message: '修改系统名称与数据刷新频率(5min → 1min)' },
{ id: 7, time: '2026-08-10 11:55:44', level: 'info', source: '状态服务', operator: '系统', message: '设备 ROBOT-001 上报状态:电量 85%,模式 patrol' },
{ id: 8, time: '2026-08-10 11:30:02', level: 'warning', source: '告警中心', operator: '系统', message: '逆变器 INV-03 输出功率较昨日下降 16%,触发预警' },
{ id: 9, time: '2026-08-10 10:48:37', level: 'action', source: '视频管理', operator: '王班长', message: '调整 CAM-04 热成像通道码率参数' },
{ id: 10, time: '2026-08-10 10:12:15', level: 'info', source: '系统', operator: '系统', message: '每日自动备份完成,备份文件:backup-20260810-0200.tar' },
{ id: 11, time: '2026-08-10 09:40:50', level: 'error', source: '设备接入', operator: '系统', message: '未知设备尝试注册(secret 校验失败),已拒绝,来源 IP:10.0.12.45' },
{ id: 12, time: '2026-08-10 09:05:23', level: 'action', source: '角色管理', operator: '张运维', message: '为「数据分析师」角色授权「报表中心-导出」权限' },
];
const LEVEL_CONFIG: Record<string, { color: string; label: string; icon: React.ReactNode }> = {
info: { color: 'blue', label: '信息', icon: <InfoCircleOutlined /> },
action: { color: 'green', label: '操作', icon: <CheckCircleOutlined /> },
warning: { color: 'orange', label: '警告', icon: <WarningOutlined /> },
error: { color: 'red', label: '错误', icon: <ExclamationCircleOutlined /> },
};
const LogManagement = () => {
const [data, setData] = useState(MOCK_LOGS);
const [levelFilter, setLevelFilter] = useState<string>('all');
const [keyword, setKeyword] = useState('');
const [dateRange, setDateRange] = useState<[any, any] | null>(null);
const filtered = useMemo(() => {
return data.filter((log) => {
if (levelFilter !== 'all' && log.level !== levelFilter) return false;
if (keyword && !(log.message.includes(keyword) || log.operator.includes(keyword) || log.source.includes(keyword))) return false;
if (dateRange && dateRange[0] && dateRange[1]) {
const t = dayjs(log.time, 'YYYY-MM-DD HH:mm:ss');
if (t.isBefore(dateRange[0].startOf('day')) || t.isAfter(dateRange[1].endOf('day'))) return false;
}
return true;
});
}, [data, levelFilter, keyword, dateRange]);
const handleRefresh = () => {
setData(MOCK_LOGS);
setLevelFilter('all');
setKeyword('');
setDateRange(null);
message.success('日志已刷新');
};
const handleExport = () => {
const header = '时间,级别,来源,操作人,消息\n';
const rows = filtered.map((l) => `${l.time},${LEVEL_CONFIG[l.level].label},${l.source},${l.operator},"${l.message}"`).join('\n');
const blob = new Blob([header + rows], { type: 'text/csv;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `系统日志_${dayjs().format('YYYYMMDD_HHmmss')}.csv`;
a.click();
URL.revokeObjectURL(url);
message.success(`已导出 ${filtered.length} 条日志`);
};
const columns = [
{ title: '时间', dataIndex: 'time', key: 'time', width: 170, fixed: 'left' as const },
{
title: '级别', dataIndex: 'level', key: 'level', width: 80,
render: (lv: string) => {
const c = LEVEL_CONFIG[lv] || LEVEL_CONFIG.info;
return <Tag color={c.color} icon={c.icon} style={{ margin: 0 }}>{c.label}</Tag>;
},
},
{ title: '来源', dataIndex: 'source', key: 'source', width: 120 },
{ title: '操作人', dataIndex: 'operator', key: 'operator', width: 100 },
{ title: '消息', dataIndex: 'message', key: 'message', ellipsis: true },
];
return (
<div style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
<div style={{ marginBottom: 8 }}>
<Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.1vw, 18px)' }}>日志管理</Title>
<Text type="secondary" style={{ fontSize: 12 }}>系统运行、设备控制与管理员操作流水,仅超级管理员可查看</Text>
</div>
<AntdCard bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: 12 }}>
<Row gutter={[8, 8]} align="middle">
<Col xs={24} sm={8} md={5}>
<Select
size="small" style={{ width: '100%' }}
value={levelFilter}
onChange={setLevelFilter}
options={[
{ value: 'all', label: '全部级别' },
{ value: 'info', label: '信息' },
{ value: 'action', label: '操作' },
{ value: 'warning', label: '警告' },
{ value: 'error', label: '错误' },
]}
/>
</Col>
<Col xs={24} sm={10} md={8}>
<Input
size="small" allowClear placeholder="搜索消息 / 操作人 / 来源"
prefix={<SearchOutlined />} value={keyword} onChange={(e) => setKeyword(e.target.value)}
/>
</Col>
<Col xs={24} sm={14} md={8}>
<RangePicker
size="small" style={{ width: '100%' }}
showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm"
value={dateRange as any} onChange={(v) => setDateRange(v as any)}
/>
</Col>
<Col xs={24} sm={10} md={3}>
<Space>
<Button size="small" icon={<ReloadOutlined />} onClick={handleRefresh}>刷新</Button>
<Button size="small" type="primary" icon={<DownloadOutlined />} onClick={handleExport}>导出</Button>
</Space>
</Col>
</Row>
</AntdCard>
<AntdCard bordered={false} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: 4 }}>
<Table
size="small"
rowKey="id"
columns={columns}
dataSource={filtered}
scroll={{ x: 'max-content' }}
pagination={{ size: 'small', pageSize: 10, showTotal: (t) => `共 ${t} 条` }}
/>
</AntdCard>
</div>
);
};
export default LogManagement;

View File

@@ -1,7 +1,8 @@
import React, { useState, useEffect } from 'react';
import {
Table, Button, Space, Modal, Form, Tree, message,
Input, Popconfirm, Select, Card, InputNumber, Row, Col, Tooltip
Input, Popconfirm, Select, Card, InputNumber, Row, Col, Tooltip,
Typography
} from 'antd';
// 引入全部常用图标
import * as AllIcons from '@ant-design/icons';
@@ -186,7 +187,10 @@ export default function MenuList() {
return (
<div style={{ padding: '8px 0px' }}>
{contextHolder}
<Card title="菜单管理" style={{ borderRadius: 8 }}>
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>菜单管理</Typography.Title>
</div>
<Card style={{ borderRadius: 8 }}>
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
<Button type="primary" icon={<PlusOutlined />} onClick={() => {
setEditMenu(null);

View File

@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import {
Input, Button, Table, message, Space, Tabs, Card
Input, Button, Table, message, Space, Tabs, Card,
Typography
} from 'antd';
import { SearchOutlined, ReloadOutlined } from '@ant-design/icons';
@@ -87,6 +88,9 @@ const OnlineUserPage = () => {
return (
<div style={{ padding: "8px 0px", background: '#f5f7fa', minHeight: '100vh' }}>
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>系统监控</Typography.Title>
</div>
{/* ====================== 顶部 Tabs ====================== */}
<Tabs
activeKey={activeTab}

View File

@@ -150,8 +150,11 @@ export default function Organization() {
return (
<div style={{ padding: '8px 0px' }}>
{contextHolder}
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>组织管理</Typography.Title>
</div>
<AntdCard title="组织管理" style={{ borderRadius: 8 }}>
<AntdCard style={{ borderRadius: 8 }}>
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
新增组织

View File

@@ -1,7 +1,8 @@
import React, { useState, useEffect } from 'react';
import {
Card, Table, Button, Space, Modal, Form, Input, Popconfirm, Select,
Switch, Divider, Row, Col, Tag, message
Switch, Divider, Row, Col, Tag, message,
Typography
} from 'antd';
import {
PlusOutlined, EditOutlined, DeleteOutlined, BgColorsOutlined
@@ -271,8 +272,12 @@ export default function StationManage() {
return (
<div style={{ padding: '8px 0px' }}>
{contextHolder}
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>场站管理</Typography.Title>
</div>
<Card title="场站管理" style={{ borderRadius: 8 }}>
<Card style={{ borderRadius: 8 }}>
{!userInfo?.orgId && (
<div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
<Select

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Card, Tabs } from 'antd';
import { Card, Tabs, Typography } from 'antd';
import { ExclamationCircleOutlined, AlertOutlined, FormOutlined } from '@ant-design/icons';
import ErrorManagement from './ErrorManagement';
import AlarmSettingsManagement from './AlarmSettingsManagement';
@@ -28,6 +28,9 @@ export const SystemMaintenancePage = () => {
return (
<div className="p-0 pt-[8px] bg-[#f5f7fa] min-h-screen">
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>系统维护</Typography.Title>
</div>
<Card className="mb-4">
<Tabs activeKey={activeSubTab} onChange={handleTabChange}>
<TabPane tab={<span><ExclamationCircleOutlined />错误管理</span>} key="error" />

View File

@@ -398,6 +398,9 @@ export default function UserRolePage() {
background: '#f5f7fa'
}}>
{contextHolder}
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>用户与角色</Typography.Title>
</div>
<AntdCard style={{ borderRadius: 12, boxShadow: '0 2px 10px rgba(0,0,0,0.06)' }}>
<Tabs defaultActiveKey="user" type="card" size="large" style={{ marginBottom: 20 }}>
{/* 用户管理 */}

View File

@@ -0,0 +1,106 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Card as AntdCard, Tag, Button, Space, Typography, Row, Col, message
} from 'antd';
import {
VideoCameraOutlined, PlayCircleOutlined, HistoryOutlined, SettingOutlined,
CameraOutlined, EyeOutlined
} from '@ant-design/icons';
const { Title, Text } = Typography;
// ======================
// 视频管理(仅 admin 可见)
// 说明:当前为前端展示页,数据使用本地 mock 视频通道。
// 接入真实视频时,「实时预览」可跳转至监控页 /monitor(VideoMonitorPage),
// 或对接 WebRTC / 流媒体服务获取实时画面与回放地址。
// ======================
const MOCK_CHANNELS = [
{ id: 'CAM-01', name: '1区组件巡检摄像头', device: '巡检机器人-01', status: 'online', location: 'A排 1-12 组件', lastUpdate: '2026-08-10 12:58' },
{ id: 'CAM-02', name: '升压站全景摄像头', device: '固定球机', status: 'online', location: '升压站', lastUpdate: '2026-08-10 12:59' },
{ id: 'CAM-03', name: '无人机航拍通道', device: '无人机-01', status: 'offline', location: '全场', lastUpdate: '2026-08-09 18:20' },
{ id: 'CAM-04', name: '汇流箱热成像', device: '巡检机器人-02', status: 'online', location: 'B排汇流箱', lastUpdate: '2026-08-10 13:01' },
{ id: 'CAM-05', name: '逆变器舱监控', device: '固定枪机', status: 'online', location: '逆变器室', lastUpdate: '2026-08-10 13:00' },
{ id: 'CAM-06', name: '组件热斑巡检通道', device: '无人机-02', status: 'offline', location: 'C排组件', lastUpdate: '2026-08-09 17:45' },
];
const VideoManagement = () => {
const navigate = useNavigate();
const [channels] = useState(MOCK_CHANNELS);
const onlineCount = channels.filter((c) => c.status === 'online').length;
const handlePreview = (ch: any) => {
if (ch.status !== 'online') {
message.warning(`${ch.name} 当前离线,无法预览`);
return;
}
// 跳转至实时监控页,可携带通道信息
navigate('/monitor', { state: { channel: ch.id, name: ch.name } });
};
return (
<div style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
<div style={{ marginBottom: 8 }}>
<Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.1vw, 18px)' }}>视频管理</Title>
<Text type="secondary" style={{ fontSize: 12 }}>视频通道总览与预览管理,仅超级管理员可查看 · 在线 {onlineCount}/{channels.length}</Text>
</div>
<Row gutter={[8, 8]}>
{channels.map((ch) => {
const online = ch.status === 'online';
return (
<Col xs={24} sm={12} lg={8} xl={6} key={ch.id}>
<AntdCard
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)', overflow: 'hidden' }}
bodyStyle={{ padding: 12 }}
>
{/* 视频快照占位 */}
<div style={{
position: 'relative', height: 120, borderRadius: 8, marginBottom: 10,
background: online
? 'linear-gradient(135deg, #0b2545 0%, #134074 100%)'
: 'linear-gradient(135deg, #2b2b2b 0%, #4a4a4a 100%)',
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
<CameraOutlined style={{ fontSize: 36, color: online ? 'rgba(255,255,255,0.85)' : 'rgba(255,255,255,0.35)' }} />
<div style={{
position: 'absolute', top: 8, left: 8,
padding: '0 8px', borderRadius: 10, fontSize: 10,
background: online ? 'rgba(82,196,26,0.9)' : 'rgba(0,0,0,0.45)',
color: '#fff',
}}>
{online ? '● 在线' : '○ 离线'}
</div>
<div style={{
position: 'absolute', bottom: 8, right: 8,
padding: '0 8px', borderRadius: 10, fontSize: 10,
background: 'rgba(0,0,0,0.45)', color: '#fff',
}}>{ch.id}</div>
</div>
<div style={{ fontSize: 13, fontWeight: 600, color: '#262626', marginBottom: 4 }}>{ch.name}</div>
<Space size={4} style={{ fontSize: 11, color: '#8c8c8c', marginBottom: 8 }} wrap>
<VideoCameraOutlined />
<span>{ch.device}</span>
<Tag bordered={false} style={{ margin: 0, fontSize: 10 }} color={online ? 'green' : 'default'}>{ch.location}</Tag>
</Space>
<div style={{ display: 'flex', gap: 6, marginTop: 4 }}>
<Button size="small" type="primary" icon={<PlayCircleOutlined />} style={{ flex: 1 }} onClick={() => handlePreview(ch)}>预览</Button>
<Button size="small" icon={<HistoryOutlined />} disabled={!online} onClick={() => message.info(`${ch.name} 回放功能开发中`)}>回放</Button>
<Button size="small" icon={<SettingOutlined />} onClick={() => message.info(`${ch.name} 参数设置`)} />
</div>
</AntdCard>
</Col>
);
})}
</Row>
</div>
);
};
export default VideoManagement;