mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-18 00:34:19 +08:00
@@ -73,23 +73,31 @@ export default () => {
|
||||
|
||||
const init = (plugin, window: BrowserWindow) => {
|
||||
if (view === null || view === undefined) {
|
||||
if (viewInstance.getView(plugin.name) && !commonConst.dev()) {
|
||||
view = viewInstance.getView(plugin.name).view;
|
||||
window.setBrowserView(view);
|
||||
view.inited = true;
|
||||
viewReadyFn(window, plugin);
|
||||
} else {
|
||||
createView(plugin, window);
|
||||
viewInstance.addView(plugin.name, view);
|
||||
}
|
||||
createView(plugin, window);
|
||||
// if (viewInstance.getView(plugin.name) && !commonConst.dev()) {
|
||||
// view = viewInstance.getView(plugin.name).view;
|
||||
// window.setBrowserView(view);
|
||||
// view.inited = true;
|
||||
// viewReadyFn(window, plugin);
|
||||
// } else {
|
||||
// createView(plugin, window);
|
||||
// viewInstance.addView(plugin.name, view);
|
||||
// }
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
require('@electron/remote/main').enable(view.webContents);
|
||||
}
|
||||
};
|
||||
|
||||
const createView = (plugin, window: BrowserWindow) => {
|
||||
const { tplPath, indexPath, development, name, main, pluginSetting, ext } =
|
||||
plugin;
|
||||
const {
|
||||
tplPath,
|
||||
indexPath,
|
||||
development,
|
||||
name,
|
||||
main = 'index.html',
|
||||
pluginSetting,
|
||||
ext,
|
||||
} = plugin;
|
||||
let pluginIndexPath = tplPath || indexPath;
|
||||
let preloadPath;
|
||||
let darkMode;
|
||||
@@ -160,7 +168,7 @@ export default () => {
|
||||
window.removeBrowserView(view);
|
||||
window.setSize(800, 60);
|
||||
executeHooks('PluginOut', null);
|
||||
window.webContents.executeJavaScript(`window.initRubick()`);
|
||||
window.webContents?.executeJavaScript(`window.initRubick()`);
|
||||
view = undefined;
|
||||
};
|
||||
|
||||
@@ -174,7 +182,7 @@ export default () => {
|
||||
} catch(e) {}
|
||||
}
|
||||
`;
|
||||
view.webContents.executeJavaScript(evalJs);
|
||||
view.webContents?.executeJavaScript(evalJs);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user