Files
sundynix-micro-admin/src/mock/system/logs.ts
T
2026-04-30 22:53:46 +08:00

23 lines
884 B
TypeScript

import type { OperationLog } from '@/api/system'
const clients = ['sundynix-admin', 'plant', 'radio', 'system']
export const mockLogs: OperationLog[] = Array.from({ length: 120 }, (_, i) => {
const method = ['GET', 'POST', 'PUT', 'DELETE'][Math.floor(Math.random() * 4)]
return {
id: `log-${i + 1}`,
userId: 'admin',
clientId: clients[Math.floor(Math.random() * clients.length)],
ip: `192.168.1.${Math.floor(Math.random() * 255)}`,
method,
path: `/api/v1/resource/${Math.floor(Math.random() * 10)}`,
status: Math.random() > 0.1 ? 200 : 500,
latency: Math.floor(Math.random() * 500) * 1000000,
agent: 'Mozilla/5.0',
errorMessage: '',
body: method === 'GET' ? '' : '{"key": "value"}',
resp: '{"code": 200}',
createdAt: Date.now() / 1000 - Math.floor(Math.random() * 86400 * 30),
}
}).sort((a, b) => b.createdAt - a.createdAt)