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 8bf33b65cd
commit c73c113721
453 changed files with 243002 additions and 4493 deletions
@@ -6,14 +6,15 @@ import { fetchLatestNotifications } from '@/api/business'
*
* - 数据源:GET /api/admin/notifications/latest(active 且未过期,管理员全量可见,
* 与员工端壳子 notifier.js 消费的 /api/notifications 同源同语义)
* - 已读跟踪:localStorage 存最近已读时间戳(服务端无逐用户已读模型,控制台本地判定足够;
* 时间戳之前的视为已读,铃铛红点 = 存在更新的通知)
* - 已读跟踪:localStorage 存最近已读通知 id(服务端无逐用户已读模型,控制台本地判定足够)。
* 用 id 而非时间戳做水位:id 自增单调、零时钟依赖,避免浏览器时钟略慢于服务端时
* 新通知 created_at「在未来」导致红点永远清不掉(「全部已读没效果」根因)
* - 轮询:模块级单例 60s 轻量刷新,页眉与面板不重复请求
*/
const LAST_READ_KEY = '37du-notify-last-read'
const LAST_READ_KEY = '37du-notify-last-read-id'
function readLastRead(): number {
function readLastReadId(): number {
try {
return Number(localStorage.getItem(LAST_READ_KEY) || 0)
} catch (e) {
@@ -22,19 +23,13 @@ function readLastRead(): number {
}
const items = ref<any[]>([])
const lastRead = ref<number>(readLastRead())
const lastReadId = ref<number>(readLastReadId())
const loading = ref(false)
let started = false
/** created_at 'YYYY-MM-DD HH:mm:ss' → 时间戳(服务端与本机同区) */
function toTs(s: string): number {
if (!s) return 0
return new Date(String(s).replace(' ', 'T')).getTime() || 0
}
/** 存在比"最近已读"更新的通知 */
/** 存在比"最近已读 id"更新的通知 */
const unreadCount = computed(() => {
return items.value.filter((i) => toTs(i.created_at) > lastRead.value).length
return items.value.filter((i) => Number(i.id) > lastReadId.value).length
})
async function refresh(): Promise<void> {
@@ -50,13 +45,16 @@ async function refresh(): Promise<void> {
}
}
/** 全部标记已读:以当前时间作为已读水位 */
/** 全部标记已读:以当前列表中最大的通知 id 作为已读水位 */
function markAllRead(): void {
lastRead.value = Date.now()
try {
localStorage.setItem(LAST_READ_KEY, String(lastRead.value))
} catch (e) {
/* ignore */
const maxId = items.value.reduce((m, i) => Math.max(m, Number(i.id) || 0), 0)
if (maxId > lastReadId.value) {
lastReadId.value = maxId
try {
localStorage.setItem(LAST_READ_KEY, String(maxId))
} catch (e) {
/* ignore */
}
}
}
@@ -70,5 +68,5 @@ function ensureStarted(): void {
export function useNotifyCenter() {
ensureStarted()
return { items, unreadCount, loading, lastRead, refresh, markAllRead }
return { items, unreadCount, loading, lastReadId, refresh, markAllRead }
}