From 4fee63c43862faeda63c96e57c6751caf39d08bd Mon Sep 17 00:00:00 2001 From: Ruslan Bekenev Date: Mon, 23 Apr 2018 10:41:16 +0300 Subject: [PATCH] prevent multiple instance of the app --- src/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.js b/src/main.js index a03a460..d3912b1 100644 --- a/src/main.js +++ b/src/main.js @@ -66,6 +66,23 @@ function createWindow () { }); } +// make sure we run only one instance of the app +var win = null; + +var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) { + // Someone tried to run a second instance, we should focus our window. + if (win) { + if (win.isMinimized()) win.restore(); + win.focus(); + } +}); + +if (shouldQuit) { + app.quit(); + return; +} + app.on('ready', createWindow); + app.commandLine.appendSwitch('high-dpi-support', 1); app.commandLine.appendSwitch('force-device-scale-factor', 1);