修复弹窗后失去焦点bug
parent
655e9cbf03
commit
5583f49106
|
@ -130,6 +130,34 @@ function createWindow(option: any, url: any) {
|
||||||
win.loadFile(url)
|
win.loadFile(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isWindows = process.platform === 'win32';
|
||||||
|
let needsFocusFix = false;
|
||||||
|
let triggeringProgrammaticBlur = false;
|
||||||
|
|
||||||
|
//弹出警报窗口后 input获取不到焦点
|
||||||
|
win.on('blur', (event: any) => {
|
||||||
|
if(!triggeringProgrammaticBlur) {
|
||||||
|
needsFocusFix = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
win.on('focus', (event: any) => {
|
||||||
|
if(isWindows && needsFocusFix) {
|
||||||
|
needsFocusFix = false;
|
||||||
|
triggeringProgrammaticBlur = true;
|
||||||
|
//弹出弹窗后重新聚焦导致windows任务栏显示,重新隐藏底部windows任务栏
|
||||||
|
win.minimize(); //最小化函数
|
||||||
|
win.restore(); //取消最小化函数(从最小化窗口还原函数)
|
||||||
|
setTimeout(function () {
|
||||||
|
win.blur(); //失去焦点函数
|
||||||
|
win.focus(); //获取焦点函数
|
||||||
|
setTimeout(function () {
|
||||||
|
triggeringProgrammaticBlur = false;
|
||||||
|
}, 100);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if(process.env.NODE_ENV === 'development') win.webContents.openDevTools()
|
if(process.env.NODE_ENV === 'development') win.webContents.openDevTools()
|
||||||
|
|
||||||
ipcMain.on('CLOSE', (event) => {
|
ipcMain.on('CLOSE', (event) => {
|
||||||
|
|
Loading…
Reference in New Issue