mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Electron: Prevent multiple application instances
This commit is contained in:
parent
56609d3619
commit
5094968a17
1 changed files with 17 additions and 0 deletions
|
@ -349,6 +349,23 @@ export class Main {
|
|||
|
||||
Main.startFullscreen = argv.fullscreen;
|
||||
Main.shouldOpenMainWindow = !argv.noMainWindow;
|
||||
|
||||
const lock = Main.application.requestSingleInstanceLock()
|
||||
if (!lock) {
|
||||
Main.application.quit();
|
||||
return;
|
||||
}
|
||||
Main.application.on('second-instance', () => {
|
||||
if (Main.mainWindow) {
|
||||
if (Main.mainWindow.isMinimized()) {
|
||||
Main.mainWindow.restore();
|
||||
}
|
||||
Main.mainWindow.focus();
|
||||
}
|
||||
else {
|
||||
Main.openMainWindow();
|
||||
}
|
||||
})
|
||||
Main.application.on('ready', Main.onReady);
|
||||
Main.application.on('window-all-closed', () => { });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue