mirror of https://github.com/certd/certd
fix: 修复CDN插件我爱云因更换接口导致部署失败的问题
parent
f0584c88e8
commit
0110dfdb70
|
@ -15,9 +15,16 @@ import { WoaiAccess } from '../access.js';
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||||
|
@TaskInput({
|
||||||
|
title: '接口地址(可留空)',
|
||||||
|
helper: '请填写我爱云的地址, 默认为 [API](https://console.edeg.sxhjgy.cn) 末尾请不要携带`/`',
|
||||||
|
component: { name: 'a-input' },
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
baseApi?: string;
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
title: '证书ID',
|
title: '证书ID',
|
||||||
helper: '请填写 [证书列表](https://console.edge.51vs.club/site/certificate) 中的证书的ID',
|
helper: '请填写 [证书列表](https://console.edge.sxhjgy.cn/site/certificate) 中的证书的ID',
|
||||||
component: { name: 'a-input' },
|
component: { name: 'a-input' },
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
|
@ -42,7 +49,6 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
private readonly baseApi = 'https://console.edeg.51vs.club';
|
|
||||||
|
|
||||||
async onInstance() {}
|
async onInstance() {}
|
||||||
|
|
||||||
|
@ -66,8 +72,10 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { certId, cert, accessId } = this;
|
const { certId, cert, accessId } = this;
|
||||||
const access = (await this.accessService.getById(accessId)) as WoaiAccess;
|
const access = (await this.accessService.getById(accessId)) as WoaiAccess;
|
||||||
|
// 使用默认值或用户输入的值
|
||||||
|
const apiBase = this.baseApi || 'https://console.edeg.sxhjgy.cn';
|
||||||
// 登录获取token
|
// 登录获取token
|
||||||
const loginResponse = await this.doRequestApi(`${this.baseApi}/account/login`, {
|
const loginResponse = await this.doRequestApi(`${apiBase}/account/login`, {
|
||||||
username: access.username,
|
username: access.username,
|
||||||
password: access.password,
|
password: access.password,
|
||||||
});
|
});
|
||||||
|
@ -75,7 +83,7 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||||
this.logger.info('登录成功,获取到Token:', token);
|
this.logger.info('登录成功,获取到Token:', token);
|
||||||
// 更新证书
|
// 更新证书
|
||||||
const editCertResponse = await this.doRequestApi(
|
const editCertResponse = await this.doRequestApi(
|
||||||
`${this.baseApi}/certificate/edit`,
|
`${apiBase}/certificate/edit`,
|
||||||
{
|
{
|
||||||
id: certId,
|
id: certId,
|
||||||
cert: cert.crt,
|
cert: cert.crt,
|
||||||
|
|
Loading…
Reference in New Issue