feat: 新增多插件 UI 支持及运行日志集中回传功能

本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
2026-10-26 15:42:50 +08:00
parent 9fd687ada8
commit 843ff244a6
453 changed files with 243002 additions and 4493 deletions
@@ -37,6 +37,28 @@ export function patchPlugin(plugin_id: string, body: any) {
return request.post<any>({ url: '/api/admin/plugin/patch', params: { plugin_id }, data: body })
}
// ==================== 字典(可维护枚举,如场景分类 plugin_category) ====================
/** 字典项列表(sort,id 升序) */
export function fetchDictItems(key: string) {
return request.get<{ items: { id: number; label: string; sort: number }[] }>({ url: `/api/admin/dict/${key}/items` })
}
/** 新增字典项 */
export function addDictItem(key: string, label: string) {
return request.post<any>({ url: `/api/admin/dict/${key}/items`, data: { label } })
}
/** 改名 / 上移下移 */
export function updateDictItem(key: string, id: number, body: { label?: string; move?: 'up' | 'down' }) {
return request.put<any>({ url: `/api/admin/dict/${key}/items/${id}`, data: body })
}
/** 删除字典项(不影响已引用该值的业务数据) */
export function deleteDictItem(key: string, id: number) {
return request.del<any>({ url: `/api/admin/dict/${key}/items/${id}` })
}
/** 账号列表 */
export function fetchAccounts(params: { page?: number; page_size?: number; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/accounts', params })
@@ -192,3 +214,53 @@ export function uploadAvatar(file: File, account: string) {
fd.append('file', file)
return request.post<any>({ url: '/api/admin/avatar', data: fd, params: { account }, timeout: 30000 })
}
// ==================== 集中日志(运行日志 / 客户端壳日志) ====================
/** 运行日志列表(分页 + 账号/设备/插件/状态/关键字/近N天筛选) */
export function fetchRunLogs(params: {
page?: number; page_size?: number; account?: string; device?: string;
plugin?: string; status?: string; q?: string; days?: number;
}) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/run-logs', params })
}
/** 单次运行日志详情(含日志正文) */
export function fetchRunLogDetail(runId: string) {
return request.get<any>({ url: `/api/admin/run-logs/${encodeURIComponent(runId)}` })
}
/** 客户端壳日志设备列表 */
export function fetchDeviceLogs(params: { page?: number; page_size?: number; account?: string; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/device-logs', params })
}
/** 设备壳日志尾部内容 */
export function fetchDeviceLogDetail(deviceId: string) {
return request.get<any>({ url: `/api/admin/device-logs/${encodeURIComponent(deviceId)}` })
}
/** 壳日志全文下载(需鉴权头,用 fetch 取 blob 触发浏览器下载) */
export async function downloadDeviceLog(deviceId: string, filename?: string) {
const { useUserStore } = await import('@/store/modules/user')
const token = useUserStore().accessToken
const base = (import.meta.env.VITE_API_URL as string) || ''
const res = await fetch(`${base}/api/admin/device-logs/${encodeURIComponent(deviceId)}/download`, {
headers: { 'X-Admin-Token': token || '' },
})
if (!res.ok) throw new Error(`下载失败 HTTP ${res.status}`)
const blob = await res.blob()
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename || `shell-${deviceId}.log`
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 5000)
}
/** 手动触发一次保留期清理 */
export function cleanupLogs() {
return request.post<any>({ url: '/api/admin/logs/cleanup' })
}