99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
import type { DashboardStats, AuditLog, TrendPoint } from '@/types/admin'
|
|
|
|
function makeTrend(days: number, base: number, variance: number): TrendPoint[] {
|
|
return Array.from({ length: days }, (_, i) => {
|
|
const d = new Date()
|
|
d.setDate(d.getDate() - (days - 1 - i))
|
|
return {
|
|
date: d.toISOString().split('T')[0],
|
|
value: Math.max(0, base + Math.round((Math.random() - 0.5) * variance)),
|
|
}
|
|
})
|
|
}
|
|
|
|
export const MOCK_DASHBOARD_STATS: DashboardStats = {
|
|
totalUsers: 1286,
|
|
newUsersToday: 23,
|
|
activeUsersToday: 347,
|
|
totalKnowledgeBases: 892,
|
|
newKbsToday: 15,
|
|
totalAiCallsToday: 4521,
|
|
totalFiles: 3412,
|
|
totalStorageBytes: 15_728_640_000,
|
|
userTrend: makeTrend(30, 40, 30),
|
|
aiCallTrend: makeTrend(30, 150, 100),
|
|
}
|
|
|
|
export const MOCK_AUDIT_LOGS: AuditLog[] = [
|
|
{
|
|
id: 'log-001',
|
|
adminUserId: 'admin-001',
|
|
adminUserEmail: 'admin@longde.cloud',
|
|
adminUserDisplayName: '超级管理员',
|
|
action: 'LOGIN',
|
|
resourceType: null,
|
|
resourceId: null,
|
|
beforeJson: null,
|
|
afterJson: null,
|
|
ip: '120.53.227.155',
|
|
userAgent: 'Chrome/130.0',
|
|
createdAt: new Date(Date.now() - 1000 * 60 * 5).toISOString(),
|
|
},
|
|
{
|
|
id: 'log-002',
|
|
adminUserId: 'admin-001',
|
|
adminUserEmail: 'admin@longde.cloud',
|
|
adminUserDisplayName: '超级管理员',
|
|
action: 'CREATE_ADMIN',
|
|
resourceType: 'AdminUser',
|
|
resourceId: 'admin-002',
|
|
beforeJson: null,
|
|
afterJson: { email: 'ops@longde.cloud', role: 'OPERATIONS' },
|
|
ip: '120.53.227.155',
|
|
userAgent: 'Chrome/130.0',
|
|
createdAt: new Date(Date.now() - 1000 * 60 * 30).toISOString(),
|
|
},
|
|
{
|
|
id: 'log-003',
|
|
adminUserId: 'admin-002',
|
|
adminUserEmail: 'ops@longde.cloud',
|
|
adminUserDisplayName: '运营小王',
|
|
action: 'UPDATE_USER_STATUS',
|
|
resourceType: 'User',
|
|
resourceId: 'user-123',
|
|
beforeJson: { status: 'active' },
|
|
afterJson: { status: 'disabled' },
|
|
ip: '120.53.227.156',
|
|
userAgent: 'Firefox/132.0',
|
|
createdAt: new Date(Date.now() - 1000 * 60 * 60).toISOString(),
|
|
},
|
|
{
|
|
id: 'log-004',
|
|
adminUserId: 'admin-001',
|
|
adminUserEmail: 'admin@longde.cloud',
|
|
adminUserDisplayName: '超级管理员',
|
|
action: 'DELETE_FILE',
|
|
resourceType: 'UploadedFile',
|
|
resourceId: 'file-456',
|
|
beforeJson: { filename: '违规内容.pdf' },
|
|
afterJson: null,
|
|
ip: '120.53.227.155',
|
|
userAgent: 'Chrome/130.0',
|
|
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 2).toISOString(),
|
|
},
|
|
{
|
|
id: 'log-005',
|
|
adminUserId: 'admin-001',
|
|
adminUserEmail: 'admin@longde.cloud',
|
|
adminUserDisplayName: '超级管理员',
|
|
action: 'LOGIN_FAILED',
|
|
resourceType: null,
|
|
resourceId: null,
|
|
beforeJson: null,
|
|
afterJson: null,
|
|
ip: '10.0.0.1',
|
|
userAgent: null,
|
|
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 3).toISOString(),
|
|
},
|
|
]
|