mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 选项显示图标
This commit is contained in:
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { LoginService } from '../../modules/login/service/login-service.js';
|
||||
import { BaseController, Constants, SysPublicSettings, SysSettingsService } from '@certd/lib-server';
|
||||
import { CodeService } from '../../modules/basic/service/code-service.js';
|
||||
import { checkComm } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -21,11 +22,6 @@ export class LoginController extends BaseController {
|
||||
@Body(ALL)
|
||||
user: any
|
||||
) {
|
||||
const settings = await this.sysSettingsService.getSetting<SysPublicSettings>(SysPublicSettings);
|
||||
if (settings.passwordLoginEnabled === false) {
|
||||
throw new Error('当前站点已禁止密码登录');
|
||||
}
|
||||
|
||||
const token = await this.loginService.loginByPassword(user);
|
||||
this.ctx.cookies.set('token', token.token, {
|
||||
maxAge: 1000 * token.expire,
|
||||
@@ -43,6 +39,7 @@ export class LoginController extends BaseController {
|
||||
if (settings.smsLoginEnabled !== true) {
|
||||
throw new Error('当前站点禁止短信验证码登录');
|
||||
}
|
||||
checkComm();
|
||||
|
||||
const token = await this.loginService.loginBySmsCode({
|
||||
phoneCode: body.phoneCode,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { BaseController, Constants, SysSettingsService } from '@certd/lib-server';
|
||||
import { RegisterType, UserService } from '../../modules/sys/authority/service/user-service.js';
|
||||
import { CodeService } from '../../modules/basic/service/code-service.js';
|
||||
import { checkComm, checkPlus } from '@certd/plus-core';
|
||||
|
||||
export type RegisterReq = {
|
||||
type: RegisterType;
|
||||
@@ -53,6 +54,7 @@ export class RegisterController extends BaseController {
|
||||
if (sysPublicSettings.mobileRegisterEnabled === false) {
|
||||
throw new Error('当前站点已禁止手机号注册功能');
|
||||
}
|
||||
checkComm();
|
||||
//验证短信验证码
|
||||
await this.codeService.checkSmsCode({
|
||||
mobile: body.mobile,
|
||||
@@ -71,6 +73,7 @@ export class RegisterController extends BaseController {
|
||||
if (sysPublicSettings.emailRegisterEnabled === false) {
|
||||
throw new Error('当前站点已禁止Email注册功能');
|
||||
}
|
||||
checkPlus();
|
||||
this.codeService.checkEmailCode({
|
||||
email: body.email,
|
||||
randomStr: body.randomStr,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/c
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import { AccessService } from '../../modules/pipeline/service/access-service.js';
|
||||
import { AuthService } from '../../modules/sys/authority/service/auth-service.js';
|
||||
import { AccessDefine } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -77,12 +78,13 @@ export class AccessController extends CrudController<AccessService> {
|
||||
|
||||
@Post('/accessTypeDict', { summary: Constants.per.authOnly })
|
||||
async getAccessTypeDict() {
|
||||
const list = this.service.getDefineList();
|
||||
const list: AccessDefine[] = this.service.getDefineList();
|
||||
const dict = [];
|
||||
for (const item of list) {
|
||||
dict.push({
|
||||
value: item.name,
|
||||
label: item.title,
|
||||
icon: item.icon,
|
||||
});
|
||||
}
|
||||
return this.ok(dict);
|
||||
|
||||
@@ -2,6 +2,8 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/c
|
||||
import { Constants, CrudController, ValidateException } from '@certd/lib-server';
|
||||
import { NotificationService } from '../../modules/pipeline/service/notification-service.js';
|
||||
import { AuthService } from '../../modules/sys/authority/service/auth-service.js';
|
||||
import { NotificationDefine } from '@certd/pipeline';
|
||||
import { checkPlus } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
* 通知
|
||||
@@ -43,12 +45,35 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean) {
|
||||
bean.userId = this.getUserId();
|
||||
const type = bean.type;
|
||||
const define: NotificationDefine = this.service.getDefineByType(type);
|
||||
if (!define) {
|
||||
throw new ValidateException('通知类型不存在');
|
||||
}
|
||||
if (define.needPlus) {
|
||||
checkPlus();
|
||||
}
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update', { summary: Constants.per.authOnly })
|
||||
async update(@Body(ALL) bean) {
|
||||
await this.service.checkUserId(bean.id, this.getUserId());
|
||||
const old = await this.service.info(bean.id);
|
||||
if (!old) {
|
||||
throw new ValidateException('通知配置不存在');
|
||||
}
|
||||
if (old.type !== bean.type) {
|
||||
const type = bean.type;
|
||||
const define: NotificationDefine = this.service.getDefineByType(type);
|
||||
if (!define) {
|
||||
throw new ValidateException('通知类型不存在');
|
||||
}
|
||||
if (define.needPlus) {
|
||||
checkPlus();
|
||||
}
|
||||
}
|
||||
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
@@ -71,14 +96,19 @@ export class NotificationController extends CrudController<NotificationService>
|
||||
|
||||
@Post('/getTypeDict', { summary: Constants.per.authOnly })
|
||||
async getTypeDict() {
|
||||
const list = this.service.getDefineList();
|
||||
const dict = [];
|
||||
const list: any = this.service.getDefineList();
|
||||
let dict = [];
|
||||
for (const item of list) {
|
||||
dict.push({
|
||||
value: item.name,
|
||||
label: item.title,
|
||||
needPlus: item.needPlus ?? false,
|
||||
icon: item.icon,
|
||||
});
|
||||
}
|
||||
dict = dict.sort(a => {
|
||||
return a.needPlus ? 0 : -1;
|
||||
});
|
||||
return this.ok(dict);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { CrudController, SysPrivateSettings, SysPublicSettings, SysSettingsEntity, SysSettingsService } from '@certd/lib-server';
|
||||
import * as _ from 'lodash-es';
|
||||
import { merge } from 'lodash-es';
|
||||
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
|
||||
import { UserSettingsService } from '../../../modules/mine/service/user-settings-service.js';
|
||||
import { getEmailSettings } from '../../../modules/sys/settings/fix.js';
|
||||
import { http, logger } from '@certd/basic';
|
||||
import { merge } from 'lodash-es';
|
||||
import { http, logger, simpleNanoId } from '@certd/basic';
|
||||
import { CodeService } from '../../../modules/basic/service/code-service.js';
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -18,6 +19,8 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||
userSettingsService: UserSettingsService;
|
||||
@Inject()
|
||||
pipelineService: PipelineService;
|
||||
@Inject()
|
||||
codeService: CodeService;
|
||||
|
||||
getService() {
|
||||
return this.service;
|
||||
@@ -111,7 +114,7 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/testProxy', { summary: 'sys:settings:view' })
|
||||
@Post('/testProxy', { summary: 'sys:settings:edit' })
|
||||
async testProxy(@Body(ALL) body) {
|
||||
const google = 'https://www.google.com/';
|
||||
const baidu = 'https://www.baidu.com/';
|
||||
@@ -148,4 +151,10 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||
baidu: baiduRes,
|
||||
});
|
||||
}
|
||||
|
||||
@Post('/testSms', { summary: 'sys:settings:edit' })
|
||||
async testSms(@Body(ALL) body) {
|
||||
await this.codeService.sendSmsCode(body.phoneCode, body.mobile, simpleNanoId());
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export class CodeService {
|
||||
}
|
||||
/**
|
||||
*/
|
||||
async sendSmsCode(phoneCode, mobile, randomStr) {
|
||||
async sendSmsCode(phoneCode = '86', mobile: string, randomStr: string) {
|
||||
console.assert(phoneCode != null && mobile != null, '手机号不能为空');
|
||||
console.assert(randomStr != null, 'randomStr不能为空');
|
||||
|
||||
@@ -83,6 +83,7 @@ export class CodeService {
|
||||
cache.set(key, smsCode, {
|
||||
ttl: 5 * 60 * 1000, //5分钟
|
||||
});
|
||||
return smsCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +103,7 @@ export class CodeService {
|
||||
cache.set(key, code, {
|
||||
ttl: 5 * 60 * 1000, //5分钟
|
||||
});
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ import { AliyunAccess, AliyunClient } from '@certd/plugin-lib';
|
||||
title: '阿里云',
|
||||
desc: '阿里云DNS解析提供商',
|
||||
accessType: 'aliyun',
|
||||
icon: 'ant-design:aliyun-outlined',
|
||||
})
|
||||
export class AliyunDnsProvider extends AbstractDnsProvider {
|
||||
client: any;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
name: 'CacheFly',
|
||||
title: 'CacheFly',
|
||||
desc: 'CacheFly',
|
||||
icon: 'clarity:plugin-line',
|
||||
})
|
||||
export class CacheflyAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
|
||||
@@ -7,6 +7,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
@IsAccess({
|
||||
name: 'cloudflare',
|
||||
title: 'cloudflare授权',
|
||||
icon: 'simple-icons:cloudflare',
|
||||
desc: '',
|
||||
})
|
||||
export class CloudflareAccess extends BaseAccess {
|
||||
|
||||
@@ -20,6 +20,7 @@ export type CloudflareRecord = {
|
||||
name: 'cloudflare',
|
||||
title: 'cloudflare',
|
||||
desc: 'cloudflare dns provider',
|
||||
icon: 'simple-icons:cloudflare',
|
||||
// 这里是对应的 cloudflare的access类型名称
|
||||
accessType: 'cloudflare',
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import { isDev } from '../../utils/env.js';
|
||||
@IsAccess({
|
||||
name: 'demo',
|
||||
title: '授权插件示例',
|
||||
icon: 'clarity:plugin-line',
|
||||
desc: '',
|
||||
})
|
||||
export class DemoAccess extends BaseAccess {
|
||||
|
||||
@@ -14,6 +14,7 @@ type DemoRecord = {
|
||||
name: 'demo',
|
||||
title: 'Dns提供商Demo',
|
||||
desc: 'dns provider示例',
|
||||
icon: 'clarity:plugin-line',
|
||||
// 这里是对应的云平台的access类型名称
|
||||
accessType: 'demo',
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
name: 'dogecloud',
|
||||
title: '多吉云',
|
||||
desc: '',
|
||||
icon: 'svg:icon-dogecloud',
|
||||
})
|
||||
export class DogeCloudAccess extends BaseAccess {
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
name: 'Gcore',
|
||||
title: 'Gcore',
|
||||
desc: 'Gcore',
|
||||
icon: 'clarity:plugin-line',
|
||||
})
|
||||
export class GcoreAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
name: 'huawei',
|
||||
title: '华为云授权',
|
||||
desc: '',
|
||||
icon: 'svg:icon-huawei',
|
||||
})
|
||||
export class HuaweiAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
|
||||
@@ -14,6 +14,7 @@ export type SearchRecordOptions = {
|
||||
title: '华为云',
|
||||
desc: '华为云DNS解析提供商',
|
||||
accessType: 'huawei',
|
||||
icon: 'svg:icon-huawei',
|
||||
})
|
||||
export class HuaweiDnsProvider extends AbstractDnsProvider {
|
||||
client!: HuaweiYunClient;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
name: 'namesilo',
|
||||
title: 'namesilo授权',
|
||||
desc: '',
|
||||
icon: 'simple-icons:namesilo',
|
||||
})
|
||||
export class NamesiloAccess extends BaseAccess {
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ export type NamesiloRecord = {
|
||||
name: 'namesilo',
|
||||
title: 'namesilo',
|
||||
desc: 'namesilo dns provider',
|
||||
icon: 'simple-icons:namesilo',
|
||||
// 这里是对应的 cloudflare的access类型名称
|
||||
accessType: 'namesilo',
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'anpush',
|
||||
title: 'AnPush',
|
||||
desc: 'https://anpush.com',
|
||||
needPlus: true,
|
||||
})
|
||||
export class AnPushNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -19,6 +19,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'bark',
|
||||
title: 'Bark 通知',
|
||||
desc: 'Bark 推送通知插件',
|
||||
needPlus: true,
|
||||
})
|
||||
export class BarkNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'discord',
|
||||
title: 'Discord 通知',
|
||||
desc: 'Discord 机器人通知',
|
||||
needPlus: true,
|
||||
})
|
||||
export class DiscordNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'iyuu',
|
||||
title: '爱语飞飞微信通知(iyuu)',
|
||||
desc: 'https://iyuu.cn/',
|
||||
needPlus: true,
|
||||
})
|
||||
export class IyuuNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'qywx',
|
||||
title: '企业微信通知',
|
||||
desc: '企业微信群聊机器人通知',
|
||||
needPlus: true,
|
||||
})
|
||||
export class QywxNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'serverchan',
|
||||
title: 'Server酱',
|
||||
desc: 'https://sct.ftqq.com/',
|
||||
needPlus: true,
|
||||
})
|
||||
export class ServerChanNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'slack',
|
||||
title: 'Slack通知',
|
||||
desc: 'Slack消息推送通知',
|
||||
needPlus: true,
|
||||
})
|
||||
export class SlackNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'telegram',
|
||||
title: 'Telegram通知',
|
||||
desc: 'Telegram Bot推送通知',
|
||||
needPlus: true,
|
||||
})
|
||||
export class TelegramNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
|
||||
name: 'vocechat',
|
||||
title: 'VoceChat通知',
|
||||
desc: 'https://voce.chat',
|
||||
needPlus: true,
|
||||
})
|
||||
export class VoceChatNotification extends BaseNotification {
|
||||
@NotificationInput({
|
||||
|
||||
@@ -5,6 +5,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
title: 'dnspod(已废弃)',
|
||||
desc: '腾讯云的域名解析接口已迁移到dnspod',
|
||||
deprecated: 'dnspod已废弃,请换成腾讯云',
|
||||
icon: 'svg:icon-tencentcloud',
|
||||
})
|
||||
export class DnspodAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import { DnspodAccess } from '../access/index.js';
|
||||
desc: '已废弃,请尽快换成腾讯云类型',
|
||||
accessType: 'dnspod',
|
||||
deprecated: 'dnspod已废弃,请换成腾讯云',
|
||||
icon: 'svg:icon-tencentcloud',
|
||||
})
|
||||
export class DnspodDnsProvider extends AbstractDnsProvider {
|
||||
@Autowire()
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ import { TencentAccess } from '@certd/plugin-plus';
|
||||
title: '腾讯云',
|
||||
desc: '腾讯云域名DNS解析提供者',
|
||||
accessType: 'tencent',
|
||||
icon: 'svg:icon-tencentcloud',
|
||||
})
|
||||
export class TencentDnsProvider extends AbstractDnsProvider {
|
||||
@Autowire()
|
||||
|
||||
@@ -8,6 +8,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
name: 'west',
|
||||
title: '西部数码授权',
|
||||
desc: '',
|
||||
icon: 'tabler:map-west',
|
||||
})
|
||||
export class WestAccess extends BaseAccess {
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ type westRecord = {
|
||||
name: 'west',
|
||||
title: '西部数码',
|
||||
desc: 'west dns provider',
|
||||
icon: 'tabler:map-west',
|
||||
// 这里是对应的云平台的access类型名称
|
||||
accessType: 'west',
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
name: 'woai',
|
||||
title: '我爱云授权',
|
||||
desc: '我爱云CDN',
|
||||
icon: 'clarity:plugin-line',
|
||||
})
|
||||
export class WoaiAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
|
||||
Reference in New Issue
Block a user