mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 调整全部静态资源到static目录
This commit is contained in:
@@ -1 +1,2 @@
|
||||
export * from './settings/index.js';
|
||||
export * from './plus/index.js';
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from './service/plus-service.js';
|
||||
@@ -0,0 +1,78 @@
|
||||
import { Config, Init, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { AppKey, http, PlusRequestService, verify } from '@certd/pipeline';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js';
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class PlusService {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Config('plus.server.baseUrls')
|
||||
plusServerBaseUrls: string[];
|
||||
|
||||
plusRequestService: PlusRequestService;
|
||||
|
||||
@Init()
|
||||
async init() {
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
this.plusRequestService = new PlusRequestService({
|
||||
plusServerBaseUrls: this.plusServerBaseUrls,
|
||||
http: http,
|
||||
logger,
|
||||
subjectId: installInfo.siteId,
|
||||
});
|
||||
}
|
||||
|
||||
async requestWithoutSign(config: any) {
|
||||
return await this.plusRequestService.requestWithoutSign(config);
|
||||
}
|
||||
async request(config: any) {
|
||||
return await this.plusRequestService.request(config);
|
||||
}
|
||||
|
||||
async active(formData: { code: any; appKey: string; subjectId: string }) {
|
||||
return await this.plusRequestService.requestWithoutSign({
|
||||
url: '/activation/active',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
});
|
||||
}
|
||||
|
||||
async updateLicense(license: string) {
|
||||
let licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
if (!licenseInfo) {
|
||||
licenseInfo = new SysLicenseInfo();
|
||||
}
|
||||
licenseInfo.license = license;
|
||||
await this.sysSettingsService.saveSetting(licenseInfo);
|
||||
const verifyRes = await this.verify();
|
||||
if (!verifyRes.isPlus) {
|
||||
const message = verifyRes.message || '授权码校验失败';
|
||||
logger.error(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
async verify() {
|
||||
const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
|
||||
return await verify({
|
||||
subjectId: installInfo.siteId,
|
||||
license: licenseInfo.license,
|
||||
plusRequestService: this.plusRequestService,
|
||||
bindUrl: installInfo?.bindUrl,
|
||||
});
|
||||
}
|
||||
|
||||
async bindUrl(subjectId: string, url: string) {
|
||||
return await this.plusRequestService.request({
|
||||
url: '/activation/subject/urlBind',
|
||||
data: {
|
||||
subjectId,
|
||||
appKey: AppKey,
|
||||
url,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ export class SysPublicSettings extends BaseSettings {
|
||||
static __access__ = 'public';
|
||||
registerEnabled = false;
|
||||
managerOtherUserPipeline = false;
|
||||
icpNo?: string;
|
||||
// triggerOnStartup = false;
|
||||
}
|
||||
|
||||
@@ -48,8 +49,7 @@ export class SysSiteInfo extends BaseSettings {
|
||||
static __title__ = '站点信息';
|
||||
static __key__ = 'sys.site';
|
||||
static __access__ = 'public';
|
||||
TITLE?: string;
|
||||
SLOGAN?: string;
|
||||
LOGO?: string;
|
||||
ICP_NO?: string;
|
||||
title?: string;
|
||||
slogan?: string;
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user