mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-06 10:34:08 +08:00
🐛 fix hooks triggering issue
This commit is contained in:
parent
2053491782
commit
6b9d5182bf
@ -72,6 +72,8 @@ export default () => {
|
||||
view.setAutoResize({ width: true, height: true });
|
||||
executeHooks('PluginEnter', ext);
|
||||
executeHooks('PluginReady', ext);
|
||||
console.log('enterrrr');
|
||||
|
||||
const config = await localConfig.getConfig();
|
||||
const darkMode = config.perf.common.darkMode;
|
||||
darkMode &&
|
||||
@ -175,31 +177,29 @@ export default () => {
|
||||
|
||||
const removeView = (window: BrowserWindow) => {
|
||||
if (!view) return;
|
||||
window.removeBrowserView(view);
|
||||
if (!view.inDetach) {
|
||||
window.setBrowserView(null);
|
||||
view.webContents?.destroy();
|
||||
}
|
||||
|
||||
// window.setSize(800, 60);
|
||||
executeHooks('PluginOut', null);
|
||||
window.webContents?.executeJavaScript(`window.initRubick()`);
|
||||
view = undefined;
|
||||
setTimeout(() => {
|
||||
window.removeBrowserView(view);
|
||||
if (!view.inDetach) {
|
||||
window.setBrowserView(null);
|
||||
view.webContents?.destroy();
|
||||
}
|
||||
window.webContents?.executeJavaScript(`window.initRubick()`);
|
||||
view = undefined;
|
||||
}, 0);
|
||||
};
|
||||
|
||||
const getView = () => view;
|
||||
|
||||
const executeHooks = (hook, data) => {
|
||||
setTimeout(() => {
|
||||
if (!view) return;
|
||||
const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) {
|
||||
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) {}
|
||||
}
|
||||
`;
|
||||
view.webContents?.executeJavaScript(evalJs);
|
||||
}, 300);
|
||||
view.webContents?.executeJavaScript(evalJs);
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -91,7 +91,7 @@ class API extends DBInstance {
|
||||
}).show();
|
||||
}
|
||||
window.setSize(window.getSize()[0], 60);
|
||||
this.removePlugin(null, window);
|
||||
// this.removePlugin(null, window);
|
||||
// 模板文件
|
||||
if (!plugin.main) {
|
||||
plugin.tplPath = common.dev()
|
||||
@ -128,8 +128,10 @@ class API extends DBInstance {
|
||||
}
|
||||
|
||||
public removePlugin(e, window) {
|
||||
this.currentPlugin = null;
|
||||
runnerInstance.removeView(window);
|
||||
setTimeout(() => {
|
||||
this.currentPlugin = null;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
public openPluginDevTools() {
|
||||
|
@ -1,8 +1,5 @@
|
||||
<template>
|
||||
<div
|
||||
id="components-layout"
|
||||
@mousedown="onMouseDown"
|
||||
>
|
||||
<div id="components-layout" @mousedown="onMouseDown">
|
||||
<Search
|
||||
:currentPlugin="currentPlugin"
|
||||
@changeCurrent="changeIndex"
|
||||
@ -94,7 +91,9 @@ watch(
|
||||
window.rubick.setExpendHeight(
|
||||
getWindowHeight(
|
||||
options.value,
|
||||
(pluginLoading.value || !config.value.perf.common.history) ? [] : pluginHistory.value
|
||||
pluginLoading.value || !config.value.perf.common.history
|
||||
? []
|
||||
: pluginHistory.value
|
||||
)
|
||||
);
|
||||
},
|
||||
@ -161,7 +160,9 @@ const choosePlugin = (plugin) => {
|
||||
});
|
||||
if (hasRemove) {
|
||||
const result = window.rubick.db.get(PLUGIN_HISTORY) || {};
|
||||
const history = result.data.filter(item => item.originName !== currentChoose.originName);
|
||||
const history = result.data.filter(
|
||||
(item) => item.originName !== currentChoose.originName
|
||||
);
|
||||
setPluginHistory(history);
|
||||
return message.warning('插件已被卸载!');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user