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 @@ + + + + +