diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts index a443c0d23..d0da67897 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts @@ -15,6 +15,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin { vModel: "value", mode: "tags", open: false, + tokenSeparators: [",", " ", ",", "、", "|"], }, required: true, col: { @@ -25,7 +26,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin { "1、支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" + "2、支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n" + "3、多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com)\n" + - "4、输入一个回车之后,再输入下一个", + "4、输入一个空格之后,再输入下一个", }) domains!: string[]; @@ -77,13 +78,6 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin { }) successNotify = true; - @TaskInput({ - title: "配置说明", - order: 9999, - helper: "运行策略请选择总是运行,其他证书部署任务请选择成功后跳过;当证书快到期前将会自动重新申请证书,然后会清空后续任务的成功状态,部署任务将会重新运行", - }) - intro!: string; - // @TaskInput({ // title: "CsrInfo", // helper: "暂时没有用", diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts index 3fc62c39b..c8eec49bd 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts @@ -37,11 +37,31 @@ export class CertApplyPlugin extends CertApplyBasePlugin { { value: "zerossl", label: "ZeroSSL" }, ], }, - helper: "如果letsencrypt.org或dv.acme-v02.api.pki.goog无法访问,请尝试开启代理选项\n如果使用ZeroSSL、google证书,需要提供EAB授权", + helper: "Let's Encrypt最简单,如果使用ZeroSSL、google证书,需要提供EAB授权", required: true, }) sslProvider!: SSLProvider; + @TaskInput({ + title: "EAB授权", + component: { + name: "pi-access-selector", + type: "eab", + }, + maybeNeed: true, + required: true, + helper: + "需要提供EAB授权\nZeroSSL:请前往[zerossl开发者中心](https://app.zerossl.com/developer),生成 'EAB Credentials' \n Google:请查看[google获取eab帮助文档](https://github.com/certd/certd/blob/v2/doc/google/google.md)", + mergeScript: ` + return { + show: ctx.compute(({form})=>{ + return form.sslProvider === 'zerossl' || form.sslProvider === 'google' + }) + } + `, + }) + eabAccessId!: number; + @TaskInput({ title: "加密算法", value: "rsa_2048", @@ -62,18 +82,6 @@ export class CertApplyPlugin extends CertApplyBasePlugin { }) privateKeyType!: PrivateKeyType; - @TaskInput({ - title: "EAB授权", - component: { - name: "pi-access-selector", - type: "eab", - }, - maybeNeed: true, - helper: - "如果使用ZeroSSL或者google证书,需要提供EAB授权\nZeroSSL:请前往 https://app.zerossl.com/developer 生成 'EAB Credentials' \n Google:请前往https://github.com/certd/certd/blob/v2/doc/google/google.md", - }) - eabAccessId!: number; - @TaskInput({ title: "DNS提供商", component: { @@ -81,7 +89,7 @@ export class CertApplyPlugin extends CertApplyBasePlugin { }, required: true, helper: - "请选择dns解析提供商,您的域名是在哪里注册的,或者域名的dns解析服务器属于哪个平台\n如果这里没有您的dns解析提供商,您可以将域名解析服务器设置成上面的任意一个提供商", + "请选择dns解析提供商,您的域名是在哪里注册的,或者域名的dns解析服务器属于哪个平台\n如果这里没有您需要的dns解析提供商,您需要将域名解析服务器设置成上面的任意一个提供商", }) dnsProviderType!: string; @@ -92,13 +100,14 @@ export class CertApplyPlugin extends CertApplyBasePlugin { }, required: true, helper: "请选择dns解析提供商授权", - reference: [ - { - src: "form.dnsProviderType", - dest: "component.type", - type: "computed", - }, - ], + mergeScript: `return { + component:{ + type: ctx.compute(({form})=>{ + return form.dnsProviderType + }) + } + } + `, }) dnsProviderAccess!: string; diff --git a/packages/ui/certd-client/src/components/cron-editor/index.vue b/packages/ui/certd-client/src/components/cron-editor/index.vue index a9ea62366..087324cfa 100644 --- a/packages/ui/certd-client/src/components/cron-editor/index.vue +++ b/packages/ui/certd-client/src/components/cron-editor/index.vue @@ -70,6 +70,7 @@ const onError = (error: any) => { } .vcron-select-input { min-height: 22px; + background-color: #fff; } .vcron-select-container { display: flex; diff --git a/packages/ui/certd-client/src/use/use-refrence.ts b/packages/ui/certd-client/src/use/use-refrence.ts deleted file mode 100644 index 489e54367..000000000 --- a/packages/ui/certd-client/src/use/use-refrence.ts +++ /dev/null @@ -1,17 +0,0 @@ -import _ from "lodash-es"; -import { compute } from "@fast-crud/fast-crud"; - -export function useReference(form: any) { - if (!form.reference) { - return; - } - for (const reference of form.reference) { - _.set( - form, - reference.dest, - compute((scope) => { - return _.get(scope, reference.src); - }) - ); - } -} diff --git a/packages/ui/certd-client/src/use/use-refrence.tsx b/packages/ui/certd-client/src/use/use-refrence.tsx new file mode 100644 index 000000000..a47945182 --- /dev/null +++ b/packages/ui/certd-client/src/use/use-refrence.tsx @@ -0,0 +1,40 @@ +import _ from "lodash-es"; +import { compute } from "@fast-crud/fast-crud"; + +export function useReference(formItem: any) { + if (formItem.reference) { + for (const reference of formItem.reference) { + _.set( + formItem, + reference.dest, + compute((scope) => { + return _.get(scope, reference.src); + }) + ); + } + delete formItem.reference; + } + + if (formItem.mergeScript) { + const ctx = { + compute + }; + const script = formItem.mergeScript; + const func = new Function("ctx", script); + const merged = func(ctx); + _.merge(formItem, merged); + + delete formItem.mergeScript; + } + //helper + if (formItem.helper && typeof formItem.helper === "string") { + //正则表达式替换 [name](url) 成 + let helper = formItem.helper.replace(/\[(.*)\]\((.*)\)/g, '$1'); + helper = helper.replace(/\n/g, "
"); + formItem.helper = { + render: () => { + return
; + } + }; + } +} diff --git a/packages/ui/certd-client/src/views/certd/access/common.tsx b/packages/ui/certd-client/src/views/certd/access/common.tsx index a1c8c90f4..9bf080bbb 100644 --- a/packages/ui/certd-client/src/views/certd/access/common.tsx +++ b/packages/ui/certd-client/src/views/certd/access/common.tsx @@ -1,4 +1,4 @@ -import { ColumnCompositionProps, dict } from "@fast-crud/fast-crud"; +import { ColumnCompositionProps, dict, compute } from "@fast-crud/fast-crud"; // @ts-ignore import * as api from "./api"; // @ts-ignore @@ -32,11 +32,25 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any) { ...value, key }; - const column = _.merge({ title: key }, defaultPluginConfig, field); + let column = _.merge({ title: key }, defaultPluginConfig, field); + + //eval + if (column.mergeScript) { + const ctx = { + compute + }; + const script = column.mergeScript; + delete column.mergeScript; + const func = new Function("ctx", script); + const merged = func(ctx); + column = _.merge(column, merged); + } + + //设置默认值 if (column.value != null && _.get(form, key) == null) { - //设置默认值 _.set(form, key, column.value); } + //字段配置赋值 columnsRef.value[key] = column; console.log("form", columnsRef.value); }); @@ -55,7 +69,12 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any) { }, form: { component: { - disabled: false + disabled: false, + showSearch: true, + filterOption: (input: string, option: any) => { + input = input?.toLowerCase(); + return option.value.toLowerCase().indexOf(input) >= 0 || option.label.toLowerCase().indexOf(input) >= 0; + } }, rules: [{ required: true, message: "请选择类型" }], valueChange: { diff --git a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx index 574554313..6e3700624 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx @@ -22,12 +22,17 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre form: { ...inputDefine, show: compute((ctx) => { - console.log(formWrapperRef); const form = formWrapperRef.value.getFormData(); if (!form) { return false; } - return form?.certApplyPlugin === plugin.name; + + let inputDefineShow = true; + if (inputDefine.show != null) { + const computeShow = inputDefine.show as any; + inputDefineShow = computeShow.computeFn({ form }); + } + return form?.certApplyPlugin === plugin.name && inputDefineShow; }) } }; @@ -60,8 +65,8 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre render: () => { return ( ); } @@ -78,7 +83,7 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre vModel: "modelValue", placeholder: "0 0 4 * * *" }, - helper: "请输入cron表达式, 例如:0 0 4 * * *,每天凌晨4点触发", + helper: "点击上面的按钮,选择每天几点几分定时执行, 例如:0 0 4 * * *,每天凌晨4点0分0秒触发", order: 100 } }, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue index a207636cd..91853f652 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue @@ -1,5 +1,5 @@