From 95b103020f4bd33dacf7028dc0872e8e32675e13 Mon Sep 17 00:00:00 2001 From: Patrick FIc Date: Thu, 10 Apr 2025 15:51:15 -0700 Subject: [PATCH] Resolve protocol handler in dev on Win32 and correct directory. --- src/main/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 5300403..e3e52f8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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); }