Merge remote-tracking branch 'origin/v2-dev' into v2-dev

pull/265/head
xiaojunnuo 2024-12-05 11:10:39 +08:00
commit 1b267813c9
4 changed files with 45 additions and 20 deletions

View File

@ -14,9 +14,6 @@ git clone https://github.com/certd/certd --depth=1
#进入项目目录 #进入项目目录
cd certd cd certd
# 切换到最新版本代码【如果v2分支无法编译请尝试切换到最新版tag】
# git checkout v1.27.0 # 这里换成最新版本号
``` ```
### 修改pnpm-workspace.yaml文件 ### 修改pnpm-workspace.yaml文件

View File

@ -65,6 +65,7 @@
<a-form :model="testFormState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onTestSend"> <a-form :model="testFormState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onTestSend">
<a-form-item label="测试收件邮箱" name="receiver" :rules="[{ required: true, message: '请输入测试收件邮箱' }]"> <a-form-item label="测试收件邮箱" name="receiver" :rules="[{ required: true, message: '请输入测试收件邮箱' }]">
<a-input v-model:value="testFormState.receiver" /> <a-input v-model:value="testFormState.receiver" />
<div class="helper">保存后再点击测试</div>
<div class="helper">发送失败<a href="https://certd.docmirror.cn/guide/use/email/" target="_blank">邮件配置帮助文档</a></div> <div class="helper">发送失败<a href="https://certd.docmirror.cn/guide/use/email/" target="_blank">邮件配置帮助文档</a></div>
<div class="helper">您还可以试试使用官方邮件服务器</div> <div class="helper">您还可以试试使用官方邮件服务器</div>
</a-form-item> </a-form-item>

View File

@ -3,12 +3,12 @@ import type { EmailSend } from '@certd/pipeline';
import { IEmailService } from '@certd/pipeline'; import { IEmailService } from '@certd/pipeline';
import { logger } from '@certd/basic'; import { logger } from '@certd/basic';
import { isPlus } from '@certd/plus-core'; import { isComm, isPlus } from '@certd/plus-core';
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
import type SMTPConnection from 'nodemailer/lib/smtp-connection'; import type SMTPConnection from 'nodemailer/lib/smtp-connection';
import { UserSettingsService } from '../../mine/service/user-settings-service.js'; import { UserSettingsService } from '../../mine/service/user-settings-service.js';
import { PlusService, SysSettingsService } from '@certd/lib-server'; import { PlusService, SysSettingsService, SysSiteInfo } from '@certd/lib-server';
import { getEmailSettings } from '../../sys/settings/fix.js'; import { getEmailSettings } from '../../sys/settings/fix.js';
export type EmailConfig = { export type EmailConfig = {
@ -80,8 +80,16 @@ export class EmailService implements IEmailService {
private async sendByCustom(emailConfig: EmailConfig, email: EmailSend) { private async sendByCustom(emailConfig: EmailConfig, email: EmailSend) {
const transporter = nodemailer.createTransport(emailConfig); const transporter = nodemailer.createTransport(emailConfig);
let sysTitle = 'Certd';
if (isComm()) {
const siteInfo = await this.sysSettingsService.getSetting<SysSiteInfo>(SysSiteInfo);
if (siteInfo) {
sysTitle = siteInfo.title || sysTitle;
}
}
const mailOptions = { const mailOptions = {
from: emailConfig.sender, from: `${sysTitle} <${emailConfig.sender}>`,
to: email.receivers.join(', '), // list of receivers to: email.receivers.join(', '), // list of receivers
subject: email.subject, subject: email.subject,
text: email.content, text: email.content,

View File

@ -4,18 +4,21 @@ import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js'; import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
@IsTaskPlugin({ @IsTaskPlugin({
name: 'demoTest', //命名规范,插件名称+功能就是目录plugin-demo中的demo大写字母开头驼峰命名
name: 'DemoTest',
title: 'Demo测试插件', title: 'Demo测试插件',
icon: 'clarity:plugin-line', icon: 'clarity:plugin-line',
//插件分组 //插件分组
group: pluginGroups.other.key, group: pluginGroups.other.key,
default: { default: {
//默认值配置照抄即可
strategy: { strategy: {
runStrategy: RunStrategy.SkipWhenSucceed, runStrategy: RunStrategy.SkipWhenSucceed,
}, },
}, },
}) })
export class DemoTestPlugin extends AbstractTaskPlugin { //类名规范跟上面插件名称name一致
export class DemoTest extends AbstractTaskPlugin {
//测试参数 //测试参数
@TaskInput({ @TaskInput({
title: '属性示例', title: '属性示例',
@ -42,6 +45,23 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
}) })
select!: string; select!: string;
//测试参数
@TaskInput({
title: '多选框',
component: {
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
name: 'a-select',
vModel: 'value',
mode: 'tags',
multiple: true,
options: [
{ value: '1', label: '选项1' },
{ value: '2', label: '选项2' },
],
},
})
multiSelect!: string;
//测试参数 //测试参数
@TaskInput({ @TaskInput({
title: 'switch', title: 'switch',
@ -85,8 +105,7 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
createRemoteSelectInputDefine({ createRemoteSelectInputDefine({
title: '从后端获取选项', title: '从后端获取选项',
helper: '选择时可以从后端获取选项', helper: '选择时可以从后端获取选项',
typeName: 'demoTest', action: DemoTest.prototype.onGetSiteList.name,
action: DemoTestPlugin.prototype.onGetSiteList.name,
//当以下参数变化时,触发获取选项 //当以下参数变化时,触发获取选项
watches: ['certDomains', 'accessId'], watches: ['certDomains', 'accessId'],
required: true, required: true,
@ -121,15 +140,15 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
this.logger.info('switch:', this.switch); this.logger.info('switch:', this.switch);
this.logger.info('授权id:', accessId); this.logger.info('授权id:', accessId);
const res = await this.http.request({ // const res = await this.http.request({
url: 'https://api.demo.com', // url: 'https://api.demo.com',
method: 'GET', // method: 'GET',
}); // });
if (res.code !== 0) { // if (res.code !== 0) {
//检查res是否报错,你需要抛异常,来结束插件执行,否则会判定为执行成功,下次执行时会跳过本任务 // //检查res是否报错,你需要抛异常,来结束插件执行,否则会判定为执行成功,下次执行时会跳过本任务
throw new Error(res.message); // throw new Error(res.message);
} // }
this.logger.info('部署成功:', res); // this.logger.info('部署成功:', res);
} }
//此方法演示,如何让前端在添加插件时可以从后端获取选项,这里是后端返回选项的方法 //此方法演示,如何让前端在添加插件时可以从后端获取选项,这里是后端返回选项的方法
@ -167,4 +186,4 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
} }
} }
//实例化一下,注册插件 //实例化一下,注册插件
new DemoTestPlugin(); new DemoTest();