Skip to content

Commit f445873

Browse files
TCOTC88250
authored andcommitted
🎨 Fix siyuan:// protocol handler in Windows dev environment (#18064)
1 parent c3d1468 commit f445873

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

app/electron/main.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,18 @@ if (!app.requestSingleInstanceLock()) {
7171
return;
7272
}
7373

74-
app.setAsDefaultProtocolClient("siyuan");
74+
// 开发环境下 Windows 需显式传入 Electron 可执行文件路径和 main.js 路径,否则 siyuan:// 会被当作相对路径
75+
if (isDevEnv && process.defaultApp && process.argv.length >= 2) {
76+
const mainScript = path.resolve(process.argv[1]);
77+
if (process.platform === "win32") {
78+
app.removeAsDefaultProtocolClient("siyuan", process.execPath, [mainScript]);
79+
app.setAsDefaultProtocolClient("siyuan", process.execPath, [mainScript]);
80+
} else {
81+
app.setAsDefaultProtocolClient("siyuan");
82+
}
83+
} else {
84+
app.setAsDefaultProtocolClient("siyuan");
85+
}
7586

7687
app.commandLine.appendSwitch("disable-web-security");
7788
app.commandLine.appendSwitch("auto-detect", "false");

0 commit comments

Comments
 (0)