Skip to content

Commit

Permalink
Add Windows support and deep linking configuration (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianaChiabai authored Jan 21, 2025
1 parent ecca7dd commit 42026e6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resources/js/electron-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const { autoUpdater } = electronUpdater;
class NativePHP {
processes = [];
schedulerInterval = undefined;
mainWindow = null;

public bootstrap(
app: CrossProcessExports.App,
Expand Down Expand Up @@ -88,6 +89,17 @@ class NativePHP {

event.preventDefault();
});

// Handle deep linking for Windows
if (process.platform === 'win32') {
app.on('second-instance', (event, commandLine, workingDirectory) => {
if (this.mainWindow) {
if (this.mainWindow.isMinimized()) this.mainWindow.restore();
this.mainWindow.focus();
}
this.handleDeepLink(commandLine.pop());
});
}
}

private async bootstrapApp(app: Electron.CrossProcessExports.App) {
Expand Down Expand Up @@ -161,6 +173,15 @@ class NativePHP {
} else {
app.setAsDefaultProtocolClient(deepLinkProtocol);
}


if (process.platform === 'win32') {
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
return;
}
}
}
}

Expand Down

0 comments on commit 42026e6

Please sign in to comment.