feat: imporve main
This commit is contained in:
parent
e715f0bd9b
commit
663adc9935
|
@ -1,6 +1,13 @@
|
|||
import { join } from 'path'
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
|
||||
app.disableHardwareAcceleration()
|
||||
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
app.quit()
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
let win: BrowserWindow | null = null
|
||||
|
||||
async function mainWin() {
|
||||
|
@ -23,7 +30,18 @@ async function mainWin() {
|
|||
}
|
||||
|
||||
app.whenReady().then(mainWin)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
win = null
|
||||
app.quit()
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('second-instance', () => {
|
||||
if (win) {
|
||||
// someone tried to run a second instance, we should focus our window.
|
||||
if (win.isMinimized()) win.restore()
|
||||
win.focus()
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue