From 2a1a332fbbd51d5ee4e845dc1ae0fdf6061794f4 Mon Sep 17 00:00:00 2001 From: muwoo <2424880409@qq.com> Date: Fri, 20 Oct 2023 11:23:57 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20=E4=BF=AE=E6=94=B9=20onPluginEnter?= =?UTF-8?q?=20=E6=89=A7=E8=A1=8C=E6=97=B6=E6=9C=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main/browsers/runner.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c8b421c..88e764e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubick", - "version": "4.0.5", + "version": "4.0.6", "author": "muwoo <2424880409@qq.com>", "private": true, "scripts": { diff --git a/src/main/browsers/runner.ts b/src/main/browsers/runner.ts index bd41293..2299018 100644 --- a/src/main/browsers/runner.ts +++ b/src/main/browsers/runner.ts @@ -175,14 +175,16 @@ export default () => { const getView = () => view; const executeHooks = (hook, data) => { - if (!view) return; - const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) { - try { + setTimeout(() => { + if (!view) return; + const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) { + try { window.rubick.hooks.on${hook}(${data ? JSON.stringify(data) : ''}); - } catch(e) {} + } catch(e) {} } `; - view.webContents?.executeJavaScript(evalJs); + view.webContents?.executeJavaScript(evalJs); + }, 300); }; return {