Resolve protocol handler in dev on Win32 and correct directory.
This commit is contained in:
@@ -326,7 +326,22 @@ app.whenReady().then(async () => {
|
|||||||
optimizer.watchWindowShortcuts(window);
|
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) {
|
if (isDefaultProtocolClient) {
|
||||||
log.info("Protocol handler registered successfully.");
|
log.info("Protocol handler registered successfully.");
|
||||||
} else {
|
} else {
|
||||||
@@ -487,6 +502,6 @@ function openMainWindow(): void {
|
|||||||
|
|
||||||
function openInExplorer(url: string): void {
|
function openInExplorer(url: string): void {
|
||||||
const folderPath: string = decodeURIComponent(url.split(`${protocol}://`)[1]);
|
const folderPath: string = decodeURIComponent(url.split(`${protocol}://`)[1]);
|
||||||
log.info("Opening folder in explorer", path.dirname(folderPath));
|
log.info("Opening folder in explorer", folderPath);
|
||||||
shell.openPath(path.dirname(folderPath));
|
shell.openPath(folderPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user