From c3d6db3f1ef2f1c897b7989521fe8809dffaded1 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 7 Jul 2026 14:15:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DAsiaIsp=20CDN=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E9=87=8D=E5=A4=8D=E6=83=85=E5=86=B5=E4=B8=8B=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/certd-server/src/configuration.ts | 1 - .../src/plugins/plugin-asiaisp/client.ts | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/packages/ui/certd-server/src/configuration.ts b/packages/ui/certd-server/src/configuration.ts index 0c6a20414..be3e1c8bd 100644 --- a/packages/ui/certd-server/src/configuration.ts +++ b/packages/ui/certd-server/src/configuration.ts @@ -132,7 +132,6 @@ export class MainConfiguration { logger.info(text); }); logger.info("当前环境:", this.app.getEnv()); // prod - } } diff --git a/packages/ui/certd-server/src/plugins/plugin-asiaisp/client.ts b/packages/ui/certd-server/src/plugins/plugin-asiaisp/client.ts index 44daa8793..b5006ff95 100644 --- a/packages/ui/certd-server/src/plugins/plugin-asiaisp/client.ts +++ b/packages/ui/certd-server/src/plugins/plugin-asiaisp/client.ts @@ -114,14 +114,20 @@ export class AsiaIspClient { if (response.code !== "0") { this.logger.error(`接口请求失败: code=${response.code}, msg=${response.msg}`); - throw new Error(response.msg || "接口请求失败"); + const e= new Error(response.msg || "接口请求失败"); + // @ts-ignore + e.errorCode = response.code; + throw e; } return response; } catch (error: any) { - if (error.message && !error.message.includes("接口请求失败")) { - this.logger.error(`接口请求异常: ${error.message}`); - throw new Error(`接口请求异常: ${error.message}`); + const response = error.response + if (response && response.data) { + const e = new Error(response.data.msg || error.message || "接口请求失败"); + // @ts-ignore + e.errorCode = response.data.code; + throw e; } throw error; } @@ -189,7 +195,7 @@ export class AsiaIspClient { return certId; } catch (e: any) { const msg = e.message || ""; - const isExists = msg.includes("Certificate already exists") || e.code === "80003" || msg.includes("Certificate note name already exists") || e.code === "80010"; + const isExists = msg.includes("Certificate already exists") || e.errorCode === "80003" || msg.includes("Certificate note name already exists") || e.errorCode === "80010"; //返回数据: {"code":"80010","msg":"Certificate note name already exists","data":null} if (!isExists) { throw e; @@ -224,15 +230,23 @@ export class AsiaIspClient { * PUT /openapi/v3/stat?action=domainModify */ async deployCertToDomain(req: { domain: string; certId: number; protocol: string }): Promise { - await this.doRequest({ - method: "PUT", - action: "domainModify", - data: { - domain: req.domain, - certId: `${req.certId}`, - protocol: req.protocol || "https", - }, - }); + try { + await this.doRequest({ + method: "PUT", + action: "domainModify", + data: { + domain: req.domain, + certId: `${req.certId}`, + protocol: req.protocol || "https", + }, + }); + } catch (e: any) { + if (e.errorCode === "50024") { + this.logger.info(`域名 ${req.domain} 已绑定该证书 ${req.certId},无需重复绑定`); + return; + } + throw e + } this.logger.info(`部署证书到域名成功: ${req.domain}, certId=${req.certId}`); } }