Resolve protocol handler in dev on Win32 and correct directory.

This commit is contained in:
Patrick FIc
2025-04-10 15:51:15 -07:00
parent 3b17175b14
commit 95b103020f

View File

@@ -326,7 +326,22 @@ app.whenReady().then(async () => {
optimizer.watchWindowShortcuts(window);
});
const isDefaultProtocolClient = app.setAsDefaultProtocolClient(protocol);
let isDefaultProtocolClient;
// remove so we can register each time as we run the app.
app.removeAsDefaultProtocolClient(protocol);
// If we are running a non-packaged version of the app && on windows
if (process.env.NODE_ENV === "development" && process.platform === "win32") {
// Set the path of electron.exe and your app.
// These two additional parameters are only available on windows.
isDefaultProtocolClient = app.setAsDefaultProtocolClient(
protocol,
process.execPath,
[path.resolve(process.argv[1])],
);
} else {
isDefaultProtocolClient = app.setAsDefaultProtocolClient(protocol);
}
if (isDefaultProtocolClient) {
log.info("Protocol handler registered successfully.");
} else {
@@ -487,6 +502,6 @@ function openMainWindow(): void {
function openInExplorer(url: string): void {
const folderPath: string = decodeURIComponent(url.split(`${protocol}://`)[1]);
log.info("Opening folder in explorer", path.dirname(folderPath));
shell.openPath(path.dirname(folderPath));
log.info("Opening folder in explorer", folderPath);
shell.openPath(folderPath);
}