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}