diff --git a/src/main/index.ts b/src/main/index.ts index d3eccdb..798554e 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 mainWin() { +async function createWindow() { win = new BrowserWindow({ title: 'Main window', webPreferences: { @@ -28,7 +28,6 @@ async function mainWin() { const url = `http://${pkg.env.HOST || '127.0.0.1'}:${pkg.env.PORT}` win.loadURL(url) - win.maximize() win.webContents.openDevTools() } @@ -38,7 +37,7 @@ async function mainWin() { }) } -app.whenReady().then(mainWin) +app.whenReady().then(createWindow) app.on('window-all-closed', () => { win = null @@ -54,3 +53,12 @@ app.on('second-instance', () => { win.focus() } }) + +app.on('activate', () => { + const allWindows = BrowserWindow.getAllWindows() + if (allWindows.length) { + allWindows[0].focus() + } else { + createWindow() + } +})