You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/frontend/mock/settings.ts

39 lines
2.9 KiB
TypeScript

import type { MockMethod } from './types'
const configs = [
{ id: 1, configKey: 'ping_interval', configValue: '60', valueType: 'number', description: 'Ping检测间隔(秒)' },
{ id: 2, configKey: 'collect_retry_count', configValue: '3', valueType: 'number', description: '采集失败重试次数' },
{ id: 3, configKey: 'collect_retry_interval', configValue: '30', valueType: 'number', description: '采集重试间隔(秒)' },
{ id: 4, configKey: 'collect_fail_alert_threshold', configValue: '5', valueType: 'number', description: '连续失败N次触发告警' },
{ id: 5, configKey: 'daily_summary_time', configValue: '01:00', valueType: 'string', description: '日终汇总执行时间' },
{ id: 6, configKey: 'log_retention_days', configValue: '90', valueType: 'number', description: '原始采集日志保留天数' },
{ id: 7, configKey: 'bigscreen_refresh_interval', configValue: '10', valueType: 'number', description: '大屏刷新间隔(秒)' },
{ id: 8, configKey: 'api_token', configValue: '********', valueType: 'string', description: '前端API Token' },
{ id: 9, configKey: 'collector_api_port', configValue: '5800', valueType: 'number', description: '采集服务管理API端口' },
{ id: 10, configKey: 'collector_api_key', configValue: '********', valueType: 'string', description: '采集服务间通信API Key' },
]
const workshops = [
{ id: 1, name: 'A栋', sortOrder: 1, isEnabled: 1, machineCount: 32 },
{ id: 2, name: 'B栋', sortOrder: 2, isEnabled: 1, machineCount: 28 },
{ id: 3, name: 'C栋', sortOrder: 3, isEnabled: 0, machineCount: 0 },
]
const mock: MockMethod[] = [
{ url: '/mock-api/admin/sys-config', method: 'get', response: () => ({ code: 0, data: { items: configs } }) },
{ url: '/mock-api/admin/sys-config/update', method: 'post', response: () => ({ code: 0, message: 'success', data: null }) },
{ url: '/mock-api/admin/sys-config/reset-token', method: 'post', response: () => ({ code: 0, data: { configKey: 'api_token', newValue: 'eyJhbGciOiJIUzI1NiJ9.new.token' } }) },
{ url: '/mock-api/admin/workshop', method: 'get', response: () => ({ code: 0, data: { items: workshops } }) },
{ url: '/mock-api/admin/workshop', method: 'post', response: () => ({ code: 0, message: 'success', data: { id: 4, name: 'D栋' } }) },
{ url: '/mock-api/admin/workshop/update', method: 'post', response: () => ({ code: 0, message: 'success', data: null }) },
{ url: '/mock-api/admin/workshop/delete', method: 'post', response: () => ({ code: 0, message: 'success', data: null }) },
{ url: '/mock-api/admin/workshop/toggle', method: 'post', response: () => ({ code: 0, message: 'success', data: null }) },
{ url: '/mock-api/admin/change-password', method: 'post', response: ({ body }: any) => {
const data = body
if (data.currentPassword === 'admin123') return { code: 0, message: 'success', data: null }
return { code: 40001, message: '当前密码不正确', data: null }
}},
]
export default mock