mirror of
https://github.com/certd/certd.git
synced 2026-04-26 22:07:29 +08:00
chore:
This commit is contained in:
@@ -170,7 +170,7 @@ export const useSettingStore = defineStore({
|
|||||||
},
|
},
|
||||||
async loadSiteInfo() {
|
async loadSiteInfo() {
|
||||||
const isComm = this.isComm;
|
const isComm = this.isComm;
|
||||||
let siteInfo: SiteInfo;
|
let siteInfo: SiteInfo = {};
|
||||||
if (isComm) {
|
if (isComm) {
|
||||||
siteInfo = await basicApi.getSiteInfo();
|
siteInfo = await basicApi.getSiteInfo();
|
||||||
if (siteInfo.logo) {
|
if (siteInfo.logo) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export async function SettingsGet(key: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function SettingsSave(key: string, setting: any) {
|
export async function SettingsSave(key: string, setting: any) {
|
||||||
await request({
|
return await request({
|
||||||
url: apiPrefix + "/save",
|
url: apiPrefix + "/save",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: {
|
data: {
|
||||||
@@ -29,14 +29,14 @@ export async function SettingsSave(key: string, setting: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function EmailSettingsGet() {
|
export async function EmailSettingsGet() {
|
||||||
await request({
|
return await request({
|
||||||
url: apiPrefix + "/getEmailSettings",
|
url: apiPrefix + "/getEmailSettings",
|
||||||
method: "post"
|
method: "post"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function PublicSettingsSave(setting: any) {
|
export async function PublicSettingsSave(setting: any) {
|
||||||
await request({
|
return await request({
|
||||||
url: apiPrefix + "/savePublicSettings",
|
url: apiPrefix + "/savePublicSettings",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: setting
|
data: setting
|
||||||
@@ -44,7 +44,7 @@ export async function PublicSettingsSave(setting: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function stopOtherUserTimer() {
|
export async function stopOtherUserTimer() {
|
||||||
await request({
|
return await request({
|
||||||
url: apiPrefix + "/stopOtherUserTimer",
|
url: apiPrefix + "/stopOtherUserTimer",
|
||||||
method: "post"
|
method: "post"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ import { SettingKeys } from "./api";
|
|||||||
import * as emailApi from "./api.email";
|
import * as emailApi from "./api.email";
|
||||||
import { notification } from "ant-design-vue";
|
import { notification } from "ant-design-vue";
|
||||||
import { useSettingStore } from "/src/store/modules/settings";
|
import { useSettingStore } from "/src/store/modules/settings";
|
||||||
|
import _ from "lodash-es";
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "EmailSetting"
|
name: "EmailSetting"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
typeorm:
|
typeorm:
|
||||||
dataSource:
|
dataSource:
|
||||||
default:
|
default:
|
||||||
database: './data/db4.sqlite'
|
database: './data/db.sqlite'
|
||||||
plus:
|
plus:
|
||||||
server:
|
server:
|
||||||
baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
|
baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { IEmailService, isPlus, logger } from '@certd/pipeline';
|
|||||||
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, SysEmailConf, SysSettingsService } from '@certd/lib-server';
|
import { PlusService, SysSettingsService } from '@certd/lib-server';
|
||||||
import { merge } from 'lodash-es';
|
import { getEmailSettings } from '../../sys/settings/fix.js';
|
||||||
|
|
||||||
export type EmailConfig = {
|
export type EmailConfig = {
|
||||||
host: string;
|
host: string;
|
||||||
@@ -60,17 +60,9 @@ export class EmailService implements IEmailService {
|
|||||||
async send(email: EmailSend) {
|
async send(email: EmailSend) {
|
||||||
logger.info('sendEmail', email);
|
logger.info('sendEmail', email);
|
||||||
|
|
||||||
const emailConf = await this.sysSettingsService.getSetting<SysEmailConf>(SysEmailConf);
|
const emailConf = await getEmailSettings(this.sysSettingsService, this.settingsService);
|
||||||
if (!emailConf.host && emailConf.usePlus != null) {
|
|
||||||
const emailConfigEntity = await this.settingsService.getByKey('email', 1);
|
|
||||||
if (emailConfigEntity) {
|
|
||||||
const emailConfig = JSON.parse(emailConfigEntity.setting) as EmailConfig;
|
|
||||||
merge(emailConf, emailConfig);
|
|
||||||
await this.sysSettingsService.saveSetting(emailConf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!emailConf.host) {
|
if (!emailConf.host && emailConf.usePlus == null) {
|
||||||
if (isPlus()) {
|
if (isPlus()) {
|
||||||
//自动使用plus发邮件
|
//自动使用plus发邮件
|
||||||
return await this.sendByPlus(email);
|
return await this.sendByPlus(email);
|
||||||
|
|||||||
+3
-13
@@ -1,11 +1,10 @@
|
|||||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||||
import { CrudController, SysEmailConf } from '@certd/lib-server';
|
import { CrudController, SysPublicSettings, SysSettingsService } from '@certd/lib-server';
|
||||||
import { SysSettingsService } from '@certd/lib-server';
|
|
||||||
import { SysSettingsEntity } from '../entity/sys-settings.js';
|
import { SysSettingsEntity } from '../entity/sys-settings.js';
|
||||||
import { SysPublicSettings } from '@certd/lib-server';
|
|
||||||
import * as _ from 'lodash-es';
|
import * as _ from 'lodash-es';
|
||||||
import { PipelineService } from '../../../pipeline/service/pipeline-service.js';
|
import { PipelineService } from '../../../pipeline/service/pipeline-service.js';
|
||||||
import { UserSettingsService } from '../../../mine/service/user-settings-service.js';
|
import { UserSettingsService } from '../../../mine/service/user-settings-service.js';
|
||||||
|
import { getEmailSettings } from '../fix.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@@ -74,16 +73,7 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
|||||||
// savePublicSettings
|
// savePublicSettings
|
||||||
@Post('/getEmailSettings', { summary: 'sys:settings:edit' })
|
@Post('/getEmailSettings', { summary: 'sys:settings:edit' })
|
||||||
async getEmailSettings(@Body(ALL) body) {
|
async getEmailSettings(@Body(ALL) body) {
|
||||||
let conf = await this.service.getSetting<SysEmailConf>(SysEmailConf);
|
const conf = await getEmailSettings(this.service, this.userSettingsService);
|
||||||
if (!conf.host && conf.usePlus != null) {
|
|
||||||
//到userSetting里面去找
|
|
||||||
const adminEmailSetting = await this.userSettingsService.getByKey('email', 1);
|
|
||||||
if (adminEmailSetting) {
|
|
||||||
const setting = JSON.parse(adminEmailSetting.setting);
|
|
||||||
conf = _.merge(conf, setting);
|
|
||||||
await this.service.saveSetting(conf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.ok(conf);
|
return this.ok(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { SysEmailConf, SysSettingsService } from '@certd/lib-server';
|
||||||
|
import * as _ from 'lodash-es';
|
||||||
|
import { UserSettingsService } from '../../mine/service/user-settings-service.js';
|
||||||
|
|
||||||
|
export async function getEmailSettings(sysSettingService: SysSettingsService, userSettingsService: UserSettingsService): Promise<SysEmailConf> {
|
||||||
|
let conf = await sysSettingService.getSetting<SysEmailConf>(SysEmailConf);
|
||||||
|
if (!conf.host || conf.usePlus == null) {
|
||||||
|
//到userSetting里面去找
|
||||||
|
const adminEmailSetting = await userSettingsService.getByKey('email', 1);
|
||||||
|
if (adminEmailSetting) {
|
||||||
|
const setting = JSON.parse(adminEmailSetting.setting);
|
||||||
|
conf = _.merge(conf, setting);
|
||||||
|
await sysSettingService.saveSetting(conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user