Skip to content

Commit

Permalink
🔨 fix #377
Browse files Browse the repository at this point in the history
  • Loading branch information
layyback committed Jul 18, 2024
1 parent 2053491 commit ef34452
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
26 changes: 12 additions & 14 deletions src/main/browsers/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,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 {
Expand Down
7 changes: 3 additions & 4 deletions src/main/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class API extends DBInstance {
}

public removePlugin(e, window) {
this.currentPlugin = null;
runnerInstance.removeView(window);
this.currentPlugin = null;
}

public openPluginDevTools() {
Expand Down Expand Up @@ -211,11 +211,10 @@ 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,
title: plugin ? plugin.pluginName : null,
body,
icon: plugin.logo,
icon: plugin ? plugin.logo : null,
});
notify.show();
}
Expand Down

0 comments on commit ef34452

Please sign in to comment.