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:
@@ -0,0 +1,50 @@
|
||||
// 通用格式化:运行台历史、定时任务、下载弹窗共用,避免各组件重复实现。
|
||||
|
||||
export function fmtBytes(n) {
|
||||
if (!n) return '0 B'
|
||||
const u = ['B', 'KB', 'MB', 'GB']
|
||||
let i = 0
|
||||
while (n >= 1024 && i < u.length - 1) { n /= 1024; i++ }
|
||||
return (n >= 100 || i === 0 ? n.toFixed(0) : n.toFixed(1)) + ' ' + u[i]
|
||||
}
|
||||
|
||||
const pad2 = (n) => String(n).padStart(2, '0')
|
||||
|
||||
// 时间戳(秒)→ "10-26 14:30";空值/非法值返回占位符
|
||||
export function fmtTime(ts, fallback = '—') {
|
||||
if (!ts) return fallback
|
||||
const d = new Date(ts * 1000)
|
||||
if (isNaN(d.getTime())) return fallback
|
||||
return `${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`
|
||||
}
|
||||
|
||||
// 时间字符串(如后端 "2026-10-26 14:30:00")→ "10-26 14:30"
|
||||
export function fmtShort(s) {
|
||||
if (!s) return ''
|
||||
const d = new Date(String(s).replace(' ', 'T'))
|
||||
if (isNaN(d.getTime())) return String(s)
|
||||
return `${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`
|
||||
}
|
||||
|
||||
// 耗时秒数 → "45s" / "2分05s"
|
||||
export function durText(s) {
|
||||
const n = parseInt(s, 10) || 0
|
||||
if (n < 60) return n + 's'
|
||||
const m = Math.floor(n / 60)
|
||||
return m + '分' + (n % 60 ? pad2(n % 60) + 's' : '')
|
||||
}
|
||||
|
||||
// 版本比较:数字段按 int(1.10.0 > 1.9.0),非数字段按小写字符串;对齐 electron/crypto.js 的 versionLt
|
||||
export function versionLt(a, b) {
|
||||
const key = (s) => String(s || '').split('.')
|
||||
.map((x) => (/^\d+$/.test(x) ? [1, parseInt(x, 10)] : [0, x.toLowerCase()]))
|
||||
const ka = key(a)
|
||||
const kb = key(b)
|
||||
for (let i = 0; i < Math.max(ka.length, kb.length); i++) {
|
||||
const x = ka[i] || [0, '']
|
||||
const y = kb[i] || [0, '']
|
||||
if (x[0] !== y[0]) return x[0] < y[0]
|
||||
if (x[1] !== y[1]) return x[1] < y[1]
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// 场景色点:语义调色板按插件在总清单中的序号取色,
|
||||
// 分组/搜索/筛选后颜色保持稳定(App.vue 场景库与 SceneCard 共用一份)。
|
||||
export const SCENE_DOTS = [
|
||||
'var(--brand)', 'var(--warn)', 'var(--good)',
|
||||
'var(--info)', 'var(--violet)', 'var(--danger)',
|
||||
]
|
||||
|
||||
export function sceneDotColor(index) {
|
||||
const i = index < 0 ? 0 : index
|
||||
return SCENE_DOTS[i % SCENE_DOTS.length]
|
||||
}
|
||||
Reference in New Issue
Block a user