From 8f677fffeeca257dede89b25ca6fcf9a025ae9d7 Mon Sep 17 00:00:00 2001 From: aiotagro Date: Wed, 10 Sep 2025 21:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E6=9C=AC=E6=AC=A1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8F=98=E6=9B=B4=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E7=94=9F=E6=88=90=E6=9C=89=E6=95=88?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF=E3=80=82=E8=AF=B7?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E5=85=B7=E4=BD=93=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=86=85=E5=AE=B9=E4=BB=A5=E4=BE=BF=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=90=88=E9=80=82=E7=9A=84=E6=8F=90=E4=BA=A4=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-system/src/api/mockData.ts | 40 ++- admin-system/src/layouts/MainLayout.vue | 11 +- admin-system/src/pages/permission/index.vue | 60 +++- admin-system/src/pages/system/logs.vue | 330 ++++++++++++++++++++ admin-system/src/router/index.ts | 14 +- 5 files changed, 451 insertions(+), 4 deletions(-) create mode 100644 admin-system/src/pages/system/logs.vue diff --git a/admin-system/src/api/mockData.ts b/admin-system/src/api/mockData.ts index e4ff118..824da11 100644 --- a/admin-system/src/api/mockData.ts +++ b/admin-system/src/api/mockData.ts @@ -53,6 +53,18 @@ const mockPermissions = [ { id: 14, name: '系统写入', code: 'system:write', description: '创建/编辑系统信息', resource_type: 'system', created_at: '2024-01-01', updated_at: '2024-01-01' } ] +// 模拟系统日志数据 +const mockSystemLogs = [ + { id: '1', level: 'info', message: '用户登录成功 - admin', timestamp: '2024-03-15T14:30:22Z', module: 'auth', userId: '1', ip: '192.168.1.100' }, + { id: '2', level: 'info', message: '数据库备份完成 - 备份文件: backup_20240315.sql', timestamp: '2024-03-15T14:00:00Z', module: 'database', userId: '1', ip: '192.168.1.100' }, + { id: '3', level: 'warn', message: '系统警告 - 内存使用率超过80%', timestamp: '2024-03-15T13:45:18Z', module: 'system', userId: '1', ip: '192.168.1.100' }, + { id: '4', level: 'info', message: '定时任务执行 - 清理过期日志', timestamp: '2024-03-15T13:30:00Z', module: 'task', userId: '1', ip: '192.168.1.100' }, + { id: '5', level: 'error', message: '数据库连接失败 - 连接超时', timestamp: '2024-03-15T12:15:30Z', module: 'database', userId: '1', ip: '192.168.1.100' }, + { id: '6', level: 'info', message: '用户注册成功 - user123', timestamp: '2024-03-15T11:20:45Z', module: 'auth', userId: '2', ip: '192.168.1.101' }, + { id: '7', level: 'debug', message: 'API调用 - 获取用户列表', timestamp: '2024-03-15T10:30:15Z', module: 'api', userId: '1', ip: '192.168.1.100' }, + { id: '8', level: 'info', message: '订单创建成功 - 订单号: ORD20240315001', timestamp: '2024-03-15T09:45:22Z', module: 'order', userId: '3', ip: '192.168.1.102' } +] + // 模拟API响应格式 const createSuccessResponse = (data: any) => ({ success: true, @@ -175,7 +187,7 @@ export const mockOrderAPI = { } } -// 模拟系统统计API +// 模拟系统API export const mockSystemAPI = { getSystemStats: async () => { await delay(600) @@ -190,6 +202,32 @@ export const mockSystemAPI = { }) }, + getSystemLogs: async (params: any = {}) => { + await delay(800) + const { page = 1, limit = 10, level, module, startDate, endDate } = params + + // 根据查询参数过滤日志 + let filteredLogs = mockSystemLogs + if (level) { + filteredLogs = mockSystemLogs.filter(log => log.level === level) + } + if (module) { + filteredLogs = filteredLogs.filter(log => log.module === module) + } + if (startDate) { + filteredLogs = filteredLogs.filter(log => new Date(log.timestamp) >= new Date(startDate)) + } + if (endDate) { + filteredLogs = filteredLogs.filter(log => new Date(log.timestamp) <= new Date(endDate)) + } + + const start = (page - 1) * limit + const end = start + limit + const paginatedData = filteredLogs.slice(start, end) + + return createPaginatedResponse(paginatedData, page, limit, filteredLogs.length) + }, + getSystemMonitorData: async () => { await delay(500) return createSuccessResponse({ diff --git a/admin-system/src/layouts/MainLayout.vue b/admin-system/src/layouts/MainLayout.vue index 704e1e1..a0052b7 100644 --- a/admin-system/src/layouts/MainLayout.vue +++ b/admin-system/src/layouts/MainLayout.vue @@ -83,6 +83,14 @@ 系统设置 + + + + 系统日志 + + @@ -179,7 +187,8 @@ import { MenuFoldOutlined, BellOutlined, QuestionCircleOutlined, - LogoutOutlined + LogoutOutlined, + FileTextOutlined } from '@ant-design/icons-vue' const router = useRouter() diff --git a/admin-system/src/pages/permission/index.vue b/admin-system/src/pages/permission/index.vue index 708a4d2..cdb7252 100644 --- a/admin-system/src/pages/permission/index.vue +++ b/admin-system/src/pages/permission/index.vue @@ -52,6 +52,24 @@ + +
+ + + + 批量删除 + + 已选择 {{ selectedRowKeys.length }} 项 + +
+