feat(frontend): 实现审计面板模块

页面:
- views/audit/LoginAudit.vue,登录审计页(查询登录记录、按时间/IP/结果筛选)
- views/audit/OpsAudit.vue,运维操作审计页(查询操作记录、按类型/状态筛选)

组件:
- components/AuditLogTable.vue,审计日志表格组件(分页、筛选)

API:
- api/audit.ts,审计相关接口(登录审计、运维操作审计)

MVP 验收:可查询所有用户的登录记录和运维操作记录
This commit is contained in:
2026-07-14 15:39:54 +08:00
parent 35e626971c
commit 0b94583796
4 changed files with 420 additions and 0 deletions
+72
View File
@@ -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<any> {
return new Promise((resolve) => {
setTimeout(() => {
resolve({
code: 0,
message: 'success',
data: {
total: mockLoginAudits.length,
items: mockLoginAudits,
},
})
}, 300)
})
},
// 获取运维操作审计
getOpsAudit(params?: any): Promise<any> {
return new Promise((resolve) => {
setTimeout(() => {
resolve({
code: 0,
message: 'success',
data: {
total: mockOpsAudits.length,
items: mockOpsAudits,
},
})
}, 300)
})
},
}