feat(Windows app-search): 修复应用索引不完整与图标显示问题,补齐开始菜单同源数据并实现图标缓存自愈#491
Open
XiaoSong-dada wants to merge 2 commits into
Hidden character warning
The head ref may contain hidden characters: "\u5e94\u7528\u641c\u7d22\u8986\u76d6"
Open
feat(Windows app-search): 修复应用索引不完整与图标显示问题,补齐开始菜单同源数据并实现图标缓存自愈#491XiaoSong-dada wants to merge 2 commits into
XiaoSong-dada wants to merge 2 commits into
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与目标
Rubick 在 Windows 11 上的应用搜索存在两个主要问题:
Get-StartApps(AppID 分支)时;清空%TEMP%\ProcessIcon后图标无法自动恢复。目标:让 Rubick 的 Windows 应用搜索尽可能与系统开始菜单一致,并确保图标稳定显示。
问题根因
appList经常不完整。.lnk快捷方式,遗漏 UWP 应用及部分注册型入口(如 AppID 标识的应用)。encodeURIComponent(appName)生成,而实际写入使用未编码的app.name,导致文件找不到。extract-file-icon对shell:AppsFolder\AppID输入返回空 buffer,无法直接提取图标。%20等字符,且不同语言环境下可能产生乱码,导致图标文件无法被正确引用。解决方案
本次 PR 通过组合策略与自愈机制,系统性地修复上述问题:
完善应用索引(win.ts)
Get-StartApps。await,确保索引完整后返回。Get-StartApps结果映射为AppInfo,并添加 AppID 分词作为关键词,提升搜索命中率。统一图标缓存路径与写入方式
getIconPathByName(name),使用normalizeAppName清洗文件名(去除非法字符、保留中文和空格),替代 URL 编码。writeFileSync),确保函数返回时文件已存在,消除竞态。为 Get-StartApps 项提供图标兜底
appName→.lnk路径的映射。.lnk,优先用该.lnk提取图标并写入缓存,同时记录iconSource供后续重建。实现展示阶段的“缺图重试”机制
rebuildAppIcon(使用iconSource或desc提取图标)。app.getFileIcon获取 dataURL 临时展示,并记录失败缓存避免无限重试。优化 PowerShell 输出编码
Get-StartApps前设置[Console]::OutputEncoding=[System.Text.Encoding]::UTF8,降低中文乱码概率。关键修改点
src/core/app-search/win.ts:重写扫描逻辑,合并数据源,统一图标路径,添加文件名清洗。src/main/common/api.ts:新增rebuildAppIconIPC 方法,支持图标重建。src/renderer/plugins-manager/options.ts:添加图标缺失检测与自愈逻辑。src/renderer/components/search.vue:微调,确保图标路径传递正确。验证方式
%TEMP%\ProcessIcon目录。clash→ 应出现 Clash Verge,图标正常显示(可能通过.lnk或兜底重建)。qq、微信→ 图标应正常,缓存文件名应为可读格式(如QQ.png、微信.png),无乱码。此 PR 使 Rubick 在 Windows 11 上的应用搜索体验大幅提升,索引完整性与图标显示稳定性达到可交付状态。