Merge pull request #1014 from yzrsng/master

Enforces single instance for linux and windows
This commit is contained in:
AkiraFukushima 2019-08-27 00:05:58 +09:00 committed by GitHub
commit 68eb013c6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -74,6 +74,25 @@ let mainWindow: BrowserWindow | null
let tray: Tray | null
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
// Enforces single instance for linux and windows.
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore()
if (!mainWindow!.isVisible()) {
mainWindow!.show()
mainWindow!.setSkipTaskbar(false)
}
mainWindow.focus()
}
})
}
const appId = pkg.build.appId
const splashURL =