From c8c60e693f704c9eb08dc100c2d24af5a1455efc Mon Sep 17 00:00:00 2001 From: shenmo Date: Fri, 2 Sep 2022 13:42:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/main.js b/main.js index c7368f7..a77d3fd 100644 --- a/main.js +++ b/main.js @@ -480,10 +480,21 @@ function createMenu() { } } -const createMainWindow = () => { +function createMainWindow = () => { + + // 实现单例,在启动第二个实例后,激活主窗口,然后退出第二个实例 +const shouldQuit = app.makeSingleInstance(() => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore() + mainWindow.focus() + } +}) + +shouldQuit && app.quit() + var mainWindowState = windowStateKeeper({ - defaultWidth: 745, - defaultHeight: 450, + defaultWidth: 1300, + defaultHeight: 700, }); mainWindow = new BrowserWindow({ @@ -705,17 +716,6 @@ const createMainWindow = () => { mainWindow.webContents.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8'); createMenu(); }; - -// 实现单例,在启动第二个实例后,激活主窗口,然后退出第二个实例 -const shouldQuit = app.makeSingleInstance(() => { - if (mainWindow) { - if (mainWindow.isMinimized()) mainWindow.restore() - mainWindow.focus() - } -}) - -shouldQuit && app.quit() - app.setName(pkg.name); app.dock && app.dock.setIcon(icon);