mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-28 08:22:48 +08:00
🔨 fix #377
This commit is contained in:
parent
2053491782
commit
ef34452a4f
@ -175,31 +175,29 @@ export default () => {
|
|||||||
|
|
||||||
const removeView = (window: BrowserWindow) => {
|
const removeView = (window: BrowserWindow) => {
|
||||||
if (!view) return;
|
if (!view) return;
|
||||||
window.removeBrowserView(view);
|
|
||||||
if (!view.inDetach) {
|
|
||||||
window.setBrowserView(null);
|
|
||||||
view.webContents?.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// window.setSize(800, 60);
|
|
||||||
executeHooks('PluginOut', null);
|
executeHooks('PluginOut', null);
|
||||||
window.webContents?.executeJavaScript(`window.initRubick()`);
|
setTimeout(() => {
|
||||||
view = undefined;
|
window.removeBrowserView(view);
|
||||||
|
if (!view.inDetach) {
|
||||||
|
window.setBrowserView(null);
|
||||||
|
view.webContents?.destroy();
|
||||||
|
}
|
||||||
|
window.webContents?.executeJavaScript(`window.initRubick()`);
|
||||||
|
view = undefined;
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getView = () => view;
|
const getView = () => view;
|
||||||
|
|
||||||
const executeHooks = (hook, data) => {
|
const executeHooks = (hook, data) => {
|
||||||
setTimeout(() => {
|
if (!view) return;
|
||||||
if (!view) return;
|
const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) {
|
||||||
const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) {
|
|
||||||
try {
|
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 {
|
||||||
|
@ -128,8 +128,8 @@ class API extends DBInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public removePlugin(e, window) {
|
public removePlugin(e, window) {
|
||||||
this.currentPlugin = null;
|
|
||||||
runnerInstance.removeView(window);
|
runnerInstance.removeView(window);
|
||||||
|
this.currentPlugin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public openPluginDevTools() {
|
public openPluginDevTools() {
|
||||||
@ -211,11 +211,10 @@ 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;
|
|
||||||
const notify = new Notification({
|
const notify = new Notification({
|
||||||
title: plugin.pluginName,
|
title: plugin ? plugin.pluginName : null,
|
||||||
body,
|
body,
|
||||||
icon: plugin.logo,
|
icon: plugin ? plugin.logo : null,
|
||||||
});
|
});
|
||||||
notify.show();
|
notify.show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user