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
|
let win: BrowserWindow | null = null
|
||||||
|
|
||||||
async function bootstrap() {
|
async function createWindow() {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, '../preload/index.cjs'),
|
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}`
|
const url = `http://${pkg.env.HOST || '127.0.0.1'}:${pkg.env.PORT}`
|
||||||
|
|
||||||
win.loadURL(url)
|
win.loadURL(url)
|
||||||
win.maximize()
|
|
||||||
win.webContents.openDevTools()
|
win.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(bootstrap)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
win = null
|
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
|
// @TODO
|
||||||
// auto update
|
// auto update
|
||||||
/* if (app.isPackaged) {
|
/* if (app.isPackaged) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user