fix(theme-manager): 修复 IPC 守卫误判与 WorkBuddy 安装位置探测 - #3
Open
hncz2015 wants to merge 1 commit into
Open
Conversation
1. registerTrustedHandler: 将脆弱的 senderFrame.url 精确字符串比较改为 event.sender === mainWindow.webContents 身份校验,并保留归一化 URL 兜底, 修复 Windows 下报 '拒绝来自非本地页面的请求' 导致皮肤列表加载失败的问题。 2. windowsCandidates(): 增加 C~Z 全盘符扫描 (WKBD/WorkBuddy/WorkBuddy.exe 与 WorkBuddy/WorkBuddy.exe),修复 WorkBuddy 装在非 C 盘 (如 G:/WKBD) 时报 '找不到 WorkBuddy 安装位置' 的问题。
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.
修复内容
1. IPC 安全守卫误判(报错:拒绝来自非本地页面的请求)
src/main/main.mjs的registerTrustedHandler原先用event.senderFrame?.url与pathToFileURL(rendererDirectory/index.html).href做精确字符串比较。运行时senderFrame?.url取不到值(恒为""),永远不等于trustedUrl,守卫误杀合法本地页面,导致manager:bootstrap调用被拒、皮肤列表加载失败。改为:
event.sender === mainWindow.webContents身份校验为首选,并保留归一化 URL 比较作为兜底(归一化解码 %-编码、统一分隔符、小写、去尾部斜杠)。同时让rendererDirectory防御性解析,兼容 asar 内 / 解包外两种布局。2. WorkBuddy 安装位置探测失败(报错:找不到 WorkBuddy 安装位置)
src/main/runtime.mjs的windowsCandidates()原先只列 C 盘 4 个固定目录,而 WorkBuddy 实际装在非 C 盘(如G:/WKBD/WorkBuddy/WorkBuddy.exe)时永远找不到。改为:增加 C~Z 全盘符扫描,每个盘查
WKBD/WorkBuddy/WorkBuddy.exe与WorkBuddy/WorkBuddy.exe,兼容任意盘符的自定义 / 便携安装。验证
main.mjs/runtime.mjs语法检查通过。resolveWorkBuddyPath()正确解析到G:\WKBD\WorkBuddy\WorkBuddy.exe。