From 284edbbee1c33f0fdc97f687695ddb6296533166 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 13 Jul 2022 17:39:31 +0800 Subject: [PATCH] refactor: removal of plugin batch operation Signed-off-by: Ryan Wang --- packages/components/package.json | 2 +- packages/shared/package.json | 2 +- pnpm-lock.yaml | 8 ++ src/main.ts | 6 +- src/modules/system/plugins/PluginList.vue | 95 +---------------------- 5 files changed, 17 insertions(+), 96 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index e4198b7c..6442a716 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@halo-dev/components", - "version": "0.0.0-alpha.0", + "version": "0.0.0-alpha.1", "description": "", "files": [ "dist" diff --git a/packages/shared/package.json b/packages/shared/package.json index f517b404..33121cbb 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@halo-dev/admin-shared", - "version": "0.0.0-alpha.1", + "version": "0.0.0-alpha.2", "description": "", "files": [ "dist" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3c58b503..2aa83b95 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,7 @@ importers: '@formkit/vue': 1.0.0-beta.9 '@halo-dev/admin-api': ^1.1.0 '@halo-dev/admin-shared': workspace:* + '@halo-dev/api-client': ^0.0.0 '@halo-dev/components': workspace:* '@rushstack/eslint-patch': ^1.1.4 '@tailwindcss/aspect-ratio': ^0.4.0 @@ -76,6 +77,7 @@ importers: '@formkit/vue': 1.0.0-beta.9_jly5jqkcc2zgnt3crhnp3znzv4 '@halo-dev/admin-api': 1.1.0 '@halo-dev/admin-shared': link:packages/shared + '@halo-dev/api-client': 0.0.0 '@halo-dev/components': link:packages/components '@vueuse/core': 8.9.2_vue@3.2.37 axios: 0.27.2 @@ -149,10 +151,12 @@ importers: packages/shared: specifiers: + '@halo-dev/api-client': ^0.0.0 '@halo-dev/components': workspace:* axios: ^0.27.2 vite-plugin-dts: ^1.2.1 dependencies: + '@halo-dev/api-client': 0.0.0 '@halo-dev/components': link:../components axios: 0.27.2 devDependencies: @@ -1781,6 +1785,10 @@ packages: - debug dev: false + /@halo-dev/api-client/0.0.0: + resolution: {integrity: sha512-DC+0MsnX3e5IkqFFya3gz8JK893hGH+9ohKzLp1b7QqYj1Hvxxc1Nbr77IxvVbktZ14LUZTeHOdWHdqFAFQdvw==} + dev: false + /@halo-dev/logger/1.1.0: resolution: {integrity: sha512-y0jVivYwF8MCVi/OdW2D0LN+GTM5rzMsR/ZmQVfgmKQw7Q7Q+EXPijxON6iCMZnWANGa4NaAcOO9k3ggG8oRwg==} engines: {node: '>=12.0.0'} diff --git a/src/main.ts b/src/main.ts index b0df8bd4..829c8bc3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -126,7 +126,11 @@ async function loadPluginModules() { } if (stylesheet) { - await loadStyle(`http://localhost:8090${stylesheet}`); + try { + await loadStyle(`http://localhost:8090${stylesheet}`); + } catch (e) { + console.error(e); + } } pluginStore.registerPlugin(plugin); diff --git a/src/modules/system/plugins/PluginList.vue b/src/modules/system/plugins/PluginList.vue index 04de922a..b0e8fb0d 100644 --- a/src/modules/system/plugins/PluginList.vue +++ b/src/modules/system/plugins/PluginList.vue @@ -13,26 +13,17 @@ import { VSwitch, VTag, } from "@halo-dev/components"; -import { onMounted, ref, watch } from "vue"; +import { onMounted, ref } from "vue"; import { useRouter } from "vue-router"; import { apiClient } from "@halo-dev/admin-shared"; import type { Plugin } from "@halo-dev/api-client"; import cloneDeep from "lodash.clonedeep"; -const checkedAll = ref(false); const plugins = ref([] as Plugin[]); -const selectedPlugins = ref([]); const router = useRouter(); const dialog = useDialog(); -watch( - () => selectedPlugins.value, - (newValue) => { - checkedAll.value = newValue.length === plugins.value?.length; - } -); - const handleRouteToDetail = (plugin: Plugin) => { router.push({ name: "PluginDetail", @@ -75,46 +66,6 @@ const handleChangeStatus = (plugin: Plugin) => { }); }; -const handleCheckedAllChange = () => { - if (checkedAll.value) { - selectedPlugins.value = plugins.value.map((plugin) => plugin.metadata.name); - } else { - selectedPlugins.value.length = 0; - } -}; - -const handleChangeStatusInBatch = (enable: boolean) => { - const pluginsToUpdate = plugins.value.filter( - (plugin) => - selectedPlugins.value.includes(plugin.metadata.name) && - plugin.spec.enabled !== enable - ); - - if (pluginsToUpdate.length === 0) { - alert("没有需要更新的插件"); - return; - } - - dialog.warning({ - title: `确定要${enable ? "启动" : "停止"}所选插件吗?`, - onConfirm: async () => { - try { - for (const plugin of pluginsToUpdate) { - plugin.spec.enabled = enable; - await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin( - plugin.metadata.name, - plugin - ); - } - } catch (e) { - console.error(e); - } finally { - window.location.reload(); - } - }, - }); -}; - onMounted(handleFetchPlugins);