chore: API改为类,成员函数变量增加static关键字 & yarn lint

This commit is contained in:
noe
2022-09-24 11:44:04 +08:00
parent 17436b0e9a
commit cfc10a6aee
25 changed files with 727 additions and 681 deletions

View File

@@ -11,7 +11,7 @@ import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/renderer";
const createPluginManager = (): any => {
const pluginInstance = new PluginHandler({
baseDir
baseDir,
});
const state: any = reactive({
@@ -19,7 +19,7 @@ const createPluginManager = (): any => {
plugins: [],
localPlugins: [],
currentPlugin: {},
pluginLoading: false
pluginLoading: false,
});
const appList = ref([]);
@@ -28,12 +28,12 @@ const createPluginManager = (): any => {
appList.value = await appSearch(nativeImage);
};
const loadPlugin = plugin => {
const loadPlugin = (plugin) => {
state.pluginLoading = true;
state.currentPlugin = plugin;
};
const openPlugin = plugin => {
const openPlugin = (plugin) => {
if (plugin.pluginType === "ui" || plugin.pluginType === "system") {
if (state.currentPlugin && state.currentPlugin.name === plugin.name) {
return;
@@ -47,10 +47,10 @@ const createPluginManager = (): any => {
ext: plugin.ext || {
code: plugin.feature.code,
type: plugin.cmd.type || "text",
payload: null
}
payload: null,
},
})
)
),
});
setSearchValue("");
}
@@ -66,12 +66,12 @@ const createPluginManager = (): any => {
searchFocus,
clipboardFile,
clearClipboardFile,
readClipboardContent
readClipboardContent,
} = optionsManager({
searchValue,
appList,
openPlugin,
currentPlugin: toRefs(state).currentPlugin
currentPlugin: toRefs(state).currentPlugin,
});
// plugin operation
const getPluginInfo = async ({ pluginName, pluginPath }) => {
@@ -84,11 +84,11 @@ const createPluginManager = (): any => {
icon: pluginInfo.logo,
indexPath: commonConst.dev()
? "http://localhost:8081/#/"
: `file://${path.join(pluginPath, "../", pluginInfo.main)}`
: `file://${path.join(pluginPath, "../", pluginInfo.main)}`,
};
};
const changeSelect = select => {
const changeSelect = (select) => {
state.currentPlugin = select;
};
@@ -99,8 +99,8 @@ const createPluginManager = (): any => {
const removePlugin = (plugin: any) => {
// todo
};
window.loadPlugin = plugin => loadPlugin(plugin);
window.loadPlugin = (plugin) => loadPlugin(plugin);
window.updatePlugin = ({ currentPlugin }: any) => {
state.currentPlugin = currentPlugin;
@@ -137,7 +137,7 @@ const createPluginManager = (): any => {
searchFocus,
clipboardFile,
clearClipboardFile,
readClipboardContent
readClipboardContent,
};
};