diff --git a/src/main/index.ts b/src/main/index.ts index 656b7c0..beb45e5 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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) {