fix: 修复某些情况下bindUrl失败的bug

pull/213/head
xiaojunnuo 2024-10-11 03:13:34 +08:00
parent 4244569211
commit 91fc1cd735
4 changed files with 65 additions and 22 deletions

View File

@ -1,4 +1,4 @@
import { Config, Init, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core'; import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
import { AppKey, PlusRequestService, verify } from '@certd/pipeline'; import { AppKey, PlusRequestService, verify } from '@certd/pipeline';
import { logger } from '@certd/basic'; import { logger } from '@certd/basic';
import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js'; import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js';
@ -11,26 +11,26 @@ export class PlusService {
@Config('plus.server.baseUrls') @Config('plus.server.baseUrls')
plusServerBaseUrls: string[]; plusServerBaseUrls: string[];
plusRequestService: PlusRequestService; async getPlusRequestService() {
@Init()
async init() {
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo); const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
this.plusRequestService = new PlusRequestService({ return new PlusRequestService({
plusServerBaseUrls: this.plusServerBaseUrls, plusServerBaseUrls: this.plusServerBaseUrls,
subjectId: installInfo.siteId, subjectId: installInfo.siteId,
}); });
} }
async requestWithoutSign(config: any) { async requestWithoutSign(config: any) {
return await this.plusRequestService.requestWithoutSign(config); const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.requestWithoutSign(config);
} }
async request(config: any) { async request(config: any) {
return await this.plusRequestService.request(config); const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.request(config);
} }
async active(formData: { code: any; appKey: string; subjectId: string }) { async active(formData: { code: any; appKey: string; subjectId: string }) {
return await this.plusRequestService.requestWithoutSign({ const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.requestWithoutSign({
url: '/activation/active', url: '/activation/active',
method: 'post', method: 'post',
data: formData, data: formData,
@ -55,16 +55,18 @@ export class PlusService {
const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo); const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo); const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
const plusRequestService = await this.getPlusRequestService();
return await verify({ return await verify({
subjectId: installInfo.siteId, subjectId: installInfo.siteId,
license: licenseInfo.license, license: licenseInfo.license,
plusRequestService: this.plusRequestService, plusRequestService: plusRequestService,
bindUrl: installInfo?.bindUrl, bindUrl: installInfo?.bindUrl,
}); });
} }
async bindUrl(subjectId: string, url: string) { async bindUrl(subjectId: string, url: string) {
return await this.plusRequestService.request({ const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.request({
url: '/activation/subject/urlBind', url: '/activation/subject/urlBind',
data: { data: {
subjectId, subjectId,

View File

@ -22,19 +22,19 @@ typeorm:
default: default:
database: './data/db-comm.sqlite' database: './data/db-comm.sqlite'
plus:
server:
baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
account:
server:
baseUrl: 'https://ai.handsfree.work/subject'
#
#plus: #plus:
# server: # server:
# baseUrls: ['http://127.0.0.1:11007'] # baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
# #
#account: #account:
# server: # server:
# baseUrl: 'http://127.0.0.1:1017/subject' # baseUrl: 'https://ai.handsfree.work/subject'
plus:
server:
baseUrls: ['http://127.0.0.1:11007']
account:
server:
baseUrl: 'http://127.0.0.1:1017/subject'

View File

@ -0,0 +1,40 @@
# key: ./data/ssl/cert.key
# cert: ./data/ssl/cert.crt
#plus:
# server:
# baseUrl: 'http://127.0.0.1:11007'
#flyway:
# scriptDir: './db/migration-pg'
#typeorm:
# dataSource:
# default:
# type: postgres
# host: localhost
# port: 5433
# username: postgres
# password: root
# database: postgres
typeorm:
dataSource:
default:
database: './data/db-comm-pro.sqlite'
plus:
server:
baseUrls: ['https://api.ai.handsfree.work', 'https://api.ai.docmirror.cn']
account:
server:
baseUrl: 'https://ai.handsfree.work/subject'
#
#plus:
# server:
# baseUrls: ['http://127.0.0.1:11007']
#
#account:
# server:
# baseUrl: 'http://127.0.0.1:1017/subject'

View File

@ -8,6 +8,7 @@
"start": "cross-env NODE_ENV=production node ./bootstrap.js", "start": "cross-env NODE_ENV=production node ./bootstrap.js",
"dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app", "dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app",
"commdev": "cross-env NODE_ENV=commdev mwtsc --watch --run @midwayjs/mock/app", "commdev": "cross-env NODE_ENV=commdev mwtsc --watch --run @midwayjs/mock/app",
"commpro": "cross-env NODE_ENV=commpro mwtsc --watch --run @midwayjs/mock/app",
"pgdev": "cross-env NODE_ENV=pgdev mwtsc --watch --run @midwayjs/mock/app", "pgdev": "cross-env NODE_ENV=pgdev mwtsc --watch --run @midwayjs/mock/app",
"test": "cross-env NODE_ENV=unittest mocha", "test": "cross-env NODE_ENV=unittest mocha",
"cov": "cross-env c8 --all --reporter=text --reporter=lcovonly npm run test", "cov": "cross-env c8 --all --reporter=text --reporter=lcovonly npm run test",