perf: 独立窗口未激活阅读逻辑

This commit is contained in:
kuaifan 2024-05-11 23:09:33 +09:00
parent 19604c46f0
commit 7bf5805714

28
electron/electron.js vendored
View File

@ -96,6 +96,14 @@ function createMainWindow() {
} }
}) })
mainWindow.on('focus', () => {
mainWindow.webContents.send("browserWindowFocus", {})
})
mainWindow.on('blur', () => {
mainWindow.webContents.send("browserWindowBlur", {})
})
mainWindow.on('close', event => { mainWindow.on('close', event => {
if (!willQuitApp) { if (!willQuitApp) {
utils.onBeforeUnload(event, mainWindow).then(() => { 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 => { browser.on('close', event => {
if (!willQuitApp) { if (!willQuitApp) {
utils.onBeforeUnload(event, browser).then(() => { utils.onBeforeUnload(event, browser).then(() => {
@ -642,18 +658,6 @@ app.on("will-quit",function(){
globalShortcut.unregisterAll(); 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} * @param args {path}