perf: 新增代理设置功能

This commit is contained in:
xiaojunnuo
2024-10-12 16:49:49 +08:00
parent 9b68009eb3
commit 273ab6139f
13 changed files with 189 additions and 113 deletions
@@ -24,13 +24,21 @@ export class SysPrivateSettings extends BaseSettings {
static __key__ = 'sys.private';
jwtKey?: string;
encryptSecret?: string;
httpsProxy? = '';
httpProxy? = '';
removeSecret() {
delete this.jwtKey;
delete this.encryptSecret;
}
}
export class SysInstallInfo extends BaseSettings {
static __title__ = '系统安装信息';
static __key__ = 'sys.install';
static __access__ = 'private';
installTime: number;
installTime?: number;
siteId?: string;
bindUserId?: number;
bindUrl?: string;
@@ -7,6 +7,7 @@ import { BaseSettings, SysPrivateSettings, SysPublicSettings } from './models.js
import * as _ from 'lodash-es';
import { BaseService } from '../../../basic/index.js';
import { isComm } from '@certd/pipeline';
import { setGlobalProxy } from '@certd/basic';
/**
* 设置
@@ -118,8 +119,25 @@ export class SysSettingsService extends BaseService<SysSettingsEntity> {
await this.saveSetting(bean);
}
async getPrivateSettings(): Promise<SysPrivateSettings> {
return await this.getSetting(SysPrivateSettings);
}
async savePrivateSettings(bean: SysPrivateSettings) {
this.saveSetting(bean);
await this.saveSetting(bean);
//让设置生效
await this.reloadPrivateSettings();
}
async reloadPrivateSettings() {
const bean = await this.getPrivateSettings();
if (bean.httpProxy || bean.httpsProxy) {
setGlobalProxy({
httpProxy: bean.httpProxy,
httpsProxy: bean.httpsProxy,
});
}
}
async updateByKey(key: string, setting: any) {