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

This commit is contained in:
muwoo
2021-11-30 15:44:56 +08:00
parent 766ba46dcc
commit c2f43bea39
10 changed files with 320 additions and 218 deletions

View File

@@ -1,7 +1,8 @@
import { reactive, toRefs } from "vue";
import { reactive, toRefs, nextTick } from "vue";
import { nativeImage, remote } from "electron";
import { appSearch, PluginHandler } from "@/core";
import path from "path";
import throttle from "lodash.throttle";
const appPath = remote.app.getPath("cache");
@@ -14,6 +15,8 @@ const createPluginManager = (): any => {
const state: any = reactive({
appList: [],
plugins: [],
options: [],
searchValue: "",
});
const initPlugins = async () => {
@@ -28,10 +31,47 @@ const createPluginManager = (): any => {
// todo
};
const searchPlugin = () => {
const onSearch = throttle((e) => {
const value = e.target.value;
state.searchValue = value;
if (!value) return;
// todo 先搜索 plugin
// todo 再搜索 app
};
let options: any = [];
const descMap = new Map();
options = [
...options,
...state.appList
.filter((plugin) => {
if (!descMap.get(plugin)) {
descMap.set(plugin, true);
let has = false;
plugin.keyWords.some((keyWord) => {
if (
keyWord
.toLocaleUpperCase()
.indexOf(value.toLocaleUpperCase()) >= 0
) {
has = keyWord;
plugin.name = keyWord;
return true;
}
return false;
});
return has;
} else {
return false;
}
})
.map((plugin) => {
plugin.click = () => {
_openPlugin({ plugin });
};
return plugin;
}),
];
state.options = options;
}, 500);
const getPluginInfo = async ({ pluginName, pluginPath }) => {
const pluginInfo = await pluginInstance.getAdapterInfo(pluginName, pluginPath);
@@ -41,12 +81,16 @@ const createPluginManager = (): any => {
};
};
const _openPlugin = ({ plugin }) => {
//
};
return {
...toRefs(state),
initPlugins,
addPlugin,
removePlugin,
searchPlugin,
onSearch,
getPluginInfo,
};
};