mirror of
https://github.com/certd/certd.git
synced 2026-07-13 00:37:36 +08:00
chore: 补充其他access的测试按钮
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
import { UpyunClient } from './client.js';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
@@ -30,6 +31,41 @@ export class UpyunAccess extends BaseAccess {
|
||||
})
|
||||
password = '';
|
||||
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "onTestRequest",
|
||||
},
|
||||
helper: "点击测试接口看是否正常",
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
async onTestRequest() {
|
||||
await this.getCdnList();
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
async getCdnList() {
|
||||
const upyunClient = new UpyunClient({
|
||||
access: this,
|
||||
logger: this.ctx.logger,
|
||||
http: this.ctx.http
|
||||
});
|
||||
const cookie = await upyunClient.getLoginToken();
|
||||
const req = {
|
||||
cookie,
|
||||
url: "https://console.upyun.com/api/account/domains/?limit=1000&business_type=file&security_cdn=false&websocket=false&key=&domain=",
|
||||
method: "GET",
|
||||
data: {}
|
||||
};
|
||||
const res = await upyunClient.doRequest(req);
|
||||
const domains = res.data?.domains || [];
|
||||
return domains
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new UpyunAccess();
|
||||
|
||||
Reference in New Issue
Block a user