single instance app

This commit is contained in:
Kyle Spearrin 2018-02-23 15:08:26 -05:00
parent 98bd6ce021
commit e3c5e3e706
1 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,21 @@ export class WindowMain {
init(): Promise<any> {
return new Promise((resolve, reject) => {
try {
const shouldQuit = app.makeSingleInstance((args, dir) => {
// Someone tried to run a second instance, we should focus our window.
if (this.win != null) {
if (this.win.isMinimized()) {
this.win.restore();
}
this.win.focus();
}
});
if (shouldQuit) {
app.quit();
return;
}
// 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.