feat: imporve main

This commit is contained in:
草鞋没号 2021-11-09 11:12:32 +08:00
parent e715f0bd9b
commit 663adc9935
1 changed files with 19 additions and 1 deletions

View File

@ -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()
}
})