add single instance lock option

This commit is contained in:
Araxeus
2022-01-27 09:58:50 +02:00
parent 61eb23614a
commit 1248f1c8ec
2 changed files with 37 additions and 12 deletions

View File

@ -26,6 +26,22 @@ unhandled({
process.env.NODE_OPTIONS = "";
const app = electron.app;
// Prevent window being garbage collected
let mainWindow;
autoUpdater.autoDownload = false;
if(config.get("options.singleInstanceLock")){
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) app.quit();
app.on('second-instance', () => {
if (!mainWindow) return;
if (mainWindow.isMinimized()) mainWindow.restore();
if (!mainWindow.isVisible()) mainWindow.show();
mainWindow.focus();
});
}
app.commandLine.appendSwitch(
"js-flags",
// WebAssembly flags
@ -54,10 +70,6 @@ require("electron-debug")({
showDevTools: false //disable automatic devTools on new window
});
// Prevent window being garbage collected
let mainWindow;
autoUpdater.autoDownload = false;
let icon = "assets/youtube-music.png";
if (process.platform == "win32") {
icon = "assets/generated/icon.ico";