feat(msg): 「按应用」清单接真实数据——GetUserApp 应用全集 + 按应用未读数角标
build / build (push) Successful in 1m59s

- 应用清单改与桌面网格同源 GetUserApp(BoaApp 自带 appKey/name):原实现读 store.getFlattenAppList,但 setApps 无调用方、列表恒空,且 MenuBar 本身无 appKey 字段——「按应用」此前只剩「全部」一行
- 角标接新代理端点 msgCenter/unreadCountByApp({appKey: 未读数}),未读多的应用排前,替代原 summary.todos 待办数语义
- 卡片 appName 缺失降级改同源匹配用户应用清单
This commit is contained in:
chenxing
2026-10-08 12:00:05 +08:00
parent 19e1bbc9d7
commit 297934f862
2 changed files with 51 additions and 21 deletions
+9
View File
@@ -134,6 +134,15 @@ class Base extends Abstract {
}>({ url });
}
/**
* 消息中心:按来源应用未读数映射(「按应用」清单角标):{appKey: 未读数},无未读的 appKey 不出现
* @memberof Basic
*/
getMsgCenterUnreadCountByApp() {
const url = path + "/msgCenter/unreadCountByApp";
return this.getRequest<Record<string, number>>({ url });
}
/**
* WS 实时推送握手地址(UserMsg 一次性票据;url=null 表示未配置/不可达,走手动刷新兜底)
* @memberof Basic
+42 -21
View File
@@ -23,7 +23,7 @@
</div>
</div>
<!-- 模式二:按应用(应用清单取 store 应用列表;计数取 summary todos 待办角标) -->
<!-- 模式二:按应用(应用清单=GetUserApp 用户应用全集;角标=unreadCountByApp 按应用未读数) -->
<div v-show="mode === 'app'">
<div class="side-title">全部应用</div>
<div :class="['cat', { active: curApp === 'all' }]" @click="onClickApp('all')">
@@ -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<Record<string, number>>({});
/** 应用导航:清单=用户应用全集(GetUserApp,BoaApp 自带 appKey/name,与桌面网格同源);角标=按应用未读数 */
const userApps = ref<{ appKey: string; name: string }[]>([]);
const unreadByApp = ref<Record<string, number>>({});
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<string, number> = {};
(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(() => {