feat: 重构控制台为37du自动化平台,新增权限授权与通知中心功能

- 更新系统名称、登录页宣传文案为37du平台相关内容
- 移除聊天功能相关代码与配置
- 新增客户端版本上报字段与设备统计接口
- 新增通知中心功能(60s轮询、localStorage已读标记)
- 新增权限授权工作台相关接口与页面
- 新增统一页头组件ArtPageHeader
- 调整快速入口配置指向真实功能页面
- 修复控制面地址为内网生产库
This commit is contained in:
2026-10-15 18:01:29 +08:00
parent f0a94bf523
commit a7dbc5a77e
49 changed files with 4925 additions and 2904 deletions
@@ -0,0 +1,74 @@
import { computed, ref } from 'vue'
import { fetchLatestNotifications } from '@/api/business'
/**
* 通知中心共享状态(页眉铃铛 + 通知面板共用)
*
* - 数据源:GET /api/admin/notifications/latest(active 且未过期,管理员全量可见,
* 与员工端壳子 notifier.js 消费的 /api/notifications 同源同语义)
* - 已读跟踪:localStorage 存最近已读时间戳(服务端无逐用户已读模型,控制台本地判定足够;
* 时间戳之前的视为已读,铃铛红点 = 存在更新的通知)
* - 轮询:模块级单例 60s 轻量刷新,页眉与面板不重复请求
*/
const LAST_READ_KEY = '37du-notify-last-read'
function readLastRead(): number {
try {
return Number(localStorage.getItem(LAST_READ_KEY) || 0)
} catch (e) {
return 0
}
}
const items = ref<any[]>([])
const lastRead = ref<number>(readLastRead())
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
}
/** 存在比"最近已读"更新的通知 */
const unreadCount = computed(() => {
return items.value.filter((i) => toTs(i.created_at) > lastRead.value).length
})
async function refresh(): Promise<void> {
if (loading.value) return
loading.value = true
try {
const r = await fetchLatestNotifications(30)
items.value = r.items || []
} catch (e) {
/* 未登录/网络异常静默,下轮重试 */
} finally {
loading.value = false
}
}
/** 全部标记已读:以当前时间作为已读水位 */
function markAllRead(): void {
lastRead.value = Date.now()
try {
localStorage.setItem(LAST_READ_KEY, String(lastRead.value))
} catch (e) {
/* ignore */
}
}
/** 模块级单例启动轮询(首个调用方触发) */
function ensureStarted(): void {
if (started) return
started = true
refresh()
setInterval(refresh, 60_000)
}
export function useNotifyCenter() {
ensureStarted()
return { items, unreadCount, loading, lastRead, refresh, markAllRead }
}