mirror of
https://github.com/kuaifan/dootask.git
synced 2026-07-03 12:55:13 +00:00
perf(apps): 角标快照判定改用 isInstalled,自定义微应用一次性建 set
userBadges 原先用 Apps::appMenuConfig() 判定应用是否存在,每个不重复 app_id 都要解析两个 yaml(loadInstalledConfig + readPluginMenus),且 自定义微应用每行都重新 foreach setting。 - 插件应用走 Apps::isInstalled(只读一个 yaml + RequestContext 请求级缓存) - 自定义微应用循环外一次性建 id set,O(1) 命中 - 行为不变(已在线实测):installed 时正常返回;status=uninstalled 时过滤
This commit is contained in:
parent
4a18ff0315
commit
b589307ebb
@ -265,11 +265,26 @@ class Badge
|
||||
return $map;
|
||||
}
|
||||
$rows = AppBadge::whereUserid($userid)->get(['app_id', 'menu_key', 'count', 'dot']);
|
||||
if ($rows->isEmpty()) {
|
||||
return $map;
|
||||
}
|
||||
// 自定义微应用 id 集合一次性收,避免每行重复 foreach
|
||||
$customIds = [];
|
||||
$customApps = Base::setting('microapp_menu');
|
||||
if (is_array($customApps)) {
|
||||
foreach ($customApps as $app) {
|
||||
if (is_array($app) && !empty($app['id'])) {
|
||||
$customIds[(string)$app['id']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 按 app_id 缓存判定结果:插件应用走 Apps::isInstalled(单 yaml + 请求级缓存),
|
||||
// 自定义微应用查 set,避免每行都读 yaml / 遍历 setting。
|
||||
$exists = [];
|
||||
foreach ($rows as $row) {
|
||||
$appId = (string)$row->app_id;
|
||||
if (!isset($exists[$appId])) {
|
||||
$exists[$appId] = Apps::appMenuConfig($appId) !== null;
|
||||
$exists[$appId] = isset($customIds[$appId]) || Apps::isInstalled($appId);
|
||||
}
|
||||
if (!$exists[$appId]) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user