Skip to content

Commit

Permalink
修复插件在macOS上进入插件时出现闪退的bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinruihua authored and qinruihua committed Feb 24, 2021
1 parent 3310fa0 commit 3e3585f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ui/public/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,18 @@ utools.onPluginEnter(({ code, type, payload, optional }) => {

// 窗口不可见的时候退出插件
document.addEventListener('visibilitychange', function () {
console.log('document.hidden=', document.hidden)
if (document.hidden && !window.preventPluginOut) {
utools.outPlugin()
console.log('退出插件.')
// macos 上utools存在一个诡异的bug
// 进入插件时,document.hidden先为true,然后再变为false
// 所以这里间隔200毫秒之后再来判断窗口是否可见
// 避免进入插件时出现闪退的情况
setTimeout(() => {
if (document.hidden && !window.preventPluginOut) {
utools.outPlugin()
console.log('退出插件.')
}
}, 200)
}
})

Expand Down

0 comments on commit 3e3585f

Please sign in to comment.