fix multi-instance launch bug #100

This commit is contained in:
Nicolas Constant 2019-06-23 16:01:45 -04:00
parent da7ddc7f3d
commit 2bc4393488
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 147 additions and 132 deletions

View File

@ -149,10 +149,25 @@ function getFile(filePath, res, page404) {
app.commandLine.appendSwitch("force-color-profile", "srgb");
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (win) {
if (win.isMinimized()) win.restore()
win.focus()
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on("ready", createWindow);
}
// Quit when all windows are closed.
app.on("window-all-closed", () => {