♻️ 修改 onPluginEnter 执行时机.

This commit is contained in:
muwoo 2023-10-20 11:23:57 +08:00
parent 7fb299d270
commit 2a1a332fbb
2 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "rubick", "name": "rubick",
"version": "4.0.5", "version": "4.0.6",
"author": "muwoo <2424880409@qq.com>", "author": "muwoo <2424880409@qq.com>",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -175,14 +175,16 @@ export default () => {
const getView = () => view; const getView = () => view;
const executeHooks = (hook, data) => { const executeHooks = (hook, data) => {
if (!view) return; setTimeout(() => {
const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) { if (!view) return;
try { 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) : ''}); window.rubick.hooks.on${hook}(${data ? JSON.stringify(data) : ''});
} catch(e) {} } catch(e) {}
} }
`; `;
view.webContents?.executeJavaScript(evalJs); view.webContents?.executeJavaScript(evalJs);
}, 300);
}; };
return { return {