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

View File

@ -91,7 +91,7 @@ class API extends DBInstance {
}).show(); }).show();
} }
window.setSize(window.getSize()[0], 60); window.setSize(window.getSize()[0], 60);
// this.removePlugin(null, window); this.removePlugin(null, window);
// 模板文件 // 模板文件
if (!plugin.main) { if (!plugin.main) {
plugin.tplPath = common.dev() plugin.tplPath = common.dev()
@ -129,9 +129,7 @@ class API extends DBInstance {
public removePlugin(e, window) { public removePlugin(e, window) {
runnerInstance.removeView(window); runnerInstance.removeView(window);
setTimeout(() => { this.currentPlugin = null;
this.currentPlugin = null;
}, 100);
} }
public openPluginDevTools() { public openPluginDevTools() {
@ -213,12 +211,15 @@ class API extends DBInstance {
if (!Notification.isSupported()) return; if (!Notification.isSupported()) return;
'string' != typeof body && (body = String(body)); 'string' != typeof body && (body = String(body));
const plugin = this.currentPlugin; const plugin = this.currentPlugin;
if (!plugin) return; console.log('current plugin', this.currentPlugin);
const notify = new Notification({
title: plugin.pluginName, const notification = {
title: plugin ? plugin.pluginName : 'rubick',
body, body,
icon: plugin.logo, icon: plugin ? plugin.logo : null,
}); };
const notify = new Notification(notification);
notify.show(); notify.show();
} }