mirror of
https://github.com/rubickCenter/rubick
synced 2025-11-19 04:57:44 +08:00
✨ 适配超级面板
This commit is contained in:
@@ -13,7 +13,6 @@ const pluginInstance = new PluginHandler({
|
||||
global.LOCAL_PLUGINS = {
|
||||
PLUGINS: [],
|
||||
async downloadPlugin(plugin) {
|
||||
console.log(plugin);
|
||||
await pluginInstance.install([plugin.name], { isDev: plugin.isDev });
|
||||
if (plugin.isDev) {
|
||||
// 获取 dev 插件信息
|
||||
@@ -30,7 +29,6 @@ global.LOCAL_PLUGINS = {
|
||||
...pluginInfo,
|
||||
};
|
||||
}
|
||||
console.log(plugin);
|
||||
global.LOCAL_PLUGINS.addPlugin(plugin);
|
||||
return global.LOCAL_PLUGINS.PLUGINS;
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { BrowserView, BrowserWindow, session } from "electron";
|
||||
import path from "path";
|
||||
import commonConst from "../../common/utils/commonConst";
|
||||
import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
|
||||
|
||||
export default () => {
|
||||
let view;
|
||||
@@ -12,10 +13,19 @@ export default () => {
|
||||
};
|
||||
|
||||
const createView = (plugin, window: BrowserWindow) => {
|
||||
let pluginIndexPath = plugin.indexPath;
|
||||
if (!pluginIndexPath) {
|
||||
const pluginPath = path.resolve(baseDir, "node_modules", plugin.name);
|
||||
pluginIndexPath = `file://${path.join(pluginPath, "./", plugin.main)}`;
|
||||
}
|
||||
const preload =
|
||||
commonConst.dev() && plugin.name === "rubick-system-feature"
|
||||
? path.resolve(__static, `../feature/public/preload.js`)
|
||||
: path.resolve(plugin.indexPath.replace("file:", ""), `../`, plugin.preload);
|
||||
: path.resolve(
|
||||
pluginIndexPath.replace("file:", ""),
|
||||
`../`,
|
||||
plugin.preload
|
||||
);
|
||||
|
||||
const ses = session.fromPartition("<" + plugin.name + ">");
|
||||
ses.setPreloads([`${__static}/preload.js`]);
|
||||
@@ -33,7 +43,7 @@ export default () => {
|
||||
},
|
||||
});
|
||||
window.setBrowserView(view);
|
||||
view.webContents.loadURL(plugin.indexPath);
|
||||
view.webContents.loadURL(pluginIndexPath);
|
||||
window.once("ready-to-show", () => {
|
||||
view.setBounds({ x: 0, y: 60, width: 800, height: 600 });
|
||||
view.setAutoResize({ width: true });
|
||||
|
||||
@@ -26,6 +26,11 @@ const API: any = {
|
||||
runnerInstance.removeView(window);
|
||||
runnerInstance.init(plugin, window);
|
||||
API.currentPlugin = plugin;
|
||||
window.webContents.executeJavaScript(
|
||||
`window.setCurrentPlugin(${JSON.stringify({
|
||||
currentPlugin: API.currentPlugin,
|
||||
})})`
|
||||
);
|
||||
},
|
||||
removePlugin(e, window) {
|
||||
API.currentPlugin = null;
|
||||
|
||||
@@ -86,7 +86,6 @@ const openMenu = () => {
|
||||
|
||||
const choosePlugin = () => {
|
||||
const currentChoose = options.value[currentSelect.value];
|
||||
console.log(currentChoose);
|
||||
currentChoose.click();
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -83,6 +83,12 @@ const createPluginManager = (): any => {
|
||||
remote.getGlobal("LOCAL_PLUGINS").updatePlugin(currentPlugin);
|
||||
};
|
||||
|
||||
window.setCurrentPlugin = ({ currentPlugin }) => {
|
||||
console.log(currentPlugin);
|
||||
state.currentPlugin = currentPlugin;
|
||||
setSearchValue("");
|
||||
};
|
||||
|
||||
window.initRubick = () => {
|
||||
state.currentPlugin = {};
|
||||
setSearchValue("");
|
||||
|
||||
1
src/renderer/shims-vue.d.ts
vendored
1
src/renderer/shims-vue.d.ts
vendored
@@ -19,4 +19,5 @@ interface Window {
|
||||
removeSubInput: () => void;
|
||||
updatePlugin: (plugin: any) => void;
|
||||
initRubick: () => void;
|
||||
setCurrentPlugin: (plugin: any) => void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user