From e4c21c4d5cac2a1bd8544368c482d2c8877d1220 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 15 Dec 2025 22:32:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=A8=A1=E7=89=88=E5=8F=91=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=20plus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/sys/settings/email/index.vue | 9 ++- .../modules/basic/service/email-service.ts | 55 ++++++++++--------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/packages/ui/certd-client/src/views/sys/settings/email/index.vue b/packages/ui/certd-client/src/views/sys/settings/email/index.vue index 8d94f2a27..2937a78db 100644 --- a/packages/ui/certd-client/src/views/sys/settings/email/index.vue +++ b/packages/ui/certd-client/src/views/sys/settings/email/index.vue @@ -78,7 +78,14 @@ - + diff --git a/packages/ui/certd-server/src/modules/basic/service/email-service.ts b/packages/ui/certd-server/src/modules/basic/service/email-service.ts index aeac0458b..b10c7b53f 100644 --- a/packages/ui/certd-server/src/modules/basic/service/email-service.ts +++ b/packages/ui/certd-server/src/modules/basic/service/email-service.ts @@ -117,8 +117,8 @@ export class EmailService implements IEmailService { async test(userId: number, receiver: string) { await this.sendByTemplate({ - type:"common", - data:{ + type: "common", + data: { title: '测试邮件,from certd', content: '测试邮件,from certd', }, @@ -150,36 +150,39 @@ export class EmailService implements IEmailService { async sendByTemplate(req: EmailSendByTemplateReq) { - const emailConf = await this.sysSettingsService.getSetting(SysEmailConf); - - const template = emailConf?.templates?.[req.type] let content = null - if (template && template.addonId) { - const addon: ITemplateProvider = await this.addonGetterService.getAddonById(template.addonId, true, 0) - if (addon) { - content = await addon.buildContent({ data: req.data }) - } - } - if (!content) { - //看看有没有通用模版 - if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) { - const addon: ITemplateProvider = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0) + if (isPlus()) { + const emailConf = await this.sysSettingsService.getSetting(SysEmailConf); + const template = emailConf?.templates?.[req.type] + if (template && template.addonId) { + const addon: ITemplateProvider = await this.addonGetterService.getAddonById(template.addonId, true, 0) if (addon) { content = await addon.buildContent({ data: req.data }) } } - } - // 没有找到模版,使用默认模版 - if (!content) { - try { - const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", req.type) - content = await addon.buildDefaultContent({ data: req.data }) - } catch (e) { - // 对应的通知类型模版可能没有注册或者开发 - const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", "common") - content = await addon.buildDefaultContent({ data: req.data }) - //common类型的一定有,已经开发了 + if (!content) { + //看看有没有通用模版 + if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) { + const addon: ITemplateProvider = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0) + if (addon) { + content = await addon.buildContent({ data: req.data }) + } + } } + // 没有找到模版,使用默认模版 + if (!content) { + try { + const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", req.type) + content = await addon.buildDefaultContent({ data: req.data }) + } catch (e) { + // 对应的通知类型模版可能没有注册或者开发 + } + } + } + + if (!content) { + const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", "common") + content = await addon.buildDefaultContent({ data: req.data }) } return await this.send({ ...req.email,