mirror of https://github.com/certd/certd
perf: 新增代理设置功能
parent
9b68009eb3
commit
273ab6139f
|
@ -47,6 +47,21 @@ export class HttpError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HttpCommonError = HttpError;
|
export const HttpCommonError = HttpError;
|
||||||
|
|
||||||
|
let defaultAgents = createAgent();
|
||||||
|
|
||||||
|
export function setGlobalProxy(opts: { httpProxy?: string; httpsProxy?: string }) {
|
||||||
|
logger.info('setGlobalProxy:', opts);
|
||||||
|
if (opts.httpProxy) {
|
||||||
|
process.env.HTTP_PROXY = opts.httpProxy;
|
||||||
|
}
|
||||||
|
if (opts.httpsProxy) {
|
||||||
|
process.env.HTTPS_PROXY = opts.httpsProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultAgents = createAgent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 创建请求实例
|
* @description 创建请求实例
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +69,6 @@ export function createAxiosService({ logger }: { logger: Logger }) {
|
||||||
// 创建一个 axios 实例
|
// 创建一个 axios 实例
|
||||||
const service = axios.create();
|
const service = axios.create();
|
||||||
|
|
||||||
const defaultAgents = createAgent();
|
|
||||||
// 请求拦截
|
// 请求拦截
|
||||||
service.interceptors.request.use(
|
service.interceptors.request.use(
|
||||||
(config: any) => {
|
(config: any) => {
|
||||||
|
|
|
@ -24,13 +24,21 @@ export class SysPrivateSettings extends BaseSettings {
|
||||||
static __key__ = 'sys.private';
|
static __key__ = 'sys.private';
|
||||||
jwtKey?: string;
|
jwtKey?: string;
|
||||||
encryptSecret?: string;
|
encryptSecret?: string;
|
||||||
|
|
||||||
|
httpsProxy? = '';
|
||||||
|
httpProxy? = '';
|
||||||
|
|
||||||
|
removeSecret() {
|
||||||
|
delete this.jwtKey;
|
||||||
|
delete this.encryptSecret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SysInstallInfo extends BaseSettings {
|
export class SysInstallInfo extends BaseSettings {
|
||||||
static __title__ = '系统安装信息';
|
static __title__ = '系统安装信息';
|
||||||
static __key__ = 'sys.install';
|
static __key__ = 'sys.install';
|
||||||
static __access__ = 'private';
|
static __access__ = 'private';
|
||||||
installTime: number;
|
installTime?: number;
|
||||||
siteId?: string;
|
siteId?: string;
|
||||||
bindUserId?: number;
|
bindUserId?: number;
|
||||||
bindUrl?: string;
|
bindUrl?: string;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { BaseSettings, SysPrivateSettings, SysPublicSettings } from './models.js
|
||||||
import * as _ from 'lodash-es';
|
import * as _ from 'lodash-es';
|
||||||
import { BaseService } from '../../../basic/index.js';
|
import { BaseService } from '../../../basic/index.js';
|
||||||
import { isComm } from '@certd/pipeline';
|
import { isComm } from '@certd/pipeline';
|
||||||
|
import { setGlobalProxy } from '@certd/basic';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置
|
* 设置
|
||||||
|
@ -118,8 +119,25 @@ export class SysSettingsService extends BaseService<SysSettingsEntity> {
|
||||||
await this.saveSetting(bean);
|
await this.saveSetting(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPrivateSettings(): Promise<SysPrivateSettings> {
|
||||||
|
return await this.getSetting(SysPrivateSettings);
|
||||||
|
}
|
||||||
|
|
||||||
async savePrivateSettings(bean: 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) {
|
async updateByKey(key: string, setting: any) {
|
||||||
|
|
|
@ -195,6 +195,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||||
async condition() {
|
async condition() {
|
||||||
if (this.forceUpdate) {
|
if (this.forceUpdate) {
|
||||||
this.logger.info("强制更新证书选项已勾选,准备申请新证书");
|
this.logger.info("强制更新证书选项已勾选,准备申请新证书");
|
||||||
|
this.logger.warn("申请完之后,切记取消强制更新,避免申请过多证书。");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ export type SiteEnv = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export type SiteInfo = {
|
export type SiteInfo = {
|
||||||
title: string;
|
title?: string;
|
||||||
slogan: string;
|
slogan?: string;
|
||||||
logo: string;
|
logo?: string;
|
||||||
loginLogo: string;
|
loginLogo?: string;
|
||||||
icpNo: string;
|
icpNo?: string;
|
||||||
licenseTo?: string;
|
licenseTo?: string;
|
||||||
licenseToUrl?: string;
|
licenseToUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,10 +77,10 @@
|
||||||
<a :href="siteInfo.licenseToUrl || ''">{{ siteInfo.licenseTo }}</a>
|
<a :href="siteInfo.licenseToUrl || ''">{{ siteInfo.licenseTo }}</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="siteInfo.icpNo">
|
<template v-if="sysPublic.icpNo">
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
<span>
|
<span>
|
||||||
<a href="https://beian.miit.gov.cn/" target="_blank">{{ siteInfo.icpNo }}</a>
|
<a href="https://beian.miit.gov.cn/" target="_blank">{{ sysPublic.icpNo }}</a>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,6 +140,9 @@ const userStore = useUserStore();
|
||||||
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
|
|
||||||
|
const sysPublic = computed(() => {
|
||||||
|
return settingStore.sysPublic;
|
||||||
|
});
|
||||||
const siteInfo = computed(() => {
|
const siteInfo = computed(() => {
|
||||||
return settingStore.siteInfo;
|
return settingStore.siteInfo;
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
<a :href="siteInfo.licenseToUrl" target="_blank">{{ siteInfo.licenseTo }}</a>
|
<a :href="siteInfo.licenseToUrl" target="_blank">{{ siteInfo.licenseTo }}</a>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="siteInfo.icpNo">
|
<span v-if="sysPublic.icpNo">
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
<a href="https://beian.miit.gov.cn/" target="_blank">{{ siteInfo.icpNo }}</a>
|
<a href="https://beian.miit.gov.cn/" target="_blank">{{ sysPublic.icpNo }}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -40,13 +40,17 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { env } from "/@/utils/util.env";
|
import { env } from "/@/utils/util.env";
|
||||||
import { computed, ref, Ref } from "vue";
|
import { computed, ref, Ref } from "vue";
|
||||||
import { SiteInfo, useSettingStore } from "/@/store/modules/settings";
|
import { useSettingStore } from "/@/store/modules/settings";
|
||||||
|
import { SiteInfo, SysPublicSetting } from "/@/api/modules/api.basic";
|
||||||
|
|
||||||
const envRef = ref(env);
|
const envRef = ref(env);
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const siteInfo: Ref<SiteInfo> = computed(() => {
|
const siteInfo: Ref<SiteInfo> = computed(() => {
|
||||||
return settingStore.siteInfo;
|
return settingStore.siteInfo;
|
||||||
});
|
});
|
||||||
|
const sysPublic: Ref<SysPublicSetting> = computed(() => {
|
||||||
|
return settingStore.sysPublic;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|
|
@ -44,12 +44,11 @@ const defaultThemeConfig = {
|
||||||
mode: "light"
|
mode: "light"
|
||||||
};
|
};
|
||||||
const SETTING_THEME_KEY = "SETTING_THEME";
|
const SETTING_THEME_KEY = "SETTING_THEME";
|
||||||
const defaultSiteInfo = {
|
const defaultSiteInfo: SiteInfo = {
|
||||||
title: env.TITLE || "Certd",
|
title: env.TITLE || "Certd",
|
||||||
slogan: env.SLOGAN || "让你的证书永不过期",
|
slogan: env.SLOGAN || "让你的证书永不过期",
|
||||||
logo: env.LOGO || "/static/images/logo/logo.svg",
|
logo: env.LOGO || "/static/images/logo/logo.svg",
|
||||||
loginLogo: env.LOGIN_LOGO || "/static/images/logo/rect-block.svg",
|
loginLogo: env.LOGIN_LOGO || "/static/images/logo/rect-block.svg",
|
||||||
icpNo: env.ICP_NO,
|
|
||||||
licenseTo: "",
|
licenseTo: "",
|
||||||
licenseToUrl: ""
|
licenseToUrl: ""
|
||||||
};
|
};
|
||||||
|
@ -69,7 +68,7 @@ export const useSettingStore = defineStore({
|
||||||
sysPublic: {
|
sysPublic: {
|
||||||
registerEnabled: false,
|
registerEnabled: false,
|
||||||
managerOtherUserPipeline: false,
|
managerOtherUserPipeline: false,
|
||||||
icpNo: ""
|
icpNo: env.ICP_NO || ""
|
||||||
},
|
},
|
||||||
installInfo: {
|
installInfo: {
|
||||||
siteId: "",
|
siteId: "",
|
||||||
|
@ -148,11 +147,6 @@ export const useSettingStore = defineStore({
|
||||||
siteInfo.loginLogo = `/api/basic/file/download?key=${siteInfo.loginLogo}`;
|
siteInfo.loginLogo = `/api/basic/file/download?key=${siteInfo.loginLogo}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const sysPublic = this.getSysPublic;
|
|
||||||
if (sysPublic.icpNo) {
|
|
||||||
siteInfo.icpNo = sysPublic.icpNo;
|
|
||||||
}
|
|
||||||
this.siteInfo = _.merge({}, defaultSiteInfo, siteInfo);
|
this.siteInfo = _.merge({}, defaultSiteInfo, siteInfo);
|
||||||
},
|
},
|
||||||
async checkUrlBound() {
|
async checkUrlBound() {
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { request } from "/@/api/service";
|
import { request } from "/@/api/service";
|
||||||
const apiPrefix = "/sys/settings";
|
const apiPrefix = "/sys/settings";
|
||||||
|
export type SysSettings = { public: SysPublicSetting; private: SysPrivateSetting };
|
||||||
|
|
||||||
|
export type SysPublicSetting = {
|
||||||
|
registerEnabled?: boolean;
|
||||||
|
managerOtherUserPipeline?: boolean;
|
||||||
|
icpNo?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SysPrivateSetting = {
|
||||||
|
httpProxy?: string;
|
||||||
|
httpsProxy?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export const SettingKeys = {
|
export const SettingKeys = {
|
||||||
SysPublic: "sys.public",
|
SysPublic: "sys.public",
|
||||||
|
@ -8,13 +20,17 @@ export const SettingKeys = {
|
||||||
SysEmail: "sys.email"
|
SysEmail: "sys.email"
|
||||||
};
|
};
|
||||||
export async function SettingsGet(key: string) {
|
export async function SettingsGet(key: string) {
|
||||||
return await request({
|
const res = await request({
|
||||||
url: apiPrefix + "/get",
|
url: apiPrefix + "/get",
|
||||||
method: "post",
|
method: "post",
|
||||||
params: {
|
params: {
|
||||||
key
|
key
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!res) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return JSON.parse(res.setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function SettingsSave(key: string, setting: any) {
|
export async function SettingsSave(key: string, setting: any) {
|
||||||
|
@ -35,17 +51,24 @@ export async function EmailSettingsGet() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function PublicSettingsSave(setting: any) {
|
|
||||||
return await request({
|
|
||||||
url: apiPrefix + "/savePublicSettings",
|
|
||||||
method: "post",
|
|
||||||
data: setting
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function stopOtherUserTimer() {
|
export async function stopOtherUserTimer() {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/stopOtherUserTimer",
|
url: apiPrefix + "/stopOtherUserTimer",
|
||||||
method: "post"
|
method: "post"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function SysSettingsGet(): Promise<SysSettings> {
|
||||||
|
return await request({
|
||||||
|
url: apiPrefix + "/getSysSettings",
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function SysSettingsSave(data: SysSettings) {
|
||||||
|
return await request({
|
||||||
|
url: apiPrefix + "/saveSysSettings",
|
||||||
|
method: "post",
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -13,29 +13,28 @@
|
||||||
@finish="onFinish"
|
@finish="onFinish"
|
||||||
@finish-failed="onFinishFailed"
|
@finish-failed="onFinishFailed"
|
||||||
>
|
>
|
||||||
<a-form-item label="开启自助注册" name="registerEnabled">
|
<a-form-item label="开启自助注册" :name="['public', 'registerEnabled']">
|
||||||
<a-switch v-model:checked="formState.registerEnabled" />
|
<a-switch v-model:checked="formState.public.registerEnabled" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="管理其他用户流水线" name="managerOtherUserPipeline">
|
<a-form-item label="管理其他用户流水线" :name="['public', 'managerOtherUserPipeline']">
|
||||||
<a-switch v-model:checked="formState.managerOtherUserPipeline" />
|
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="ICP备案号" name="icpNo">
|
<a-form-item label="ICP备案号" :name="['public', 'icpNo']">
|
||||||
<a-input v-model:value="formState.icpNo" />
|
<a-input v-model:value="formState.public.icpNo" placeholder="粤ICP备xxxxxxx号" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="HTTP代理" :name="['private', 'httpProxy']" :rules="urlRules">
|
||||||
|
<a-input v-model:value="formState.private.httpProxy" placeholder="http://192.168.1.2:18010/" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="HTTPS代理" :name="['private', 'httpsProxy']" :rules="urlRules">
|
||||||
|
<a-input v-model:value="formState.private.httpsProxy" placeholder="http://192.168.1.2:18010/" />
|
||||||
|
<div class="helper">一般这两个代理填一样的</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- <a-form-item label="启动后触发流水线" name="triggerOnStartup">-->
|
|
||||||
<!-- <a-switch v-model:checked="formState.triggerOnStartup" />-->
|
|
||||||
<!-- <div class="helper">启动后自动触发一次所有已启用的流水线</div>-->
|
|
||||||
<!-- </a-form-item>-->
|
|
||||||
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
|
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
|
||||||
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
<!-- <a-descriptions label="系统维护操作">-->
|
|
||||||
<!-- <a-descriptions-item label="自动化任务">-->
|
|
||||||
<!-- <a-button @click="stopOtherUserTimer">停止所有其他用户的定时任务</a-button>-->
|
|
||||||
<!-- </a-descriptions-item>-->
|
|
||||||
<!-- </a-descriptions>-->
|
|
||||||
</div>
|
</div>
|
||||||
</fs-page>
|
</fs-page>
|
||||||
</template>
|
</template>
|
||||||
|
@ -43,42 +42,41 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref } from "vue";
|
import { reactive, ref } from "vue";
|
||||||
import * as api from "./api";
|
import * as api from "./api";
|
||||||
import { PublicSettingsSave, SettingKeys } from "./api";
|
import { SysSettings } from "./api";
|
||||||
import { notification } from "ant-design-vue";
|
import { notification } from "ant-design-vue";
|
||||||
import { useSettingStore } from "/@/store/modules/settings";
|
import { useSettingStore } from "/@/store/modules/settings";
|
||||||
|
import { merge } from "lodash-es";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "SysSettings"
|
name: "SysSettings"
|
||||||
});
|
});
|
||||||
|
|
||||||
interface FormState {
|
const formState = reactive<Partial<SysSettings>>({
|
||||||
registerEnabled: boolean;
|
public: {
|
||||||
managerOtherUserPipeline: boolean;
|
registerEnabled: false,
|
||||||
icpNo: string;
|
managerOtherUserPipeline: false,
|
||||||
}
|
icpNo: ""
|
||||||
|
},
|
||||||
const formState = reactive<Partial<FormState>>({
|
private: {}
|
||||||
registerEnabled: false,
|
|
||||||
managerOtherUserPipeline: false,
|
|
||||||
icpNo: ""
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadSysPublicSettings() {
|
const urlRules = ref({
|
||||||
const data: any = await api.SettingsGet(SettingKeys.SysPublic);
|
type: "url",
|
||||||
if (data == null) {
|
message: "请输入正确的URL"
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
const setting = JSON.parse(data.setting);
|
async function loadSysSettings() {
|
||||||
Object.assign(formState, setting);
|
const data: any = await api.SysSettingsGet();
|
||||||
|
merge(formState, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveLoading = ref(false);
|
const saveLoading = ref(false);
|
||||||
loadSysPublicSettings();
|
loadSysSettings();
|
||||||
const settingsStore = useSettingStore();
|
const settingsStore = useSettingStore();
|
||||||
const onFinish = async (form: any) => {
|
const onFinish = async (form: any) => {
|
||||||
try {
|
try {
|
||||||
saveLoading.value = true;
|
saveLoading.value = true;
|
||||||
await api.PublicSettingsSave(form);
|
await api.SysSettingsSave(form);
|
||||||
await settingsStore.loadSysSettings();
|
await settingsStore.loadSysSettings();
|
||||||
notification.success({
|
notification.success({
|
||||||
message: "保存成功"
|
message: "保存成功"
|
||||||
|
|
|
@ -53,6 +53,8 @@ export class AutoInitSite {
|
||||||
await this.sysSettingsService.saveSetting(privateInfo);
|
await this.sysSettingsService.saveSetting(privateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.sysSettingsService.reloadPrivateSettings();
|
||||||
|
|
||||||
// 授权许可
|
// 授权许可
|
||||||
try {
|
try {
|
||||||
await this.plusService.verify();
|
await this.plusService.verify();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ALL, Body, Controller, Get, Inject, Post, Provide } from '@midwayjs/core';
|
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||||
import { BaseController, Constants, PlusService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
|
import { BaseController, PlusService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
|
||||||
import { AppKey, logger, PlusRequestService, verify } from '@certd/pipeline';
|
import { AppKey, logger } from '@certd/pipeline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -51,42 +51,42 @@ export class SysPlusController extends BaseController {
|
||||||
|
|
||||||
return this.ok(true);
|
return this.ok(true);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
@Get('/test', { summary: Constants.per.guest })
|
// @Get('/test', { summary: Constants.per.guest })
|
||||||
async test() {
|
// async test() {
|
||||||
const subjectId = 'vpyoZb6fDBjzzSZp67OBP';
|
// const subjectId = 'xxxxxx';
|
||||||
const license = '';
|
// const license = '';
|
||||||
const timestamps = 1728365013899;
|
// const timestamps = 1728365013899;
|
||||||
const bindUrl = 'http://89.21.0.171:7001/';
|
// const bindUrl = 'http://127.0.0.1:7001/';
|
||||||
const service = new PlusRequestService({
|
// const service = new PlusRequestService({
|
||||||
subjectId: subjectId,
|
// subjectId: subjectId,
|
||||||
plusServerBaseUrls: ['https://api.ai.handsfree.work'],
|
// plusServerBaseUrls: ['https://api.ai.handsfree.work'],
|
||||||
});
|
// });
|
||||||
const body = { subjectId, appKey: 'kQth6FHM71IPV3qdWc', url: bindUrl };
|
// const body = { subjectId, appKey: 'kQth6FHM71IPV3qdWc', url: bindUrl };
|
||||||
|
//
|
||||||
async function test() {
|
// async function test() {
|
||||||
await verify({
|
// await verify({
|
||||||
subjectId: subjectId,
|
// subjectId: subjectId,
|
||||||
license: license,
|
// license: license,
|
||||||
plusRequestService: service,
|
// plusRequestService: service,
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
const res = await service.sign(body, timestamps);
|
// const res = await service.sign(body, timestamps);
|
||||||
console.log('sign:', res);
|
// console.log('sign:', res);
|
||||||
|
//
|
||||||
const res2 = await service.request({
|
// const res2 = await service.request({
|
||||||
url: '/activation/subject/vip/check',
|
// url: '/activation/subject/vip/check',
|
||||||
data: {
|
// data: {
|
||||||
url: 'http://127.0.0.1:7001/',
|
// url: 'http://127.0.0.1:7001/',
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
console.log('res2:', res2);
|
// console.log('res2:', res2);
|
||||||
}
|
// }
|
||||||
console.log('2222');
|
// console.log('2222');
|
||||||
await test();
|
// await test();
|
||||||
console.log('3333');
|
// console.log('3333');
|
||||||
|
//
|
||||||
return this.ok(true);
|
// return this.ok(true);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||||
import { CrudController, SysPublicSettings, SysSettingsService } from '@certd/lib-server';
|
import { CrudController, SysPrivateSettings, SysPublicSettings, SysSettingsService } from '@certd/lib-server';
|
||||||
import { SysSettingsEntity } from '../entity/sys-settings.js';
|
import { SysSettingsEntity } from '../entity/sys-settings.js';
|
||||||
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';
|
||||||
|
@ -77,12 +77,23 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||||
return this.ok(conf);
|
return this.ok(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/getSysSettings', { summary: 'sys:settings:edit' })
|
||||||
|
async getSysSettings() {
|
||||||
|
const publicSettings = await this.service.getPublicSettings();
|
||||||
|
const privateSettings = await this.service.getPrivateSettings();
|
||||||
|
privateSettings.removeSecret();
|
||||||
|
return this.ok({ public: publicSettings, private: privateSettings });
|
||||||
|
}
|
||||||
|
|
||||||
// savePublicSettings
|
// savePublicSettings
|
||||||
@Post('/savePublicSettings', { summary: 'sys:settings:edit' })
|
@Post('/saveSysSettings', { summary: 'sys:settings:edit' })
|
||||||
async savePublicSettings(@Body(ALL) body) {
|
async saveSysSettings(@Body(ALL) body: { public: SysPublicSettings; private: SysPrivateSettings }) {
|
||||||
const setting = new SysPublicSettings();
|
const publicSettings = await this.service.getPublicSettings();
|
||||||
_.merge(setting, body);
|
const privateSettings = await this.service.getPrivateSettings();
|
||||||
await this.service.savePublicSettings(setting);
|
_.merge(publicSettings, body.public);
|
||||||
|
_.merge(privateSettings, body.private);
|
||||||
|
await this.service.savePublicSettings(publicSettings);
|
||||||
|
await this.service.savePrivateSettings(privateSettings);
|
||||||
return this.ok({});
|
return this.ok({});
|
||||||
}
|
}
|
||||||
@Post('/stopOtherUserTimer', { summary: 'sys:settings:edit' })
|
@Post('/stopOtherUserTimer', { summary: 'sys:settings:edit' })
|
||||||
|
|
Loading…
Reference in New Issue