- {{ pluginDetail.pluginName }}
-
{{ pluginDetail.version }}
+
+
+
+
![]()
+
+
+ {{ plugin.pluginName }}
+ v{{ plugin.version }}
+
+
{{ plugin.description }}
-
- 开发者:{{ `${pluginDetail.author || "未知"}` }}
-
-
- {{ pluginDetail.description }}
-
-
-
-
-
-
-
+
+
+
+ {{ pluginDetail.pluginName }}
+
{{ pluginDetail.version }}
+
+
+ 开发者:{{ `${pluginDetail.author || "未知"}` }}
+
+
+ {{ pluginDetail.description }}
+
+
+
+
移除
-
{{ item.explain }}
-
+
+
+
+
+
+
{{ item.explain }}
+
- {{ cmd }}
-
+ v-for="cmd in item.cmds"
+ >
+ {{ cmd }}
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -88,7 +94,11 @@ const appPath = remote.app.getPath("cache");
const baseDir = path.join(appPath, "./rubick-plugins");
const store = useStore();
-const localPlugins = computed(() => store.state.localPlugins);
+const localPlugins = computed(() =>
+ store.state.localPlugins.filter(
+ (plugin) => plugin.name !== "rubick-system-feature"
+ )
+);
const updateLocalPlugin = () => store.dispatch("updateLocalPlugin");
const currentSelect = ref(0);
@@ -125,7 +135,14 @@ const deletePlugin = async (plugin) => {
overflow: hidden;
background: #f3efef;
height: calc(~"100vh - 46px");
- display: flex;
+ .container {
+ box-sizing: border-box;
+ width: 100%;
+ overflow: hidden;
+ background: #f3efef;
+ height: 100%;
+ display: flex;
+ }
.installed-list {
width: 40%;
background: #fff;
diff --git a/feature/src/views/market/components/finder.vue b/feature/src/views/market/components/finder.vue
index 94dfda9..06cab15 100644
--- a/feature/src/views/market/components/finder.vue
+++ b/feature/src/views/market/components/finder.vue
@@ -45,7 +45,6 @@ const totalPlugins = computed(() => store.state.totalPlugins);
const data = ref([]);
onBeforeMount(async () => {
- console.log(12312);
data.value = await request.getFinderDetail();
});
diff --git a/feature/src/views/market/components/system.vue b/feature/src/views/market/components/system.vue
new file mode 100644
index 0000000..1f6ec2d
--- /dev/null
+++ b/feature/src/views/market/components/system.vue
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
diff --git a/feature/src/views/market/index.vue b/feature/src/views/market/index.vue
index 147cbd1..2e1f0a6 100644
--- a/feature/src/views/market/index.vue
+++ b/feature/src/views/market/index.vue
@@ -67,9 +67,11 @@ import {
import { reactive, toRefs, computed } from "vue";
import { useStore } from "vuex";
import Finder from "./components/finder.vue";
+import System from "./components/system.vue";
const Components = {
finder: Finder,
+ system: System,
};
const state = reactive({
diff --git a/src/common/constans/index.js b/src/common/constans/index.js
deleted file mode 100644
index 7e679cb..0000000
--- a/src/common/constans/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-const APP_FINDER_PATH = process.platform === 'darwin' ? ['/System/Applications', '/Applications', '/System/Library/PreferencePanes'] : []
-
-export {
- APP_FINDER_PATH
-}
diff --git a/src/common/constans/main.ts b/src/common/constans/main.ts
new file mode 100644
index 0000000..95b42a0
--- /dev/null
+++ b/src/common/constans/main.ts
@@ -0,0 +1,8 @@
+import { app } from "electron";
+import path from "path";
+
+const appPath = app.getPath("cache");
+
+const PLUGIN_INSTALL_DIR = path.join(appPath, "./rubick-plugins");
+
+export { PLUGIN_INSTALL_DIR };
diff --git a/src/common/constans/renderer.ts b/src/common/constans/renderer.ts
new file mode 100644
index 0000000..ba1e559
--- /dev/null
+++ b/src/common/constans/renderer.ts
@@ -0,0 +1,8 @@
+import { remote } from "electron";
+import path from "path";
+
+const appPath = remote.app.getPath("cache");
+
+const PLUGIN_INSTALL_DIR = path.join(appPath, "./rubick-plugins");
+
+export { PLUGIN_INSTALL_DIR };
diff --git a/src/common/utils/localPlugin.ts b/src/common/utils/localPlugin.ts
index c56e232..fd9b8de 100644
--- a/src/common/utils/localPlugin.ts
+++ b/src/common/utils/localPlugin.ts
@@ -1,21 +1,36 @@
import path from "path";
import fs from "fs";
import getLocalDataFile from "./getLocalDataFile";
-import { app } from "electron";
import { PluginHandler } from "@/core";
+import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
const configPath = path.join(getLocalDataFile(), "./rubick-local-plugin.json");
-const appPath = app.getPath("cache");
-const baseDir = path.join(appPath, "./rubick-plugins");
const pluginInstance = new PluginHandler({
- baseDir: baseDir,
+ baseDir,
});
global.LOCAL_PLUGINS = {
PLUGINS: [],
async downloadPlugin(plugin) {
- await pluginInstance.install([plugin.name]);
+ console.log(plugin);
+ await pluginInstance.install([plugin.name], { isDev: plugin.isDev });
+ if (plugin.isDev) {
+ // 获取 dev 插件信息
+ const pluginPath = path.resolve(
+ baseDir,
+ "node_modules",
+ plugin.name
+ );
+ const pluginInfo = JSON.parse(
+ fs.readFileSync(path.join(pluginPath, "./package.json"), "utf8")
+ );
+ plugin = {
+ ...plugin,
+ ...pluginInfo,
+ };
+ }
+ console.log(plugin);
global.LOCAL_PLUGINS.addPlugin(plugin);
return global.LOCAL_PLUGINS.PLUGINS;
},
@@ -60,7 +75,7 @@ global.LOCAL_PLUGINS = {
fs.writeFileSync(configPath, JSON.stringify(global.LOCAL_PLUGINS.PLUGINS));
},
async deletePlugin(plugin) {
- await pluginInstance.uninstall([plugin.name]);
+ await pluginInstance.uninstall([plugin.name], { isDev: plugin.isDev });
global.LOCAL_PLUGINS.PLUGINS = global.LOCAL_PLUGINS.PLUGINS.filter((p) => plugin.name !== p.name);
fs.writeFileSync(configPath, JSON.stringify(global.LOCAL_PLUGINS.PLUGINS));
return global.LOCAL_PLUGINS.PLUGINS;
diff --git a/src/core/plugin-handler/index.ts b/src/core/plugin-handler/index.ts
index 939d5d6..7ac8894 100644
--- a/src/core/plugin-handler/index.ts
+++ b/src/core/plugin-handler/index.ts
@@ -68,8 +68,8 @@ class AdapterHandler {
}
// 安装并启动插件
- async install(adapters: Array
) {
- const installCmd = "install";
+ async install(adapters: Array, options: { isDev: boolean }) {
+ const installCmd = options.isDev ? "link" : "install";
// 安装
await this.execCommand(installCmd, adapters);
}
@@ -110,11 +110,13 @@ class AdapterHandler {
/**
* 卸载指定插件
* @param {...string[]} adapters 插件名称
+ * @param options
* @memberof AdapterHandler
*/
- async uninstall(adapters: string[]) {
+ async uninstall(adapters: string[], options: { isDev: boolean }) {
+ const installCmd = options.isDev ? "unlink" : "uninstall";
// 卸载插件
- await this.execCommand("uninstall", adapters);
+ await this.execCommand(installCmd, adapters);
}
/**
diff --git a/src/main/common/api.ts b/src/main/common/api.ts
index 96ee03a..1856ccf 100644
--- a/src/main/common/api.ts
+++ b/src/main/common/api.ts
@@ -22,11 +22,13 @@ const API: any = {
currentPlugin: null,
DBKEY: "RUBICK_DB_DEFAULT",
openPlugin({ plugin }, window) {
+ if (API.currentPlugin && API.currentPlugin.name === plugin.name) return;
runnerInstance.removeView(window);
runnerInstance.init(plugin, window);
API.currentPlugin = plugin;
},
removePlugin(e, window) {
+ API.currentPlugin = null;
runnerInstance.removeView(window);
},
hideMainWindow(arg, window) {
diff --git a/src/main/common/registerySystemPlugin.ts b/src/main/common/registerySystemPlugin.ts
index 75b47f1..fe138b3 100644
--- a/src/main/common/registerySystemPlugin.ts
+++ b/src/main/common/registerySystemPlugin.ts
@@ -1,19 +1,15 @@
/* eslint-disable */
import path from "path";
-import {app} from "electron";
import fs from "fs";
-
-const appPath = app.getPath("cache");
+import { PLUGIN_INSTALL_DIR } from "@/common/constans/main";
export default () => {
// 读取所有插件
const totalPlugins = global.LOCAL_PLUGINS.getLocalPlugins();
let systemPlugins = totalPlugins.filter((plugin) => plugin.pluginType === "system");
- const baseDir = path.join(appPath, "./rubick-plugins");
-
systemPlugins = systemPlugins.map((plugin) => {
const pluginPath = path.resolve(
- baseDir,
+ PLUGIN_INSTALL_DIR,
"node_modules",
plugin.name
);
diff --git a/src/renderer/components/search.vue b/src/renderer/components/search.vue
index dac9751..968b164 100644
--- a/src/renderer/components/search.vue
+++ b/src/renderer/components/search.vue
@@ -48,6 +48,7 @@ const props = defineProps({
});
const changeValue = (e) => {
+ if (props.currentPlugin.name === "rubick-system-feature") return;
emit("onSearch", e);
};
diff --git a/src/renderer/plugins-manager/index.ts b/src/renderer/plugins-manager/index.ts
index 4411eb5..d3f556a 100644
--- a/src/renderer/plugins-manager/index.ts
+++ b/src/renderer/plugins-manager/index.ts
@@ -6,13 +6,11 @@ import commonConst from "@/common/utils/commonConst";
import { execSync } from "child_process";
import searchManager from "./search";
import optionsManager from "./options";
-
-const appPath = remote.app.getPath("cache");
+import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/renderer";
const createPluginManager = (): any => {
- const baseDir = path.join(appPath, "./rubick-plugins");
const pluginInstance = new PluginHandler({
- baseDir: baseDir,
+ baseDir,
});
const state: any = reactive({
@@ -54,7 +52,6 @@ const createPluginManager = (): any => {
const { searchValue, onSearch, setSearchValue, placeholder } = searchManager();
const { options } = optionsManager({
searchValue,
- baseDir,
appList,
openPlugin,
currentPlugin: toRefs(state).currentPlugin,
diff --git a/src/renderer/plugins-manager/options.ts b/src/renderer/plugins-manager/options.ts
index d20448b..f61a769 100644
--- a/src/renderer/plugins-manager/options.ts
+++ b/src/renderer/plugins-manager/options.ts
@@ -2,6 +2,7 @@ import { ref, toRaw, toRefs, watch } from "vue";
import throttle from "lodash.throttle";
import { remote } from "electron";
import path from "path";
+import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/renderer";
function searchKeyValues(lists, value) {
return lists.filter((item) => {
@@ -12,7 +13,7 @@ function searchKeyValues(lists, value) {
});
}
-const optionsManager = ({ searchValue, baseDir, appList, openPlugin, currentPlugin }) => {
+const optionsManager = ({ searchValue, appList, openPlugin, currentPlugin }) => {
const optionsRef = ref([]);
watch(searchValue, () => search(searchValue.value));