Add single-instance

This commit is contained in:
smartfridge 2022-09-25 20:31:29 +02:00 committed by GitHub
parent b5e7e94ba7
commit 7e9e43fa6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,7 +54,19 @@ async function doAfterDefiningTheWindow() {
}
mainWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36`; //fake useragent for screenshare to work
}
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// i love stack overflow
if (mainWindow) {
mainWindow.restore()
mainWindow.focus()
}
})
}
mainWindow.webContents.setWindowOpenHandler(({url}) => {
if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) {
shell.openExternal(url);