fix: 修复火山引擎查不到自定义源站域名的问题

This commit is contained in:
xiaojunnuo
2026-07-09 16:39:08 +08:00
parent 58024128d8
commit 02dabe11db
3 changed files with 45 additions and 35 deletions
@@ -65,7 +65,7 @@ export class MineController extends BaseController {
user.needInitAccount = true; user.needInitAccount = true;
} }
} }
return this.ok(user); return this.ok(user);
} }
@@ -150,7 +150,7 @@ export class MineController extends BaseController {
@Post("/accountInit", { description: Constants.per.authOnly, summary: "初始化Let's Encrypt ACME账号和邮件通知" }) @Post("/accountInit", { description: Constants.per.authOnly, summary: "初始化Let's Encrypt ACME账号和邮件通知" })
public async accountInit(@Body("email") email?: string) { public async accountInit(@Body("email") email?: string) {
let userId = this.getUserId(); const userId = this.getUserId();
let userEmail = email; let userEmail = email;
let user: any = null; let user: any = null;
if (!userEmail) { if (!userEmail) {
@@ -190,7 +190,7 @@ export class MineController extends BaseController {
type: "acmeAccount", type: "acmeAccount",
name: "Let's Encrypt", name: "Let's Encrypt",
userId, userId,
projectId:undefined, projectId: undefined,
setting: JSON.stringify({ setting: JSON.stringify({
caType: "letsencrypt", caType: "letsencrypt",
email: userEmail, email: userEmail,
@@ -114,7 +114,7 @@ export class AsiaIspClient {
if (response.code !== "0") { if (response.code !== "0") {
this.logger.error(`接口请求失败: code=${response.code}, msg=${response.msg}`); this.logger.error(`接口请求失败: code=${response.code}, msg=${response.msg}`);
const e= new Error(response.msg || "接口请求失败"); const e = new Error(response.msg || "接口请求失败");
// @ts-ignore // @ts-ignore
e.errorCode = response.code; e.errorCode = response.code;
throw e; throw e;
@@ -122,9 +122,9 @@ export class AsiaIspClient {
return response; return response;
} catch (error: any) { } catch (error: any) {
const response = error.response const response = error.response;
if (response && response.data) { if (response && response.data) {
const e = new Error(response.data.msg || error.message || "接口请求失败"); const e = new Error(response.data.msg || error.message || "接口请求失败");
// @ts-ignore // @ts-ignore
e.errorCode = response.data.code; e.errorCode = response.data.code;
throw e; throw e;
@@ -245,7 +245,7 @@ export class AsiaIspClient {
this.logger.info(`域名 ${req.domain} 已绑定该证书 ${req.certId},无需重复绑定`); this.logger.info(`域名 ${req.domain} 已绑定该证书 ${req.certId},无需重复绑定`);
return; return;
} }
throw e throw e;
} }
this.logger.info(`部署证书到域名成功: ${req.domain}, certId=${req.certId}`); this.logger.info(`部署证书到域名成功: ${req.domain}, certId=${req.certId}`);
} }
@@ -86,8 +86,6 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
}) })
domainType!: string; domainType!: string;
@TaskInput( @TaskInput(
createRemoteSelectInputDefine({ createRemoteSelectInputDefine({
title: "域名", title: "域名",
@@ -111,18 +109,24 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
const access = await this.getAccess<VolcengineAccess>(this.accessId); const access = await this.getAccess<VolcengineAccess>(this.accessId);
const certId = await this.uploadOrGetCertId(access); const certId = await this.uploadOrGetCertId(access);
const service = await this.getVodService({ version: "2023-07-01", region: this.regionId }); const domainTypeMapping: Record<string, string> = {
play: "vod_play",
image: "vod_image",
};
const apiDomainType = domainTypeMapping[this.domainType] || this.domainType;
const service = await this.getVodService({ version: "2026-01-01", region: this.regionId });
const domains = Array.isArray(this.domainList) ? this.domainList : [this.domainList]; const domains = Array.isArray(this.domainList) ? this.domainList : [this.domainList];
for (const domain of domains) { for (const domain of domains) {
this.logger.info(`开始部署域名${domain}证书`); this.logger.info(`开始部署域名${domain}证书`);
await service.request({ await service.request({
action: "UpdateDomainConfig", action: "UpdateVodDomainConfig",
method: "POST", method: "POST",
body: { body: {
SpaceName: this.spaceName, SpaceName: this.spaceName,
DomainType: this.domainType, DomainType: apiDomainType,
Domain: domain, Domain: domain,
Config: { UpdateCdnConfigParam: {
HTTPS: { HTTPS: {
Switch: true, Switch: true,
CertInfo: { CertInfo: {
@@ -207,34 +211,40 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
if (!this.spaceName) { if (!this.spaceName) {
throw new Error("请先选择空间名称"); throw new Error("请先选择空间名称");
} }
const service = await this.getVodService({ version: "2023-01-01", region: this.regionId }); const service = await this.getVodService({ version: "2026-01-01", region: this.regionId });
const query: Record<string, any> = { const domainTypeMapping: Record<string, string> = {
SpaceName: this.spaceName, play: "vod_play",
DomainType: this.domainType, image: "vod_image",
}; };
const apiDomainType = domainTypeMapping[this.domainType] || this.domainType;
const body: Record<string, any> = {
SpaceName: this.spaceName,
ListCdnDomainsParam: {
PageNum: 1,
PageSize: 100,
},
};
if (apiDomainType) {
body.DomainType = apiDomainType;
}
const res = await service.request({ const res = await service.request({
action: "ListDomain", action: "ListVodDomains",
query, method: "POST",
body,
}); });
const instances = res.Result?.PlayInstanceInfo?.ByteInstances; const domains = res.Result?.VodInfo?.Domains;
if (!instances || instances.length === 0) { if (!domains || domains.length === 0) {
throw new Error("找不到域名,您也可以手动输入域名"); return [];
}
const list = [];
for (const item of instances) {
if (item.Domains && item.Domains.length > 0) {
for (const domain of item.Domains) {
if (domain.Domain) {
list.push({
value: domain.Domain,
label: domain.Domain,
});
}
}
}
} }
const list = domains.map((item: any) => {
return {
value: item.Domain,
label: item.Domain,
};
});
return this.ctx.utils.options.buildGroupOptions(list, this.certDomains); return this.ctx.utils.options.buildGroupOptions(list, this.certDomains);
} }
} }