mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
perf: 增加邮件发送证书模版配置
This commit is contained in:
@@ -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 }) {
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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'
|
||||
@@ -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<EmailContent> {
|
||||
@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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user