From 4a18ff03159d581f72210d747cd769d3326f3bf7 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 29 Jun 2026 12:16:19 +0000 Subject: [PATCH] =?UTF-8?q?fix(apps):=20=E8=A7=92=E6=A0=87=E5=BF=AB?= =?UTF-8?q?=E7=85=A7=E8=BF=87=E6=BB=A4=E5=B7=B2=E5=8D=B8=E8=BD=BD=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=AE=8B=E7=95=99=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 应用卸载后 app_badges 表行未被清理(主程序侧无卸载回调), 导致 hydrate 后父级『应用』入口聚合仍把残留 count 算进去。 userBadges 返回前用 Apps::appMenuConfig() 判定应用是否仍存在 (同时覆盖插件应用与自定义微应用),不存在则跳过;按 app_id 缓 存判定结果,避免逐行重复读 yaml。 --- app/Module/Badge.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Module/Badge.php b/app/Module/Badge.php index 775e471d5..df508821e 100644 --- a/app/Module/Badge.php +++ b/app/Module/Badge.php @@ -253,6 +253,7 @@ class Badge /** * 获取用户当前全部角标快照,用于前端初始同步。 + * 过滤掉应用已不存在(卸载 / 自定义微应用被删除)的行,避免父级聚合统计残留数据。 * * @param int $userid * @return array app_id => menu_key => ['count'=>int,'dot'=>bool] @@ -264,8 +265,16 @@ class Badge return $map; } $rows = AppBadge::whereUserid($userid)->get(['app_id', 'menu_key', 'count', 'dot']); + $exists = []; foreach ($rows as $row) { - $map[$row->app_id][$row->menu_key] = [ + $appId = (string)$row->app_id; + if (!isset($exists[$appId])) { + $exists[$appId] = Apps::appMenuConfig($appId) !== null; + } + if (!$exists[$appId]) { + continue; + } + $map[$appId][$row->menu_key] = [ 'count' => (int)$row->count, 'dot' => (bool)$row->dot, ];