diff --git a/packages/core/pipeline/src/core/license.ts b/packages/core/pipeline/src/core/license.ts index 0c145b31..ea659c81 100644 --- a/packages/core/pipeline/src/core/license.ts +++ b/packages/core/pipeline/src/core/license.ts @@ -1,9 +1,10 @@ import { createVerify } from "node:crypto"; import { logger } from "../utils/index.js"; +import dayjs from "dayjs"; const SecreteKey = - "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQkNnS0NBUUVBMjdoZDM0NjRYbyt3TkpmTTNCWjE5MXlQK2NLaTd3ck9CbXdjTWJPZUdsNlJOMUVtTGhyMgplOFdvOGpmMW9IVXc5RFV6L2I2ZHU3Q3ZXMXZNUDA1Q3dSS3lNd2U3Q1BYRGQ2U01mSkwxRFZyUkw5Ylh0cEYzCjJkQVA5UENrakFJcFMvRE5jVkhLRXk1QW8yMnFFenpTKzlUT0JVY2srREdZcmo4KzI5U3h2aEZDRE5ZbEE2d1EKbEkyRWc5TWNBV2xDU3p1S1JWa2ZWUWdYVlU3SmE5OXp1Um1oWWtYZjFxQzBLcVAwQkpDakdDNEV6ZHorMmwyaAo2T3RxVHVVLzRkemlYYnRMUS8vU0JqNEgxdi9PZ3dUZjJkSVBjUnRHOXlWVTB2ZlQzVzdUTkdlMjU3em5ESDBYCkd6Wm4zdWJxTXJuL084b2ltMHRrS3ZHZXZ1V2ZraWNwVVFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg=="; -export const appKey = "GGtrKRWRknFdIID0rW"; + "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQXY3TGtMaUp1dGM0NzhTU3RaTExjajVGZXh1YjJwR2NLMGxwa0hwVnlZWjhMY29rRFhuUlAKUGQ5UlJSTVRTaGJsbFl2Mzd4QUhOV1ZIQ0ZsWHkrQklVU001bUlBU1NDQTV0azlJNmpZZ2F4bEFDQm1BY0lGMwozKzBjeGZIYVkrVW9YdVluMkZ6YUt2Ym5GdFZIZ0lkMDg4a3d4clZTZzlCT3BDRVZIR1pxR2I5TWN5MXVHVXhUClFTVENCbmpoTWZlZ0p6cXVPYWVOY0ZPSE5tbmtWRWpLTythbTBPeEhNS1lyS3ZnQnVEbzdoVnFENlBFMUd6V3AKZHdwZUV4QXZDSVJxL2pWTkdRK3FtMkRWOVNJZ3U5bmF4MktmSUtFeU50dUFFS1VpekdqL0VmRFhDM1cxMExhegpKaGNYNGw1SUFZU1o3L3JWVmpGbExWSVl0WDU1T054L1Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K"; +export const appKey = "z4nXOeTeSnnpUpnmsV"; export type LicenseVerifyReq = { subjectId: string; license: string; @@ -40,7 +41,7 @@ class LicenseVerifier { } setPlus(value: boolean, info: any = {}) { - if (value && !info) { + if (value && info) { holder.isPlus = true; holder.expireTime = info.expireTime; holder.level = info.level; @@ -71,7 +72,10 @@ class LicenseVerifier { logger.warn("授权已过期"); return this.setPlus(false, { message: "授权已过期" }); } - const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.activeTime},${json.duration},${json.expireTime},${json.version}`; + const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.level},${json.activeTime},${json.duration},${json.expireTime},${json.version}`; + // content := fmt.Sprintf("%s,%s,%s,%s,%d,%d,%d,%d,%d", entity.AppKey, entity.SubjectId, entity.Code, entity.Secret, entity.Level, entity.ActiveTime, entity.Duration, entity.ExpireTime, entity.Version) + //z4nXOeTeSnnpUpnmsV,_m9jFTdNHktdaEN4xBDw_,HZz7rAAR3h3zGlDMhScO1wGBYPjXpZ9S_1,uUpr9I8p6K3jWSzu2Wh5NECvgG2FNynU,0,1724199847470,365,1787271324416,1 + logger.debug("content:", content); const publicKey = Buffer.from(SecreteKey, "base64").toString(); const res = this.verifySignature(content, json.signature, publicKey); this.checked = true; @@ -79,6 +83,7 @@ class LicenseVerifier { logger.warn("授权校验失败"); return this.setPlus(false, { message: "授权校验失败" }); } + logger.info(`授权校验成功,到期时间:${dayjs(json.expireTime).format("YYYY-MM-DD HH:mm:ss")}`); return this.setPlus(true, { expireTime: json.expireTime, level: json.level || 1, diff --git a/packages/core/pipeline/src/utils/util.request.ts b/packages/core/pipeline/src/utils/util.request.ts index 874a91b1..2efd0fa1 100644 --- a/packages/core/pipeline/src/utils/util.request.ts +++ b/packages/core/pipeline/src/utils/util.request.ts @@ -53,8 +53,7 @@ export function createAxiosService({ logger }: { logger: Logger }) { logger.error(`请求出错:url:${error?.response?.config.url},method:${error?.response?.config?.method},status:${error?.response?.status}`); logger.info("返回数据:", JSON.stringify(error?.response?.data)); delete error.config; - delete error.response; - return Promise.reject(error); + return Promise.reject(error.response || error); } ); return service; diff --git a/packages/ui/certd-client/src/layout/components/vip-info/index.vue b/packages/ui/certd-client/src/layout/components/vip-info/index.vue index d45e49ac..47b0ab9b 100644 --- a/packages/ui/certd-client/src/layout/components/vip-info/index.vue +++ b/packages/ui/certd-client/src/layout/components/vip-info/index.vue @@ -4,8 +4,10 @@
- 专业版 - {{ expireTime }} + + + 专业版 + 当前免费版
@@ -55,8 +57,9 @@ function openUpgrade() {
diff --git a/packages/ui/certd-server/src/modules/system/controller/plus-controller.ts b/packages/ui/certd-server/src/modules/system/controller/plus-controller.ts index 0c31ee80..e03f1068 100644 --- a/packages/ui/certd-server/src/modules/system/controller/plus-controller.ts +++ b/packages/ui/certd-server/src/modules/system/controller/plus-controller.ts @@ -1,9 +1,10 @@ import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core'; import { SysSettingsService } from '../service/sys-settings-service.js'; import { BaseController } from '../../../basic/base-controller.js'; -import { appKey, utils, verify } from '@certd/pipeline'; +import { appKey, verify } from '@certd/pipeline'; import { SysInstallInfo, SysLicenseInfo } from '../service/models.js'; import { logger } from '../../../utils/logger.js'; +import { request } from '../../../utils/http.js'; /** */ @@ -22,8 +23,9 @@ export class SysPlusController extends BaseController { code, subjectId: installInfo.siteId, }; - const res: any = await utils.http({ - url: 'https://api.ai.handsfree.work/activation/active', + + const res: any = await request({ + url: 'http://localhost:11007/activation/active', method: 'post', data: formData, }); diff --git a/packages/ui/certd-server/src/utils/http.ts b/packages/ui/certd-server/src/utils/http.ts new file mode 100644 index 00000000..18ad7fc2 --- /dev/null +++ b/packages/ui/certd-server/src/utils/http.ts @@ -0,0 +1,13 @@ +import { utils } from '@certd/pipeline'; + +export async function request(config: any) { + try { + return await utils.http(config); + } catch (e) { + const data = e.data || e.response?.data; + if (data) { + throw new Error(data.message || data.msg || data.error || data); + } + throw e; + } +}