This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
CrunchyDL/src/electron/singleInstance.ts
2024-05-01 01:45:45 +02:00

24 lines
535 B
TypeScript

import { App, BrowserWindow } from 'electron'
export default (app: App, win: BrowserWindow) => {
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
return true
}
app.on('second-instance', (_, _argv) => {
if (win) {
win.show()
if (win.isMinimized()) win.restore()
win.focus()
}
})
app.on('open-url', function (event, url) {
event.preventDefault()
win.webContents.send('deeplink', url)
})
}