mirror of
https://github.com/certd/certd.git
synced 2026-07-06 20:37:34 +08:00
chore: format
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
|
||||
|
||||
@IsAccess({
|
||||
name: 'woai',
|
||||
title: '我爱云授权',
|
||||
desc: '我爱云CDN',
|
||||
icon: 'clarity:plugin-line',
|
||||
name: "woai",
|
||||
title: "我爱云授权",
|
||||
desc: "我爱云CDN",
|
||||
icon: "clarity:plugin-line",
|
||||
})
|
||||
export class WoaiAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: '账号',
|
||||
title: "账号",
|
||||
component: {
|
||||
placeholder: '我爱云的账号',
|
||||
placeholder: "我爱云的账号",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
username = '';
|
||||
username = "";
|
||||
@AccessInput({
|
||||
title: '密码',
|
||||
title: "密码",
|
||||
component: {
|
||||
placeholder: '我爱云的密码',
|
||||
placeholder: "我爱云的密码",
|
||||
},
|
||||
required: true,
|
||||
encrypt: true,
|
||||
})
|
||||
password = '';
|
||||
password = "";
|
||||
}
|
||||
|
||||
new WoaiAccess();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from './plugins/index.js';
|
||||
export * from './access.js';
|
||||
export * from "./plugins/index.js";
|
||||
export * from "./access.js";
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './plugin-deploy-to-cdn.js';
|
||||
export * from "./plugin-deploy-to-cdn.js";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { WoaiAccess } from '../access.js';
|
||||
import { WoaiAccess } from "../access.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'WoaiCDN',
|
||||
title: '我爱云-部署证书到我爱云CDN',
|
||||
desc: '部署证书到我爱云CDN',
|
||||
icon: 'clarity:plugin-line',
|
||||
name: "WoaiCDN",
|
||||
title: "我爱云-部署证书到我爱云CDN",
|
||||
desc: "部署证书到我爱云CDN",
|
||||
icon: "clarity:plugin-line",
|
||||
group: pluginGroups.cdn.key,
|
||||
default: {
|
||||
strategy: {
|
||||
@@ -16,35 +16,35 @@ import { WoaiAccess } from '../access.js';
|
||||
})
|
||||
export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: '接口地址(可留空)',
|
||||
helper: '请填写我爱云的地址, 默认为 [API](https://console.edeg.ttzi.cn) 末尾请不要携带`/`',
|
||||
component: { name: 'a-input' },
|
||||
title: "接口地址(可留空)",
|
||||
helper: "请填写我爱云的地址, 默认为 [API](https://console.edeg.ttzi.cn) 末尾请不要携带`/`",
|
||||
component: { name: "a-input" },
|
||||
required: false,
|
||||
})
|
||||
baseApi?: string;
|
||||
@TaskInput({
|
||||
title: '证书ID',
|
||||
helper: '请填写 [证书列表](https://console.edge.ttzi.cn/site/certificate) 中的证书的ID',
|
||||
component: { name: 'a-input' },
|
||||
title: "证书ID",
|
||||
helper: "请填写 [证书列表](https://console.edge.ttzi.cn/site/certificate) 中的证书的ID",
|
||||
component: { name: "a-input" },
|
||||
required: true,
|
||||
})
|
||||
certId!: string;
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
helper: '请选择前置任务输出的域名证书',
|
||||
title: "域名证书",
|
||||
helper: "请选择前置任务输出的域名证书",
|
||||
component: {
|
||||
name: 'output-selector',
|
||||
name: "output-selector",
|
||||
from: [...CertApplyPluginNames],
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
cert!: CertInfo;
|
||||
@TaskInput({
|
||||
title: 'Access授权',
|
||||
helper: '我爱云的用户、密码授权',
|
||||
title: "Access授权",
|
||||
helper: "我爱云的用户、密码授权",
|
||||
component: {
|
||||
name: 'access-selector',
|
||||
type: 'woai',
|
||||
name: "access-selector",
|
||||
type: "woai",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
@@ -52,9 +52,9 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||
|
||||
async onInstance() {}
|
||||
|
||||
private async doRequestApi(url: string, data: any = null, method = 'post', token: string | null = null) {
|
||||
private async doRequestApi(url: string, data: any = null, method = "post", token: string | null = null) {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
...(token ? { Token: token } : {}),
|
||||
};
|
||||
const res = await this.http.request<any, any>({
|
||||
@@ -73,14 +73,14 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||
const { baseApi, certId, cert, accessId } = this;
|
||||
const access = (await this.getAccess(accessId)) as WoaiAccess;
|
||||
// 使用默认值或用户输入的值
|
||||
const apiBase = baseApi || 'https://console.edeg.ttzi.cn';
|
||||
const apiBase = baseApi || "https://console.edeg.ttzi.cn";
|
||||
// 登录获取token
|
||||
const loginResponse = await this.doRequestApi(`${apiBase}/account/login`, {
|
||||
username: access.username,
|
||||
password: access.password,
|
||||
});
|
||||
const token = loginResponse.data.token;
|
||||
this.logger.info('登录成功,获取到Token:', token);
|
||||
this.logger.info("登录成功,获取到Token:", token);
|
||||
// 更新证书
|
||||
const editCertResponse = await this.doRequestApi(
|
||||
`${apiBase}/certificate/edit`,
|
||||
@@ -89,10 +89,10 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
|
||||
cert: cert.crt,
|
||||
key: cert.key,
|
||||
},
|
||||
'post',
|
||||
"post",
|
||||
token
|
||||
);
|
||||
this.logger.info('证书更新成功:', editCertResponse.message);
|
||||
this.logger.info("证书更新成功:", editCertResponse.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user