From 0b94583796ec59281a392584dcc8459710bda1b4 Mon Sep 17 00:00:00 2001 From: hezhaohui Date: Tue, 14 Jul 2026 15:39:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E5=AE=9E=E7=8E=B0=E5=AE=A1?= =?UTF-8?q?=E8=AE=A1=E9=9D=A2=E6=9D=BF=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 页面: - views/audit/LoginAudit.vue,登录审计页(查询登录记录、按时间/IP/结果筛选) - views/audit/OpsAudit.vue,运维操作审计页(查询操作记录、按类型/状态筛选) 组件: - components/AuditLogTable.vue,审计日志表格组件(分页、筛选) API: - api/audit.ts,审计相关接口(登录审计、运维操作审计) MVP 验收:可查询所有用户的登录记录和运维操作记录 --- frontend/src/api/audit.ts | 72 ++++++++ frontend/src/components/AuditLogTable.vue | 207 ++++++++++++++++++++++ frontend/src/views/audit/LoginAudit.vue | 70 ++++++++ frontend/src/views/audit/OpsAudit.vue | 71 ++++++++ 4 files changed, 420 insertions(+) create mode 100644 frontend/src/api/audit.ts create mode 100644 frontend/src/components/AuditLogTable.vue create mode 100644 frontend/src/views/audit/LoginAudit.vue create mode 100644 frontend/src/views/audit/OpsAudit.vue diff --git a/frontend/src/api/audit.ts b/frontend/src/api/audit.ts new file mode 100644 index 0000000..10c18cb --- /dev/null +++ b/frontend/src/api/audit.ts @@ -0,0 +1,72 @@ +import request from './request' + +export interface LoginAudit { + id: number + user_id: number + username: string + login_time: string + source_ip: string + target_system: string + status: 'success' | 'failed' +} + +export interface OpsAudit { + id: number + user_id: number + username: string + operation_type: string + operation: string + target: string + status: 'success' | 'failed' | 'running' + created_at: string +} + +// Mock 数据 +const mockLoginAudits: LoginAudit[] = [ + { id: 1, user_id: 1, username: 'zhangsan', login_time: '2024-01-15T10:30:00Z', source_ip: '10.0.0.1', target_system: 'Wayne', status: 'success' }, + { id: 2, user_id: 2, username: 'lisi', login_time: '2024-01-15T10:25:00Z', source_ip: '10.0.0.2', target_system: 'CloudDM', status: 'success' }, + { id: 3, user_id: 3, username: 'wangwu', login_time: '2024-01-15T10:20:00Z', source_ip: '10.0.0.3', target_system: 'CacheCloud', status: 'failed' }, + { id: 4, user_id: 1, username: 'zhangsan', login_time: '2024-01-15T09:15:00Z', source_ip: '10.0.0.1', target_system: 'Grafana', status: 'success' }, + { id: 5, user_id: 4, username: 'zhaoliu', login_time: '2024-01-15T09:00:00Z', source_ip: '10.0.0.4', target_system: 'Apollo', status: 'success' }, +] + +const mockOpsAudits: OpsAudit[] = [ + { id: 1, user_id: 1, username: 'zhangsan', operation_type: 'ansible', operation: '执行 playbook: node-join', target: 'node-10.0.0.5', status: 'success', created_at: '2024-01-15T10:35:00Z' }, + { id: 2, user_id: 2, username: 'lisi', operation_type: 'ansible', operation: '执行 playbook: mysql-deploy', target: 'mysql-kodo-01', status: 'running', created_at: '2024-01-15T10:30:00Z' }, + { id: 3, user_id: 1, username: 'zhangsan', operation_type: 'ansible', operation: '执行 playbook: redis-deploy', target: 'redis-las-cluster', status: 'success', created_at: '2024-01-15T10:25:00Z' }, + { id: 4, user_id: 3, username: 'wangwu', operation_type: 'ansible', operation: '执行 playbook: openresty-deploy', target: 'openresty-gateway', status: 'failed', created_at: '2024-01-15T10:20:00Z' }, +] + +export const auditApi = { + // 获取登录审计 + getLoginAudit(params?: any): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve({ + code: 0, + message: 'success', + data: { + total: mockLoginAudits.length, + items: mockLoginAudits, + }, + }) + }, 300) + }) + }, + + // 获取运维操作审计 + getOpsAudit(params?: any): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve({ + code: 0, + message: 'success', + data: { + total: mockOpsAudits.length, + items: mockOpsAudits, + }, + }) + }, 300) + }) + }, +} diff --git a/frontend/src/components/AuditLogTable.vue b/frontend/src/components/AuditLogTable.vue new file mode 100644 index 0000000..e568768 --- /dev/null +++ b/frontend/src/components/AuditLogTable.vue @@ -0,0 +1,207 @@ + + + + + diff --git a/frontend/src/views/audit/LoginAudit.vue b/frontend/src/views/audit/LoginAudit.vue new file mode 100644 index 0000000..c3540ed --- /dev/null +++ b/frontend/src/views/audit/LoginAudit.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/frontend/src/views/audit/OpsAudit.vue b/frontend/src/views/audit/OpsAudit.vue new file mode 100644 index 0000000..7eb2567 --- /dev/null +++ b/frontend/src/views/audit/OpsAudit.vue @@ -0,0 +1,71 @@ + + + + +