mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
feat: app.on('activate') handle
This commit is contained in:
parent
aea6e9e822
commit
b62d5fae87
@ -13,7 +13,7 @@ if (!app.requestSingleInstanceLock()) {
|
||||
|
||||
let win: BrowserWindow | null = null
|
||||
|
||||
async function bootstrap() {
|
||||
async function createWindow() {
|
||||
win = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '../preload/index.cjs'),
|
||||
@ -27,12 +27,11 @@ async function bootstrap() {
|
||||
const url = `http://${pkg.env.HOST || '127.0.0.1'}:${pkg.env.PORT}`
|
||||
|
||||
win.loadURL(url)
|
||||
win.maximize()
|
||||
win.webContents.openDevTools()
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(bootstrap)
|
||||
app.whenReady().then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
win = null
|
||||
@ -49,6 +48,15 @@ app.on('second-instance', () => {
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
const allWindows = BrowserWindow.getAllWindows()
|
||||
if (allWindows.length) {
|
||||
allWindows[0].focus()
|
||||
} else {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
// @TODO
|
||||
// auto update
|
||||
/* if (app.isPackaged) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user