This commit is contained in:
muwoo
2023-06-26 10:18:06 +08:00
parent e2ea081d25
commit a827438dbe
4 changed files with 44 additions and 16 deletions

View File

@@ -78,6 +78,7 @@ export default () => {
window.setBrowserView(view);
view.webContents.loadURL(pluginIndexPath);
view.webContents.once('dom-ready', () => {
if (!view) return;
const height = pluginSetting && pluginSetting.height;
window.setSize(800, height || 660);
view.setBounds({ x: 0, y: 60, width: 800, height: height || 600 });

View File

@@ -1,26 +1,24 @@
/* eslint-disable */
import path from "path";
import fs from "fs";
import { PLUGIN_INSTALL_DIR } from "@/common/constans/main";
import path from 'path';
import fs from 'fs';
import { PLUGIN_INSTALL_DIR } from '@/common/constans/main';
export default () => {
// 读取所有插件
const totalPlugins = global.LOCAL_PLUGINS.getLocalPlugins();
let systemPlugins = totalPlugins.filter((plugin) => plugin.pluginType === "system");
let systemPlugins = totalPlugins.filter(
(plugin) => plugin.pluginType === 'system'
);
systemPlugins = systemPlugins.map((plugin) => {
const pluginPath = path.resolve(
PLUGIN_INSTALL_DIR,
"node_modules",
'node_modules',
plugin.name
);
return {
...plugin,
indexPath: path.join(
pluginPath,
"./",
plugin.entry
),
}
indexPath: path.join(pluginPath, './', plugin.entry),
};
});
const hooks = {
@@ -39,14 +37,14 @@ export default () => {
// @ts-ignore
hooks.onReady.forEach((hook: any) => {
try {
hook(ctx);
hook && hook(ctx);
} catch (e) {
console.log(e);
}
});
}
};
return {
triggerReadyHooks
triggerReadyHooks,
};
}
};