主界面开发&插件运行容器开发&菜单开发

This commit is contained in:
muwoo
2021-11-26 17:22:45 +08:00
parent 072d57f068
commit 766ba46dcc
59 changed files with 29326 additions and 244 deletions

View File

@@ -0,0 +1,54 @@
import { reactive, toRefs } from "vue";
import { nativeImage, remote } from "electron";
import { appSearch, PluginHandler } from "@/core";
import path from "path";
const appPath = remote.app.getPath("cache");
const createPluginManager = (): any => {
const baseDir = path.join(appPath, "./rubick-plugins");
const pluginInstance = new PluginHandler({
baseDir: baseDir,
});
const state: any = reactive({
appList: [],
plugins: [],
});
const initPlugins = async () => {
state.appList = await appSearch(nativeImage);
};
const addPlugin = (plugin: any) => {
state.plugins.unshift(plugin);
};
const removePlugin = (plugin: any) => {
// todo
};
const searchPlugin = () => {
// todo 先搜索 plugin
// todo 再搜索 app
};
const getPluginInfo = async ({ pluginName, pluginPath }) => {
const pluginInfo = await pluginInstance.getAdapterInfo(pluginName, pluginPath);
return {
...pluginInfo,
indexPath: path.join(pluginPath, "../", pluginInfo.main),
};
};
return {
...toRefs(state),
initPlugins,
addPlugin,
removePlugin,
searchPlugin,
getPluginInfo,
};
};
export default createPluginManager;