mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
chore:
This commit is contained in:
@@ -170,7 +170,7 @@ export const useSettingStore = defineStore({
|
||||
},
|
||||
async loadSiteInfo() {
|
||||
const isComm = this.isComm;
|
||||
let siteInfo: SiteInfo;
|
||||
let siteInfo: SiteInfo = {};
|
||||
if (isComm) {
|
||||
siteInfo = await basicApi.getSiteInfo();
|
||||
if (siteInfo.logo) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export async function SettingsGet(key: string) {
|
||||
}
|
||||
|
||||
export async function SettingsSave(key: string, setting: any) {
|
||||
await request({
|
||||
return await request({
|
||||
url: apiPrefix + "/save",
|
||||
method: "post",
|
||||
data: {
|
||||
@@ -29,14 +29,14 @@ export async function SettingsSave(key: string, setting: any) {
|
||||
}
|
||||
|
||||
export async function EmailSettingsGet() {
|
||||
await request({
|
||||
return await request({
|
||||
url: apiPrefix + "/getEmailSettings",
|
||||
method: "post"
|
||||
});
|
||||
}
|
||||
|
||||
export async function PublicSettingsSave(setting: any) {
|
||||
await request({
|
||||
return await request({
|
||||
url: apiPrefix + "/savePublicSettings",
|
||||
method: "post",
|
||||
data: setting
|
||||
@@ -44,7 +44,7 @@ export async function PublicSettingsSave(setting: any) {
|
||||
}
|
||||
|
||||
export async function stopOtherUserTimer() {
|
||||
await request({
|
||||
return await request({
|
||||
url: apiPrefix + "/stopOtherUserTimer",
|
||||
method: "post"
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ import { SettingKeys } from "./api";
|
||||
import * as emailApi from "./api.email";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { useSettingStore } from "/src/store/modules/settings";
|
||||
|
||||
import _ from "lodash-es";
|
||||
defineOptions({
|
||||
name: "EmailSetting"
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
typeorm:
|
||||
dataSource:
|
||||
default:
|
||||
database: './data/db4.sqlite'
|
||||
database: './data/db.sqlite'
|
||||
plus:
|
||||
server:
|
||||
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 type SMTPConnection from 'nodemailer/lib/smtp-connection';
|
||||
import { UserSettingsService } from '../../mine/service/user-settings-service.js';
|
||||
import { PlusService, SysEmailConf, SysSettingsService } from '@certd/lib-server';
|
||||
import { merge } from 'lodash-es';
|
||||
import { PlusService, SysSettingsService } from '@certd/lib-server';
|
||||
import { getEmailSettings } from '../../sys/settings/fix.js';
|
||||
|
||||
export type EmailConfig = {
|
||||
host: string;
|
||||
@@ -60,17 +60,9 @@ export class EmailService implements IEmailService {
|
||||
async send(email: EmailSend) {
|
||||
logger.info('sendEmail', email);
|
||||
|
||||
const emailConf = await this.sysSettingsService.getSetting<SysEmailConf>(SysEmailConf);
|
||||
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);
|
||||
}
|
||||
}
|
||||
const emailConf = await getEmailSettings(this.sysSettingsService, this.settingsService);
|
||||
|
||||
if (!emailConf.host) {
|
||||
if (!emailConf.host && emailConf.usePlus == null) {
|
||||
if (isPlus()) {
|
||||
//自动使用plus发邮件
|
||||
return await this.sendByPlus(email);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { CrudController, SysEmailConf } from '@certd/lib-server';
|
||||
import { SysSettingsService } from '@certd/lib-server';
|
||||
import { CrudController, SysPublicSettings, SysSettingsService } from '@certd/lib-server';
|
||||
import { SysSettingsEntity } from '../entity/sys-settings.js';
|
||||
import { SysPublicSettings } from '@certd/lib-server';
|
||||
import * as _ from 'lodash-es';
|
||||
import { PipelineService } from '../../../pipeline/service/pipeline-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
|
||||
@Post('/getEmailSettings', { summary: 'sys:settings:edit' })
|
||||
async getEmailSettings(@Body(ALL) body) {
|
||||
let conf = await this.service.getSetting<SysEmailConf>(SysEmailConf);
|
||||
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);
|
||||
}
|
||||
}
|
||||
const conf = await getEmailSettings(this.service, this.userSettingsService);
|
||||
return this.ok(conf);
|
||||
}
|
||||
|
||||
|
||||
17
packages/ui/certd-server/src/modules/sys/settings/fix.ts
Normal file
17
packages/ui/certd-server/src/modules/sys/settings/fix.ts
Normal file
@@ -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