From cabc4da3ac003a8c699c69f5bffea4c149be185c Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 30 Dec 2025 11:53:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=AF=81=E4=B9=A6=E6=A8=A1=E7=89=88=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/certd/addon/common.tsx | 5 +- .../plugins/plugin-deploy-to-mail.ts | 2 +- .../plugins/plugin-template/email/index.ts | 1 + .../plugin-template/email/plugin-send-cert.ts | 50 +++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 packages/ui/certd-server/src/plugins/plugin-template/email/plugin-send-cert.ts diff --git a/packages/ui/certd-client/src/views/certd/addon/common.tsx b/packages/ui/certd-client/src/views/certd/addon/common.tsx index cb6dc4358..d871e1c9d 100644 --- a/packages/ui/certd-client/src/views/certd/addon/common.tsx +++ b/packages/ui/certd-client/src/views/certd/addon/common.tsx @@ -211,6 +211,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any, a show: computed(() => { return getAddonTypeDefine(addonType)?.showDefault ?? false; }), + columnSetShow: false, value: false, rules: [{ required: true, message: t("certd.selectIsDefault") }], order: 999, @@ -218,6 +219,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any, a column: { align: "center", width: 100, + columnSetShow: false, show: computed(() => { return getAddonTypeDefine(addonType)?.showDefault ?? false; }), @@ -263,10 +265,11 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any, a }, column: { show: false, + columnSetShow: false, }, }, setting: { - column: { show: false }, + column: { show: false, columnSetShow: false }, form: { show: false, valueBuilder({ value, form }) { diff --git a/packages/ui/certd-server/src/plugins/plugin-other/plugins/plugin-deploy-to-mail.ts b/packages/ui/certd-server/src/plugins/plugin-other/plugins/plugin-deploy-to-mail.ts index eabbd39a6..b9a944b4d 100644 --- a/packages/ui/certd-server/src/plugins/plugin-other/plugins/plugin-deploy-to-mail.ts +++ b/packages/ui/certd-server/src/plugins/plugin-other/plugins/plugin-deploy-to-mail.ts @@ -156,7 +156,7 @@ export class DeployCertToMailPlugin extends AbstractTaskPlugin { throw new Error('证书压缩文件还未生成,重新运行证书任务'); } await this.ctx.emailService.sendByTemplate({ - type: "common", + type: "sendCert", data, receivers: this.email, attachments: [ diff --git a/packages/ui/certd-server/src/plugins/plugin-template/email/index.ts b/packages/ui/certd-server/src/plugins/plugin-template/email/index.ts index 36e564c05..be4697ab2 100644 --- a/packages/ui/certd-server/src/plugins/plugin-template/email/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-template/email/index.ts @@ -2,3 +2,4 @@ export * from './plugin-common.js' export * from './plugin-register-code.js' export * from './plugin-forgot-password.js' export * from './plugin-pipeline-result.js' +export * from './plugin-send-cert.js' \ No newline at end of file diff --git a/packages/ui/certd-server/src/plugins/plugin-template/email/plugin-send-cert.ts b/packages/ui/certd-server/src/plugins/plugin-template/email/plugin-send-cert.ts new file mode 100644 index 000000000..dccac8cc0 --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-template/email/plugin-send-cert.ts @@ -0,0 +1,50 @@ +import { AddonInput, IsAddon } from "@certd/lib-server"; +import { BuildContentReq, EmailContent, ITemplateProvider } from "../api.js"; +import { BaseEmailTemplateProvider } from "./plugin-base.js"; + +@IsAddon({ + addonType: "emailTemplate", + name: 'sendCert', + title: '发送证书邮件模版', + desc: '邮件发送证书插件的邮件模版', + icon: "simple-icons:email:blue", + showTest: false, +}) +export class SendCertEmailTemplateProvider extends BaseEmailTemplateProvider implements ITemplateProvider { + @AddonInput({ + title: "可用参数", + component: { + name: "ParamsShow", + params:[ + /** + * mainDomain, + domains, + expiresTime: dayjs(certReader.expires).format("YYYY-MM-DD HH:mm:ss"), + remark: this.remark || "", + crt: this.cert.crt, + key: this.cert.key, + ic: this.cert.ic, + */ + {label:"主域名",value:"mainDomain"}, + {label:"全部域名",value:"domains"}, + {label:"过期时间",value:"expiresTime"}, + {label:"备注",value:"remark"}, + {label:"证书内容",value:"crt"}, + {label:"私钥内容",value:"key"}, + {label:"中间证书",value:"ic"}, + ] + }, + col: { span: 24 }, + }) + paramIntro = ""; + + + async buildDefaultContent(req:BuildContentReq) { + const defaultTemplate = new SendCertEmailTemplateProvider() + defaultTemplate.titleTemplate = "${title}" + defaultTemplate.contentTemplate = "${content}" + defaultTemplate.formatType = "text" + return await defaultTemplate.buildContent(req) + } + +}