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 {