Allow more than one instance of the app.

This commit is contained in:
Preston 2020-06-21 23:03:51 -04:00
parent 06a9e400a3
commit 4bc5b1d608
1 changed files with 20 additions and 20 deletions

View File

@ -14,7 +14,7 @@ app.setName(productName)
// disable electron warning // disable electron warning
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true' process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
const gotTheLock = app.requestSingleInstanceLock() // const gotTheLock = app.requestSingleInstanceLock()
const isDev = process.env.NODE_ENV === 'development' const isDev = process.env.NODE_ENV === 'development'
const isDebug = process.argv.includes('--debug') const isDebug = process.argv.includes('--debug')
let mainWindow let mainWindow
@ -24,25 +24,26 @@ let mainWindow
// This line can possible be removed if the issue is fixed upstream // This line can possible be removed if the issue is fixed upstream
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors') app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
// TODO: Uncomment if needed
// only allow single instance of application // only allow single instance of application
if (!isDev) { // if (!isDev) {
if (gotTheLock) { // if (gotTheLock) {
app.on('second-instance', () => { // app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window. // // Someone tried to run a second instance, we should focus our window.
if (mainWindow && mainWindow.isMinimized()) { // if (mainWindow && mainWindow.isMinimized()) {
mainWindow.restore() // mainWindow.restore()
} // }
mainWindow.focus() // mainWindow.focus()
}) // })
} else { // } else {
app.quit() // app.quit()
process.exit(0) // process.exit(0)
} // }
} else { // } else {
require('electron-debug')({ // require('electron-debug')({
showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true') // showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true')
}) // })
} // }
async function installDevTools () { async function installDevTools () {
try { try {
@ -70,7 +71,6 @@ function createWindow () {
webSecurity: false, webSecurity: false,
backgroundThrottling: false backgroundThrottling: false
}, },
show: false
}) })
// eslint-disable-next-line // eslint-disable-next-line