From a0eeb17d730e0c09d6685051814440494567e064 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 8 Apr 2025 22:56:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=8F=92=E4=BB=B6=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E4=B8=8E=E8=BF=90=E8=A1=8C=E6=B5=8B=E8=AF=95beta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/plugin/registry.ts | 13 +++- .../components/code-editor/import-works.ts | 1 - .../src/components/code-editor/index.vue | 17 ++--- .../src/components/code-editor/workers.ts | 1 - packages/ui/certd-client/src/router/index.ts | 2 +- .../ui/certd-client/src/router/resolve.ts | 4 +- .../src/router/source/modules/sys.ts | 4 + .../src/vben/layouts/basic/layout.vue | 14 ++-- .../src/vben/preferences/config.ts | 28 +++---- .../src/vben/stores/modules/tabbar.ts | 76 +++++++++---------- .../certd/pipeline/cert-upload/index.vue | 2 - .../src/views/certd/pipeline/index.vue | 8 +- .../certd-client/src/views/sys/plugin/api.ts | 8 ++ .../src/views/sys/plugin/edit.vue | 40 +++++++--- .../src/views/sys/plugin/index.vue | 4 +- .../sys/plugin/plugin-controller.ts | 7 +- .../modules/plugin/service/plugin-service.ts | 62 +++++++++------ 17 files changed, 169 insertions(+), 122 deletions(-) diff --git a/packages/core/pipeline/src/plugin/registry.ts b/packages/core/pipeline/src/plugin/registry.ts index 1411053b..b2fcac60 100644 --- a/packages/core/pipeline/src/plugin/registry.ts +++ b/packages/core/pipeline/src/plugin/registry.ts @@ -3,14 +3,23 @@ import { AbstractTaskPlugin } from "./api.js"; import { pluginGroups } from "./group.js"; const onRegister = ({ key, value }: OnRegisterContext) => { + //如果有相同名字的先移除 + + for (const group of Object.values(pluginGroups)) { + const index = group.plugins.findIndex(plugin => plugin.name === key); + if (index > -1) { + group.plugins.splice(index, 1); + } + } + const group = value?.define?.group as string; if (group) { if (pluginGroups.hasOwnProperty(group)) { // @ts-ignore pluginGroups[group].plugins.push(value.define); - } else { - pluginGroups.other.plugins.push(value.define); + return; } } + pluginGroups.other.plugins.push(value.define); }; export const pluginRegistry = createRegistry("plugin", onRegister); diff --git a/packages/ui/certd-client/src/components/code-editor/import-works.ts b/packages/ui/certd-client/src/components/code-editor/import-works.ts index ee04a655..8b67ff01 100644 --- a/packages/ui/certd-client/src/components/code-editor/import-works.ts +++ b/packages/ui/certd-client/src/components/code-editor/import-works.ts @@ -26,7 +26,6 @@ export function registerWorker(name: string, worker: any) { window.MonacoEnvironment = { //@ts-ignore getWorker(_, label) { - debugger; const custom = WorkerBucket[label]; if (custom) { return new custom(); diff --git a/packages/ui/certd-client/src/components/code-editor/index.vue b/packages/ui/certd-client/src/components/code-editor/index.vue index 8da38344..8219f5f0 100644 --- a/packages/ui/certd-client/src/components/code-editor/index.vue +++ b/packages/ui/certd-client/src/components/code-editor/index.vue @@ -83,17 +83,6 @@ const emitValue = lodashDebounce((value: any) => { emits("update:modelValue", value); }, props.debounce || 500); -// watch( -// () => { -// return props.modelValue; -// }, -// (value: string) => { -// if (instanceRef.value && value !== instanceRef.value.getValue()) { -// // instanceRef.value.setValue(value); -// } -// } -// ); - async function createEditor(ctx: EditorCodeCtx) { disposeEditor(); const instance = monaco.editor.create(monacoRef.value, { @@ -121,6 +110,9 @@ async function createEditor(ctx: EditorCodeCtx) { instanceRef = instance; ctx.instance = instance; emits("ready", ctx); + if (props.modelValue) { + instanceRef.setValue(props.modelValue); + } return instance; } @@ -224,6 +216,9 @@ watch( editor.setValue(newValue); } } + }, + { + immediate: true, } ); diff --git a/packages/ui/certd-client/src/components/code-editor/workers.ts b/packages/ui/certd-client/src/components/code-editor/workers.ts index 31cd3aa0..a933d2a4 100644 --- a/packages/ui/certd-client/src/components/code-editor/workers.ts +++ b/packages/ui/certd-client/src/components/code-editor/workers.ts @@ -49,7 +49,6 @@ export async function initWorkers() { } else if (label === "typescript" || label === "javascript") { return new tsWorker.default(); } else if (label === "yaml" || label === "yml") { - debugger; //@ts-ignore return new yamlWorker.default(); } diff --git a/packages/ui/certd-client/src/router/index.ts b/packages/ui/certd-client/src/router/index.ts index 249517fd..c5769ecf 100644 --- a/packages/ui/certd-client/src/router/index.ts +++ b/packages/ui/certd-client/src/router/index.ts @@ -65,7 +65,7 @@ export default router; // // 多页控制 打开新的页面 // const pageStore = usePageStore(); // // for (const item of to.matched) { -// // pageStore.keepAlivePush(item.name); +// // pageStore.cachePush(item.name); // // } // pageStore.open(to); // // 更改标题 diff --git a/packages/ui/certd-client/src/router/resolve.ts b/packages/ui/certd-client/src/router/resolve.ts index ddeb6e49..c8d2bf8d 100644 --- a/packages/ui/certd-client/src/router/resolve.ts +++ b/packages/ui/certd-client/src/router/resolve.ts @@ -58,7 +58,7 @@ function transformOneResource(resource: any, parent: any) { } return { menu, - route + route, }; } @@ -79,7 +79,7 @@ export const buildMenusAndRouters = (resources: any, parent: any = null) => { setIndex(menus); return { routes, - menus + menus, }; }; diff --git a/packages/ui/certd-client/src/router/source/modules/sys.ts b/packages/ui/certd-client/src/router/source/modules/sys.ts index aeca062f..dd668a30 100644 --- a/packages/ui/certd-client/src/router/source/modules/sys.ts +++ b/packages/ui/certd-client/src/router/source/modules/sys.ts @@ -47,6 +47,7 @@ export const sysResources = [ meta: { icon: "ion:earth-outline", permission: "sys:settings:view", + cache: true, }, }, { @@ -110,6 +111,7 @@ export const sysResources = [ meta: { icon: "ion:extension-puzzle-outline", permission: "sys:settings:view", + cache: true, }, }, { @@ -121,6 +123,7 @@ export const sysResources = [ isMenu: false, icon: "ion:extension-puzzle", permission: "sys:settings:view", + cache: true, }, }, { @@ -145,6 +148,7 @@ export const sysResources = [ meta: { icon: "ion:golf-outline", permission: "sys:settings:view", + cache: true, }, }, { diff --git a/packages/ui/certd-client/src/vben/layouts/basic/layout.vue b/packages/ui/certd-client/src/vben/layouts/basic/layout.vue index a6c8a7d3..7ab1886b 100644 --- a/packages/ui/certd-client/src/vben/layouts/basic/layout.vue +++ b/packages/ui/certd-client/src/vben/layouts/basic/layout.vue @@ -88,7 +88,7 @@ function wrapperMenus(menus: MenuRecordRaw[], deep: boolean = true) { ? mapTree(menus, (item: any) => { return { ...cloneDeep(item), name: $t(item.name) }; }) - : menus.map((item) => { + : menus.map(item => { return { ...cloneDeep(item), name: $t(item.name) }; }); } @@ -96,8 +96,8 @@ function wrapperMenus(menus: MenuRecordRaw[], deep: boolean = true) { function toggleSidebar() { updatePreferences({ sidebar: { - hidden: !preferences.sidebar.hidden - } + hidden: !preferences.sidebar.hidden, + }, }); } @@ -107,12 +107,12 @@ function clearPreferencesAndLogout() { watch( () => preferences.app.layout, - async (val) => { + async val => { if (val === "sidebar-mixed-nav" && preferences.sidebar.hidden) { updatePreferences({ sidebar: { - hidden: false - } + hidden: false, + }, }); } } @@ -124,7 +124,7 @@ watch(i18n.global.locale, refresh, { flush: "post" }); const slots: SetupContext["slots"] = useSlots(); const headerSlots = computed(() => { - return Object.keys(slots).filter((key) => key.startsWith("header-")); + return Object.keys(slots).filter(key => key.startsWith("header-")); }); diff --git a/packages/ui/certd-client/src/vben/preferences/config.ts b/packages/ui/certd-client/src/vben/preferences/config.ts index e4d6e4a0..25404657 100644 --- a/packages/ui/certd-client/src/vben/preferences/config.ts +++ b/packages/ui/certd-client/src/vben/preferences/config.ts @@ -20,14 +20,14 @@ const defaultPreferences: Preferences = { loginExpiredMode: "page", name: "", preferencesButtonPosition: "auto", - watermark: false + watermark: false, }, breadcrumb: { enable: true, hideOnlyOne: false, showHome: false, showIcon: true, - styleType: "normal" + styleType: "normal", }, copyright: { companyName: "greper", @@ -36,33 +36,33 @@ const defaultPreferences: Preferences = { enable: false, icp: "", icpLink: "", - settingShow: false + settingShow: false, }, footer: { enable: true, - fixed: false + fixed: false, }, header: { enable: true, hidden: false, menuAlign: "start", - mode: "fixed" + mode: "fixed", }, logo: { enable: true, - source: "./static/images/logo/logo.svg" + source: "./static/images/logo/logo.svg", }, navigation: { accordion: true, split: true, - styleType: "rounded" + styleType: "rounded", }, shortcutKeys: { enable: true, globalLockScreen: true, globalLogout: true, globalPreferences: true, - globalSearch: true + globalSearch: true, }, sidebar: { autoActivateChild: true, @@ -72,7 +72,7 @@ const defaultPreferences: Preferences = { expandOnHover: true, extraCollapse: false, hidden: false, - width: 224 + width: 224, }, tabbar: { draggable: true, @@ -86,7 +86,7 @@ const defaultPreferences: Preferences = { showMaximize: true, showMore: true, styleType: "chrome", - wheelable: true + wheelable: true, }, theme: { builtinType: "default", @@ -97,13 +97,13 @@ const defaultPreferences: Preferences = { mode: "light", radius: "0.5", semiDarkHeader: false, - semiDarkSidebar: false + semiDarkSidebar: false, }, transition: { enable: true, loading: false, name: "fade-slide", - progress: true + progress: true, }, widget: { fullscreen: true, @@ -113,8 +113,8 @@ const defaultPreferences: Preferences = { notification: false, refresh: true, sidebarToggle: true, - themeToggle: true - } + themeToggle: true, + }, }; export { defaultPreferences }; diff --git a/packages/ui/certd-client/src/vben/stores/modules/tabbar.ts b/packages/ui/certd-client/src/vben/stores/modules/tabbar.ts index 18fcae7b..0e02e84e 100644 --- a/packages/ui/certd-client/src/vben/stores/modules/tabbar.ts +++ b/packages/ui/certd-client/src/vben/stores/modules/tabbar.ts @@ -45,7 +45,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * Close tabs in bulk */ async _bulkCloseByPaths(paths: string[]) { - this.tabs = this.tabs.filter((item) => { + this.tabs = this.tabs.filter(item => { return !paths.includes(getTabPath(item)); }); @@ -60,7 +60,7 @@ export const useTabbarStore = defineStore("core-tabbar", { if (isAffixTab(tab)) { return; } - const index = this.tabs.findIndex((item) => item.fullPath === fullPath); + const index = this.tabs.findIndex(item => item.fullPath === fullPath); index !== -1 && this.tabs.splice(index, 1); }, /** @@ -85,7 +85,7 @@ export const useTabbarStore = defineStore("core-tabbar", { const toParams = { params: params || {}, path, - query: query || {} + query: query || {}, }; await router.replace(toParams); }, @@ -99,7 +99,7 @@ export const useTabbarStore = defineStore("core-tabbar", { return; } - const tabIndex = this.tabs.findIndex((tab) => { + const tabIndex = this.tabs.findIndex(tab => { return getTabPath(tab) === getTabPath(routeTab); }); @@ -109,13 +109,13 @@ export const useTabbarStore = defineStore("core-tabbar", { const maxNumOfOpenTab = (routeTab?.meta?.maxNumOfOpenTab ?? -1) as number; // 如果动态路由层级大于 0 了,那么就要限制该路由的打开数限制了 // 获取到已经打开的动态路由数, 判断是否大于某一个值 - if (maxNumOfOpenTab > 0 && this.tabs.filter((tab) => tab.name === routeTab.name).length >= maxNumOfOpenTab) { + if (maxNumOfOpenTab > 0 && this.tabs.filter(tab => tab.name === routeTab.name).length >= maxNumOfOpenTab) { // 关闭第一个 - const index = this.tabs.findIndex((item) => item.name === routeTab.name); + const index = this.tabs.findIndex(item => item.name === routeTab.name); index !== -1 && this.tabs.splice(index, 1); } else if (maxCount > 0 && this.tabs.length >= maxCount) { // 关闭第一个 - const index = this.tabs.findIndex((item) => !Reflect.has(item.meta, "affixTab") || !item.meta.affixTab); + const index = this.tabs.findIndex(item => !Reflect.has(item.meta, "affixTab") || !item.meta.affixTab); index !== -1 && this.tabs.splice(index, 1); } this.tabs.push(tab); @@ -125,7 +125,7 @@ export const useTabbarStore = defineStore("core-tabbar", { const mergedTab = { ...currentTab, ...tab, - meta: { ...currentTab?.meta, ...tab.meta } + meta: { ...currentTab?.meta, ...tab.meta }, }; if (currentTab) { const curMeta = currentTab.meta; @@ -145,7 +145,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @zh_CN 关闭所有标签页 */ async closeAllTabs(router: Router) { - const newTabs = this.tabs.filter((tab) => isAffixTab(tab)); + const newTabs = this.tabs.filter(tab => isAffixTab(tab)); this.tabs = newTabs.length > 0 ? newTabs : [...this.tabs].splice(0, 1); await this._goToDefaultTab(router); this.updateCacheTabs(); @@ -155,7 +155,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param tab */ async closeLeftTabs(tab: TabDefinition) { - const index = this.tabs.findIndex((item) => getTabPath(item) === getTabPath(tab)); + const index = this.tabs.findIndex(item => getTabPath(item) === getTabPath(tab)); if (index < 1) { return; @@ -176,13 +176,13 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param tab */ async closeOtherTabs(tab: TabDefinition) { - const closePaths = this.tabs.map((item) => getTabPath(item)); + const closePaths = this.tabs.map(item => getTabPath(item)); const paths: string[] = []; for (const path of closePaths) { if (path !== tab.fullPath) { - const closeTab = this.tabs.find((item) => getTabPath(item) === path); + const closeTab = this.tabs.find(item => getTabPath(item) === path); if (!closeTab) { continue; } @@ -198,7 +198,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param tab */ async closeRightTabs(tab: TabDefinition) { - const index = this.tabs.findIndex((item) => getTabPath(item) === getTabPath(tab)); + const index = this.tabs.findIndex(item => getTabPath(item) === getTabPath(tab)); if (index !== -1 && index < this.tabs.length - 1) { const rightTabs = this.tabs.slice(index + 1); @@ -227,7 +227,7 @@ export const useTabbarStore = defineStore("core-tabbar", { this.updateCacheTabs(); return; } - const index = this.getTabs.findIndex((item) => getTabPath(item) === getTabPath(currentRoute.value)); + const index = this.getTabs.findIndex(item => getTabPath(item) === getTabPath(currentRoute.value)); const before = this.getTabs[index - 1]; const after = this.getTabs[index + 1]; @@ -252,7 +252,7 @@ export const useTabbarStore = defineStore("core-tabbar", { */ async closeTabByKey(key: string, router: Router) { const originKey = decodeURIComponent(key); - const index = this.tabs.findIndex((item) => getTabPath(item) === originKey); + const index = this.tabs.findIndex(item => getTabPath(item) === originKey); if (index === -1) { return; } @@ -268,7 +268,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param path */ getTabByPath(path: string) { - return this.getTabs.find((item) => getTabPath(item) === path) as TabDefinition; + return this.getTabs.find(item => getTabPath(item) === path) as TabDefinition; }, /** * @zh_CN 新窗口打开标签页 @@ -283,7 +283,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param tab */ async pinTab(tab: TabDefinition) { - const index = this.tabs.findIndex((item) => getTabPath(item) === getTabPath(tab)); + const index = this.tabs.findIndex(item => getTabPath(item) === getTabPath(tab)); if (index !== -1) { const oldTab = this.tabs[index]; tab.meta.affixTab = true; @@ -292,9 +292,9 @@ export const useTabbarStore = defineStore("core-tabbar", { this.tabs.splice(index, 1, tab); } // 过滤固定tabs,后面更改affixTabOrder的值的话可能会有问题,目前行464排序affixTabs没有设置值 - const affixTabs = this.tabs.filter((tab) => isAffixTab(tab)); + const affixTabs = this.tabs.filter(tab => isAffixTab(tab)); // 获得固定tabs的index - const newIndex = affixTabs.findIndex((item) => getTabPath(item) === getTabPath(tab)); + const newIndex = affixTabs.findIndex(item => getTabPath(item) === getTabPath(tab)); // 交换位置重新排序 await this.sortTabs(index, newIndex); }, @@ -310,7 +310,7 @@ export const useTabbarStore = defineStore("core-tabbar", { this.renderRouteView = false; startProgress(); - await new Promise((resolve) => setTimeout(resolve, 200)); + await new Promise(resolve => setTimeout(resolve, 200)); this.excludeCachedTabs.delete(name as string); this.renderRouteView = true; @@ -324,7 +324,7 @@ export const useTabbarStore = defineStore("core-tabbar", { if (tab?.meta?.newTabTitle) { return; } - const findTab = this.tabs.find((item) => getTabPath(item) === getTabPath(tab)); + const findTab = this.tabs.find(item => getTabPath(item) === getTabPath(tab)); if (findTab) { findTab.meta.newTabTitle = undefined; await this.updateCacheTabs(); @@ -348,7 +348,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param title */ async setTabTitle(tab: TabDefinition, title: string) { - const findTab = this.tabs.find((item) => getTabPath(item) === getTabPath(tab)); + const findTab = this.tabs.find(item => getTabPath(item) === getTabPath(tab)); if (findTab) { findTab.meta.newTabTitle = title; @@ -389,7 +389,7 @@ export const useTabbarStore = defineStore("core-tabbar", { * @param tab */ async unpinTab(tab: TabDefinition) { - const index = this.tabs.findIndex((item) => getTabPath(item) === getTabPath(tab)); + const index = this.tabs.findIndex(item => getTabPath(item) === getTabPath(tab)); if (index !== -1) { const oldTab = this.tabs[index]; @@ -399,7 +399,7 @@ export const useTabbarStore = defineStore("core-tabbar", { this.tabs.splice(index, 1, tab); } // 过滤固定tabs,后面更改affixTabOrder的值的话可能会有问题,目前行464排序affixTabs没有设置值 - const affixTabs = this.tabs.filter((tab) => isAffixTab(tab)); + const affixTabs = this.tabs.filter(tab => isAffixTab(tab)); // 获得固定tabs的index,使用固定tabs的下一个位置也就是活动tabs的第一个位置 const newIndex = affixTabs.length; // 交换位置重新排序 @@ -428,11 +428,11 @@ export const useTabbarStore = defineStore("core-tabbar", { cacheMap.add(name); } this.cachedTabs = cacheMap; - } + }, }, getters: { affixTabs(): TabDefinition[] { - const affixTabs = this.tabs.filter((tab) => isAffixTab(tab)); + const affixTabs = this.tabs.filter(tab => isAffixTab(tab)); return affixTabs.sort((a, b) => { const orderA = (a.meta?.affixTabOrder ?? 0) as number; @@ -447,16 +447,16 @@ export const useTabbarStore = defineStore("core-tabbar", { return [...this.excludeCachedTabs]; }, getTabs(): TabDefinition[] { - const normalTabs = this.tabs.filter((tab) => !isAffixTab(tab)); + const normalTabs = this.tabs.filter(tab => !isAffixTab(tab)); return [...this.affixTabs, ...normalTabs].filter(Boolean); - } + }, }, persist: [ // tabs不需要保存在localStorage { pick: ["tabs"], - storage: sessionStorage - } + storage: sessionStorage, + }, ], state: (): TabbarState => ({ cachedTabs: new Set(), @@ -464,8 +464,8 @@ export const useTabbarStore = defineStore("core-tabbar", { excludeCachedTabs: new Set(), renderRouteView: true, tabs: [], - updateTime: Date.now() - }) + updateTime: Date.now(), + }), }); // 解决热更新问题 @@ -486,16 +486,16 @@ function cloneTab(route: TabDefinition): TabDefinition { return { ...opt, matched: (matched - ? matched.map((item) => ({ + ? matched.map(item => ({ meta: item.meta, name: item.name, - path: item.path + path: item.path, })) : undefined) as RouteRecordNormalized[], meta: { ...meta, - newTabTitle: meta.newTabTitle - } + newTabTitle: meta.newTabTitle, + }, }; } @@ -513,7 +513,7 @@ function isAffixTab(tab: TabDefinition) { */ function isTabShown(tab: TabDefinition) { const matched = tab?.matched ?? []; - return !tab.meta.hideInTab && matched.every((item) => !item.meta.hideInTab); + return !tab.meta.hideInTab && matched.every(item => !item.meta.hideInTab); } /** @@ -528,6 +528,6 @@ function routeToTab(route: RouteRecordNormalized) { return { meta: route.meta, name: route.name, - path: route.path + path: route.path, } as TabDefinition; } diff --git a/packages/ui/certd-client/src/views/certd/pipeline/cert-upload/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/cert-upload/index.vue index 777ccac8..47ad261e 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/cert-upload/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/cert-upload/index.vue @@ -37,7 +37,6 @@ const domain = computed(() => { }); function onUpdated(res: { uploadCert: any }) { - debugger; emit("update:modelValue", res.uploadCert); const domains = getAllDomainsFromCrt(res.uploadCert.crt); emit("updated", { domains }); @@ -45,7 +44,6 @@ function onUpdated(res: { uploadCert: any }) { const pipeline: any = inject("pipeline"); function onUploadClick() { - debugger; openUpdateCertDialog({ onSubmit: onUpdated, }); diff --git a/packages/ui/certd-client/src/views/certd/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/index.vue index aa71ab5a..0c9f240f 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/index.vue @@ -30,20 +30,20 @@ import { Modal, notification } from "ant-design-vue"; import * as api from "./api"; defineOptions({ - name: "PipelineManager" + name: "PipelineManager", }); const certdFormRef = ref(); const groupDictRef = dict({ url: "/pi/pipeline/group/all", value: "id", - label: "name" + label: "name", }); const selectedRowKeys = ref([]); const context: any = { certdFormRef, groupDictRef, - selectedRowKeys + selectedRowKeys, }; const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context }); @@ -70,7 +70,7 @@ function batchDelete() { notification.success({ message: "删除成功" }); await crudExpose.doRefresh(); selectedRowKeys.value = []; - } + }, }); } diff --git a/packages/ui/certd-client/src/views/sys/plugin/api.ts b/packages/ui/certd-client/src/views/sys/plugin/api.ts index 91efcf59..dd5800f4 100644 --- a/packages/ui/certd-client/src/views/sys/plugin/api.ts +++ b/packages/ui/certd-client/src/views/sys/plugin/api.ts @@ -101,3 +101,11 @@ export async function SaveCommPluginConfigs(data: CommPluginConfig): Promise { + return await request({ + url: apiPrefix + "/doTest", + method: "post", + data: req, + }); +} diff --git a/packages/ui/certd-client/src/views/sys/plugin/edit.vue b/packages/ui/certd-client/src/views/sys/plugin/edit.vue index 3a83a072..29756c09 100644 --- a/packages/ui/certd-client/src/views/sys/plugin/edit.vue +++ b/packages/ui/certd-client/src/views/sys/plugin/edit.vue @@ -8,7 +8,8 @@
- 保存 + 保存 + 测试运行
@@ -34,6 +35,7 @@ import { onMounted, provide, ref } from "vue"; import { useRoute } from "vue-router"; import * as api from "./api"; import yaml from "js-yaml"; +import { notification } from "ant-design-vue"; const CertApplyPluginNames = ["CertApply", "CertApplyLego", "CertApplyUpload"]; defineOptions({ @@ -48,39 +50,53 @@ async function getPlugin() { const pluginObj = await api.GetObj(id); if (!pluginObj.metadata) { pluginObj.metadata = yaml.dump({ - input: [ - { - key: "cert", + input: { + cert: { title: "前置任务生成的证书", component: { name: "output-selector", from: [...CertApplyPluginNames], }, }, - ], - output: [], + }, + output: {}, }); - } else { - pluginObj.metadata = ""; } plugin.value = pluginObj; } -getPlugin(); -onMounted(async () => {}); + +onMounted(async () => { + getPlugin(); +}); provide("get:plugin", () => { return plugin; }); const saveLoading = ref(false); -function doSave() { +async function doSave() { saveLoading.value = true; try { - // api.Save(plugin.value); + await api.UpdateObj(plugin.value); + notification.success({ + message: "保存成功", + }); } finally { saveLoading.value = false; } } + +async function doTest() { + await doSave(); + const result = await api.DoTest({ + id: plugin.value.id, + input: {}, + }); + notification.success({ + message: "测试已开始", + description: result, + }); +}