From 7bf5805714577173b16670c067896449210998fd Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 11 May 2024 23:09:33 +0900 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=8B=AC=E7=AB=8B=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=9C=AA=E6=BF=80=E6=B4=BB=E9=98=85=E8=AF=BB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/electron.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/electron/electron.js b/electron/electron.js index 5c1277de2..a43b2121c 100644 --- a/electron/electron.js +++ b/electron/electron.js @@ -96,6 +96,14 @@ function createMainWindow() { } }) + mainWindow.on('focus', () => { + mainWindow.webContents.send("browserWindowFocus", {}) + }) + + mainWindow.on('blur', () => { + mainWindow.webContents.send("browserWindowBlur", {}) + }) + mainWindow.on('close', event => { if (!willQuitApp) { utils.onBeforeUnload(event, mainWindow).then(() => { @@ -159,6 +167,14 @@ function createChildWindow(args) { } }) + browser.on('focus', () => { + browser.webContents.send("browserWindowFocus", {}) + }) + + browser.on('blur', () => { + browser.webContents.send("browserWindowBlur", {}) + }) + browser.on('close', event => { if (!willQuitApp) { utils.onBeforeUnload(event, browser).then(() => { @@ -642,18 +658,6 @@ app.on("will-quit",function(){ globalShortcut.unregisterAll(); }) -app.on('browser-window-blur', () => { - if (mainWindow) { - mainWindow.webContents.send("browserWindowBlur", {}) - } -}) - -app.on('browser-window-focus', () => { - if (mainWindow) { - mainWindow.webContents.send("browserWindowFocus", {}) - } -}) - /** * 设置菜单语言包 * @param args {path}