mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-22 18:22:53 +08:00
✨ 主界面开发&插件运行容器开发&菜单开发
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user