From 297934f8621cc41a4fe8d7522f975245f098ac41 Mon Sep 17 00:00:00 2001 From: chenxing Date: Thu, 8 Oct 2026 12:00:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(msg):=20=E3=80=8C=E6=8C=89=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E3=80=8D=E6=B8=85=E5=8D=95=E6=8E=A5=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E2=80=94=E2=80=94GetUserApp=20=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=85=A8=E9=9B=86=20+=20=E6=8C=89=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E6=95=B0=E8=A7=92=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 应用清单改与桌面网格同源 GetUserApp(BoaApp 自带 appKey/name):原实现读 store.getFlattenAppList,但 setApps 无调用方、列表恒空,且 MenuBar 本身无 appKey 字段——「按应用」此前只剩「全部」一行 - 角标接新代理端点 msgCenter/unreadCountByApp({appKey: 未读数}),未读多的应用排前,替代原 summary.todos 待办数语义 - 卡片 appName 缺失降级改同源匹配用户应用清单 --- src/api/BaseApi.ts | 9 ++++++ src/views/msg/index.vue | 63 +++++++++++++++++++++++++++-------------- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/api/BaseApi.ts b/src/api/BaseApi.ts index dd382f9..ca374b5 100644 --- a/src/api/BaseApi.ts +++ b/src/api/BaseApi.ts @@ -134,6 +134,15 @@ class Base extends Abstract { }>({ url }); } + /** + * 消息中心:按来源应用未读数映射(「按应用」清单角标):{appKey: 未读数},无未读的 appKey 不出现 + * @memberof Basic + */ + getMsgCenterUnreadCountByApp() { + const url = path + "/msgCenter/unreadCountByApp"; + return this.getRequest>({ url }); + } + /** * WS 实时推送握手地址(UserMsg 一次性票据;url=null 表示未配置/不可达,走手动刷新兜底) * @memberof Basic diff --git a/src/views/msg/index.vue b/src/views/msg/index.vue index fb4df88..f6c8f2b 100644 --- a/src/views/msg/index.vue +++ b/src/views/msg/index.vue @@ -23,7 +23,7 @@ - +
全部应用
@@ -166,10 +166,10 @@ function isUnread(m: MsgRow) { return m.isRead !== 1; } -/** appName 缺失降级:按 appKey 匹配 store 应用列表,再退类型标签 */ +/** appName 缺失降级:按 appKey 匹配用户应用清单(与桌面网格同源),再退类型标签 */ function typeAppName(m: MsgRow) { if (m.appKey) { - const hit = store.getFlattenAppList.find((x: any) => x.appKey == m.appKey || x.appCode == m.appKey); + const hit = userApps.value.find(a => a.appKey === String(m.appKey)); if (hit && hit.name) return hit.name; } return typeName(m.msgType); @@ -184,14 +184,28 @@ const catList = computed(() => [ { key: "read", name: "已读", color: "#c0c6ce", cnt: catCounts.value.readCount == null ? "—" : catCounts.value.readCount }, ]); -/** 应用导航:store 应用列表平铺;计数取 summary todos 待办角标(同源数据不新拉接口) */ -const todoCounts = ref>({}); +/** 应用导航:清单=用户应用全集(GetUserApp,BoaApp 自带 appKey/name,与桌面网格同源);角标=按应用未读数 */ +const userApps = ref<{ appKey: string; name: string }[]>([]); +const unreadByApp = ref>({}); const appList = computed(() => - store.getFlattenAppList - .filter((x: any) => !!x.appKey || !!x.appCode) - .map((x: any) => ({ appKey: String(x.appKey ?? x.appCode), name: x.name, cnt: todoCounts.value[String(x.appKey ?? x.appCode)] || 0 })) + userApps.value + .map(a => ({ appKey: a.appKey, name: a.name, cnt: unreadByApp.value[a.appKey] || 0 })) + .sort((x, y) => y.cnt - x.cnt) // 未读多的排前(稳定排序,同计数保持注册表顺序) ); +/** 应用清单一次拉齐(GetUserApp;失败降级空,不打扰列表) */ +async function loadApps() { + try { + const groups: any[] = await BaseApi.getUserApp(store.getCurUserId, store.getCurSchId); + userApps.value = (groups || []) + .flatMap((g: any) => (g && Array.isArray(g.apps) ? g.apps : [])) + .filter((a: any) => a && a.appKey != null) + .map((a: any) => ({ appKey: String(a.appKey), name: a.name })); + } catch (e) { + /* 应用清单失败降级空 */ + } +} + /** 当前视图的列表标题 */ const curTitle = computed(() => { if (mode.value === "cat") { @@ -256,22 +270,28 @@ function onScroll() { } } -/** 左栏计数一次拉齐(未读总数进 store 与铃铛同源) */ +/** 左栏计数一次拉齐(未读总数进 store 与铃铛同源;按应用未读数一并拉取) */ async function loadSummary() { try { - const s = await BaseApi.getMsgCenterSummary(); - if (!s) return; - store.setUnreadCount(s.unreadCount); - catCounts.value = { - sysUnread: (s as any).sysUnread, - bizUnread: (s as any).bizUnread, - approvalUnread: (s as any).approvalUnread, - total: (s as any).total, - readCount: (s as any).readCount, - }; + const [s, byApp] = await Promise.all([ + BaseApi.getMsgCenterSummary(), + BaseApi.getMsgCenterUnreadCountByApp().catch(() => null), + ]); + if (s) { + store.setUnreadCount(s.unreadCount); + catCounts.value = { + sysUnread: (s as any).sysUnread, + bizUnread: (s as any).bizUnread, + approvalUnread: (s as any).approvalUnread, + total: (s as any).total, + readCount: (s as any).readCount, + }; + } const map: Record = {}; - (s.todos || []).forEach(t => (map[t.appKey] = t.count)); - todoCounts.value = map; + if (byApp && typeof byApp === "object") { + Object.entries(byApp).forEach(([k, v]) => (map[k] = Number(v) || 0)); + } + unreadByApp.value = map; } catch (e) { /* 摘要失败不打扰列表 */ } @@ -368,6 +388,7 @@ function onWsNewMessage() { onMounted(() => { loadList(true); loadSummary(); + loadApps(); mittBus.on("msgCenter:newMessage", onWsNewMessage); }); onUnmounted(() => {