🐛 fix hooks triggering issue

This commit is contained in:
layyback 2024-07-18 17:25:11 +08:00
parent 6b9d5182bf
commit 286d9da8d1
2 changed files with 14 additions and 10 deletions

View File

@ -73,7 +73,7 @@ export default () => {
executeHooks('PluginEnter', ext);
executeHooks('PluginReady', ext);
console.log('enterrrr');
const config = await localConfig.getConfig();
const darkMode = config.perf.common.darkMode;
darkMode &&
@ -178,8 +178,11 @@ export default () => {
const removeView = (window: BrowserWindow) => {
if (!view) return;
executeHooks('PluginOut', null);
console.log('PluginOut hooks');
setTimeout(() => {
window.removeBrowserView(view);
console.log('remove view');
if (!view.inDetach) {
window.setBrowserView(null);
view.webContents?.destroy();

View File

@ -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()
@ -129,9 +129,7 @@ class API extends DBInstance {
public removePlugin(e, window) {
runnerInstance.removeView(window);
setTimeout(() => {
this.currentPlugin = null;
}, 100);
this.currentPlugin = null;
}
public openPluginDevTools() {
@ -213,12 +211,15 @@ class API extends DBInstance {
if (!Notification.isSupported()) return;
'string' != typeof body && (body = String(body));
const plugin = this.currentPlugin;
if (!plugin) return;
const notify = new Notification({
title: plugin.pluginName,
console.log('current plugin', this.currentPlugin);
const notification = {
title: plugin ? plugin.pluginName : 'rubick',
body,
icon: plugin.logo,
});
icon: plugin ? plugin.logo : null,
};
const notify = new Notification(notification);
notify.show();
}