From d583e55390100b65b52378c9ab6182301a2c934a Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 23 Jul 2022 20:42:13 +0800 Subject: [PATCH] feat: add support for uploading plugins (#590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ryan Wang #### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 添加上传插件的支持。 see https://github.com/halo-dev/halo/pull/2271 #### Which issue(s) this PR fixes: None #### Screenshots: image image #### Special notes for your reviewer: 可以使用以下插件仓库中 Actions 构建的 JAR 测试: - https://github.com/halo-sigs/plugin-links/actions - https://github.com/halo-sigs/plugin-meilisearch/actions - https://github.com/halo-sigs/plugin-template/actions /cc @halo-dev/sig-halo-admin /cc @halo-dev/sig-halo #### Does this PR introduce a user-facing change? ```release-note None ``` --- packages/shared/package.json | 2 +- packages/shared/src/utils/api-client.ts | 18 ++--- pnpm-lock.yaml | 8 +- src/modules/system/plugins/PluginList.vue | 14 +++- .../plugins/components/PluginInstallModal.vue | 79 +++++++++++++++++++ 5 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 src/modules/system/plugins/components/PluginInstallModal.vue diff --git a/packages/shared/package.json b/packages/shared/package.json index 8df20229..3e264361 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -35,7 +35,7 @@ "homepage": "https://github.com/halo-dev/halo-admin/tree/next/shared/components#readme", "license": "MIT", "dependencies": { - "@halo-dev/api-client": "^0.0.3", + "@halo-dev/api-client": "^0.0.4", "@halo-dev/components": "workspace:*", "axios": "^0.27.2" }, diff --git a/packages/shared/src/utils/api-client.ts b/packages/shared/src/utils/api-client.ts index 5d87f360..64d63c84 100644 --- a/packages/shared/src/utils/api-client.ts +++ b/packages/shared/src/utils/api-client.ts @@ -1,18 +1,17 @@ import { - PluginHaloRunV1alpha1PluginApi, - V1alpha1UserApi, + ApiHaloRunV1alpha1PluginApi, ApiHaloRunV1alpha1UserApi, + PluginHaloRunV1alpha1PluginApi, + PluginHaloRunV1alpha1ReverseProxyApi, V1alpha1ConfigMapApi, V1alpha1PersonalAccessTokenApi, - V1alpha1RoleBindingApi, V1alpha1RoleApi, + V1alpha1RoleBindingApi, V1alpha1SettingApi, - PluginHaloRunV1alpha1ReverseProxyApi, - CoreHaloRunV1alpha1LinkApi, - CoreHaloRunV1alpha1LinkGroupApi, + V1alpha1UserApi, } from "@halo-dev/api-client"; -import axios from "axios"; import type { AxiosInstance } from "axios"; +import axios from "axios"; let apiUrl: string | undefined; const axiosInstance = axios.create({ @@ -61,10 +60,11 @@ function setupApiClient(axios: AxiosInstance) { user: new V1alpha1UserApi(undefined, apiUrl, axios), // TODO optional - link: new CoreHaloRunV1alpha1LinkApi(undefined, apiUrl, axios), - linkGroup: new CoreHaloRunV1alpha1LinkGroupApi(undefined, apiUrl, axios), + // link: new CoreHaloRunV1alpha1LinkApi(undefined, apiUrl, axios), + // linkGroup: new CoreHaloRunV1alpha1LinkGroupApi(undefined, apiUrl, axios), }, user: new ApiHaloRunV1alpha1UserApi(undefined, apiUrl, axios), + plugin: new ApiHaloRunV1alpha1PluginApi(undefined, apiUrl, axios), }; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e182751f..8e4dfe74 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -172,12 +172,12 @@ importers: packages/shared: specifiers: - '@halo-dev/api-client': ^0.0.3 + '@halo-dev/api-client': ^0.0.4 '@halo-dev/components': workspace:* axios: ^0.27.2 vite-plugin-dts: ^1.3.1 dependencies: - '@halo-dev/api-client': 0.0.3 + '@halo-dev/api-client': 0.0.4 '@halo-dev/components': link:../components axios: 0.27.2 devDependencies: @@ -1873,6 +1873,10 @@ packages: resolution: {integrity: sha512-ybtVcjeeFqOldPIKRrm3socfGtbSR5GL+MXVmkSJwD2fCwT9OiXEvs3cgceWceIZI0Ug7AEKwxbcO+ZfOmDlYA==} dev: false + /@halo-dev/api-client/0.0.4: + resolution: {integrity: sha512-rNkQJWBL+1du/wfe70cqc7YczcQMTlQBQb0xmBLXCvQvxIlANpEVo0YKlbMXBvznaec2MYUFu7aF0b8hi4GEDw==} + 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/modules/system/plugins/PluginList.vue b/src/modules/system/plugins/PluginList.vue index 765f9d84..fc4ec242 100644 --- a/src/modules/system/plugins/PluginList.vue +++ b/src/modules/system/plugins/PluginList.vue @@ -13,6 +13,7 @@ import { VSwitch, VTag, } from "@halo-dev/components"; +import PluginInstallModal from "./components/PluginInstallModal.vue"; import { onMounted, ref } from "vue"; import { useRouter } from "vue-router"; import { apiClient } from "@halo-dev/admin-shared"; @@ -20,6 +21,7 @@ import type { Plugin } from "@halo-dev/api-client"; import cloneDeep from "lodash.clonedeep"; const plugins = ref([] as Plugin[]); +const pluginInstall = ref(false); const router = useRouter(); const dialog = useDialog(); @@ -69,12 +71,22 @@ const handleChangeStatus = (plugin: Plugin) => { onMounted(handleFetchPlugins);