2025-05-16 00:04:52 +08:00
|
|
|
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
|
|
|
|
|
import { HttpClient } from "@certd/basic";
|
|
|
|
|
import { FlexCDNClient } from "./client.js";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
@IsAccess({
|
|
|
|
|
name: "flexcdn",
|
|
|
|
|
title: "FlexCDN授权",
|
|
|
|
|
desc: "",
|
2026-05-31 01:41:33 +08:00
|
|
|
icon: "svg:icon-lucky",
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
export class FlexCDNAccess extends BaseAccess {
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "接口地址",
|
|
|
|
|
component: {
|
|
|
|
|
placeholder: "http://xxxxxxx:8080",
|
|
|
|
|
name: "a-input",
|
2026-05-31 01:41:33 +08:00
|
|
|
vModel: "value",
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
2026-05-31 01:41:33 +08:00
|
|
|
required: true,
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
endpoint!: string;
|
|
|
|
|
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "用户类型",
|
|
|
|
|
component: {
|
|
|
|
|
placeholder: "请选择",
|
|
|
|
|
name: "a-select",
|
|
|
|
|
vModel: "value",
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
value: "user",
|
2026-05-31 01:41:33 +08:00
|
|
|
label: "普通用户",
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "admin",
|
2026-05-31 01:41:33 +08:00
|
|
|
label: "管理员",
|
|
|
|
|
},
|
|
|
|
|
],
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
2026-05-31 01:41:33 +08:00
|
|
|
required: true,
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
type!: string;
|
|
|
|
|
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "accessKeyId",
|
|
|
|
|
component: {
|
|
|
|
|
placeholder: "accessKeyId",
|
|
|
|
|
component: {
|
|
|
|
|
name: "a-input",
|
2026-05-31 01:41:33 +08:00
|
|
|
vModel: "value",
|
|
|
|
|
},
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
|
|
|
|
encrypt: false,
|
2026-05-31 01:41:33 +08:00
|
|
|
required: true,
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
accessKeyId!: string;
|
|
|
|
|
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "accessKey",
|
|
|
|
|
component: {
|
|
|
|
|
placeholder: "accessKey",
|
|
|
|
|
component: {
|
|
|
|
|
name: "a-input",
|
2026-05-31 01:41:33 +08:00
|
|
|
vModel: "value",
|
|
|
|
|
},
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
|
|
|
|
encrypt: true,
|
2026-05-31 01:41:33 +08:00
|
|
|
required: true,
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
accessKey!: string;
|
|
|
|
|
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "忽略证书校验",
|
|
|
|
|
component: {
|
|
|
|
|
name: "a-switch",
|
2026-05-31 01:41:33 +08:00
|
|
|
vModel: "checked",
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
|
|
|
|
encrypt: false,
|
2025-06-01 01:03:11 +08:00
|
|
|
required: true,
|
|
|
|
|
value: false,
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
skipSslVerify!: boolean;
|
|
|
|
|
|
|
|
|
|
@AccessInput({
|
|
|
|
|
title: "测试",
|
|
|
|
|
component: {
|
|
|
|
|
name: "api-test",
|
2026-05-31 01:41:33 +08:00
|
|
|
action: "TestRequest",
|
2025-05-16 00:04:52 +08:00
|
|
|
},
|
2026-05-31 01:41:33 +08:00
|
|
|
helper: "点击测试接口看是否正常",
|
2025-05-16 00:04:52 +08:00
|
|
|
})
|
|
|
|
|
testRequest = true;
|
|
|
|
|
|
|
|
|
|
async onTestRequest() {
|
|
|
|
|
const http: HttpClient = this.ctx.http;
|
|
|
|
|
const client = new FlexCDNClient({
|
|
|
|
|
logger: this.ctx.logger,
|
|
|
|
|
http,
|
2026-05-31 01:41:33 +08:00
|
|
|
access: this,
|
2025-05-16 00:04:52 +08:00
|
|
|
});
|
|
|
|
|
const token = await client.getToken();
|
|
|
|
|
if (token) {
|
|
|
|
|
return "ok";
|
|
|
|
|
}
|
|
|
|
|
throw "测试失败,未知错误";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new FlexCDNAccess();
|