From 3e3585f5971a41d0e8ac57c125d1f378ca998718 Mon Sep 17 00:00:00 2001 From: qinruihua Date: Wed, 24 Feb 2021 21:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6=E5=9C=A8ma?= =?UTF-8?q?cOS=E4=B8=8A=E8=BF=9B=E5=85=A5=E6=8F=92=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=97=AA=E9=80=80=E7=9A=84bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/public/preload.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/public/preload.js b/ui/public/preload.js index a23fd57..68970ab 100644 --- a/ui/public/preload.js +++ b/ui/public/preload.js @@ -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) } })