mirror of https://github.com/certd/certd
chore: 优化access
parent
b09acfb4dc
commit
551311d3a0
|
@ -1,6 +1,8 @@
|
|||
import { Registrable } from "../registry/index.js";
|
||||
import { FormItemProps } from "../dt/index.js";
|
||||
import { HttpClient, ILogger, utils } from "../utils";
|
||||
import { HttpClient, ILogger, utils } from "../utils/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { AccessRequestHandleReq } from "../core";
|
||||
|
||||
export type AccessInputDefine = FormItemProps & {
|
||||
title: string;
|
||||
|
@ -26,3 +28,26 @@ export type AccessContext = {
|
|||
logger: ILogger;
|
||||
utils: typeof utils;
|
||||
};
|
||||
|
||||
export abstract class BaseAccess implements IAccess {
|
||||
ctx!: AccessContext;
|
||||
|
||||
async onRequest(req: AccessRequestHandleReq) {
|
||||
if (!req.action) {
|
||||
throw new Error("action is required");
|
||||
}
|
||||
|
||||
let methodName = req.action;
|
||||
if (!req.action.startsWith("on")) {
|
||||
methodName = `on${_.upperFirst(req.action)}`;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const method = this[methodName];
|
||||
if (method) {
|
||||
// @ts-ignore
|
||||
return await this[methodName](req.data);
|
||||
}
|
||||
throw new Error(`action ${req.action} not found`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { AccessContext, AccessDefine, AccessInputDefine } from "./api.js";
|
|||
import { Decorator } from "../decorator/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { accessRegistry } from "./registry.js";
|
||||
import { http, logger, utils } from "../utils";
|
||||
import { http, logger, utils } from "../utils/index.js";
|
||||
|
||||
// 提供一个唯一 key
|
||||
export const ACCESS_CLASS_KEY = "pipeline:access";
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import _ from "lodash-es";
|
||||
import { HttpClient, ILogger, utils } from "../utils";
|
||||
import { HttpClient, ILogger, utils } from "../utils/index.js";
|
||||
|
||||
export type PluginRequestHandleReq<T = any> = {
|
||||
typeName: string;
|
||||
|
@ -20,24 +19,3 @@ export type AccessRequestHandleContext = {
|
|||
};
|
||||
|
||||
export type AccessRequestHandleReq<T = any> = PluginRequestHandleReq<AccessRequestHandleReqInput<T>>;
|
||||
|
||||
export class AccessRequestHandler<T = any> {
|
||||
async onRequest(req: AccessRequestHandleReq<T>, ctx: AccessRequestHandleContext) {
|
||||
if (!req.action) {
|
||||
throw new Error("action is required");
|
||||
}
|
||||
|
||||
let methodName = req.action;
|
||||
if (!req.action.startsWith("on")) {
|
||||
methodName = `on${_.upperFirst(req.action)}`;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const method = this[methodName];
|
||||
if (method) {
|
||||
// @ts-ignore
|
||||
return await this[methodName](req.data, ctx);
|
||||
}
|
||||
throw new Error(`action ${req.action} not found`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { IAccessService } from "../access/index.js";
|
|||
import { IEmailService } from "../service/index.js";
|
||||
import { IContext, PluginRequestHandleReq, RunnableCollection } from "../core/index.js";
|
||||
import { ILogger, logger, utils } from "../utils/index.js";
|
||||
import { HttpClient } from "../utils/util.request";
|
||||
import { HttpClient } from "../utils/util.request.js";
|
||||
import dayjs from "dayjs";
|
||||
import _ from "lodash-es";
|
||||
export type UserInfo = {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { IsAccess, AccessInput } from "@certd/pipeline";
|
||||
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
|
||||
|
||||
@IsAccess({
|
||||
name: "eab",
|
||||
title: "EAB授权",
|
||||
desc: "ZeroSSL证书申请需要EAB授权",
|
||||
})
|
||||
export class EabAccess {
|
||||
export class EabAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: "KID",
|
||||
component: {
|
||||
|
|
|
@ -64,7 +64,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||
}
|
||||
},
|
||||
rowHandle: {
|
||||
width: "130px"
|
||||
width: 200
|
||||
},
|
||||
table: {
|
||||
scroll: {
|
||||
|
|
|
@ -42,6 +42,9 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
|||
span: 6
|
||||
}
|
||||
},
|
||||
rowHandle: {
|
||||
width: 200
|
||||
},
|
||||
columns: {
|
||||
id: {
|
||||
title: "ID",
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useRouter } from "vue-router";
|
|||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, useUi } from "@fast-crud/fast-crud";
|
||||
import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
|
||||
import { nanoid } from "nanoid";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import { message, Modal, notification } from "ant-design-vue";
|
||||
import { env } from "/@/utils/util.env";
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
import dayjs from "dayjs";
|
||||
|
@ -181,23 +181,34 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
|||
}
|
||||
}
|
||||
},
|
||||
table: {
|
||||
scroll: { x: 1500 }
|
||||
},
|
||||
rowHandle: {
|
||||
minWidth: 200,
|
||||
width: 300,
|
||||
fixed: "right",
|
||||
buttons: {
|
||||
play: {
|
||||
order: -999,
|
||||
title: null,
|
||||
type: "link",
|
||||
icon: "ant-design:play-outlined",
|
||||
icon: "ant-design:play-circle-outlined",
|
||||
click({ row }) {
|
||||
Modal.confirm({
|
||||
title: "确认",
|
||||
content: `确定要触发运行吗?`,
|
||||
async onOk() {
|
||||
await api.Trigger(row.id);
|
||||
notification.success({ message: "管道已经开始运行" });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
view: {
|
||||
click({ row }) {
|
||||
router.push({ path: "/certd/pipeline/detail", query: { id: row.id, editMode: "false" } });
|
||||
}
|
||||
},
|
||||
// view: {
|
||||
// click({ row }) {
|
||||
// router.push({ path: "/certd/pipeline/detail", query: { id: row.id, editMode: "false" } });
|
||||
// }
|
||||
// },
|
||||
copy: {
|
||||
click: async (context) => {
|
||||
userStore.checkPlus();
|
||||
|
@ -303,7 +314,7 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
|||
}
|
||||
},
|
||||
column: {
|
||||
width: 300,
|
||||
width: 350,
|
||||
sorter: true,
|
||||
component: {
|
||||
on: {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { IsAccess, AccessInput } from '@certd/pipeline';
|
|||
title: 'cloudflare授权',
|
||||
desc: '',
|
||||
})
|
||||
export class CloudflareAccess {
|
||||
export class CloudflareAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsAccess, AccessInput, IAccess } from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { IsAccess, AccessInput, IAccess } from '@certd/pipeline';
|
|||
title: '授权插件示例',
|
||||
desc: '',
|
||||
})
|
||||
export class DemoAccess implements IAccess {
|
||||
export class DemoAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { IsAccess, AccessInput } from '@certd/pipeline';
|
|||
title: '多吉云',
|
||||
desc: '',
|
||||
})
|
||||
export class DogeCloudAccess {
|
||||
export class DogeCloudAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AccessInput, IsAccess } from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { AccessInput, IsAccess } from '@certd/pipeline';
|
|||
title: 'dynadot授权',
|
||||
desc: '************\n注意:申请证书时会覆盖已有的域名解析配置,慎用\n************\n待优化,主要是dynadot的接口一言难尽',
|
||||
})
|
||||
export class DynadotAccess {
|
||||
export class DynadotAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AccessInput, IAccess, IsAccess } from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
import { ConnectConfig } from 'ssh2';
|
||||
|
||||
@IsAccess({
|
||||
|
@ -7,7 +7,7 @@ import { ConnectConfig } from 'ssh2';
|
|||
desc: '',
|
||||
input: {},
|
||||
})
|
||||
export class SshAccess implements IAccess, ConnectConfig {
|
||||
export class SshAccess extends BaseAccess implements ConnectConfig {
|
||||
@AccessInput({
|
||||
title: '主机地址',
|
||||
component: {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
|
||||
@IsAccess({
|
||||
name: 'huawei',
|
||||
title: '华为云授权',
|
||||
desc: '',
|
||||
})
|
||||
export class HuaweiAccess {
|
||||
export class HuaweiAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: 'accessKeyId',
|
||||
component: {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AccessInput, IsAccess } from '@certd/pipeline';
|
||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { AccessInput, IsAccess } from '@certd/pipeline';
|
|||
title: '京东云授权',
|
||||
desc: '暂时无法成功申请,还没测试通过',
|
||||
})
|
||||
export class JDCloudAccess {
|
||||
export class JDCloudAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
|
||||
@IsAccess({
|
||||
name: 'dnspod',
|
||||
|
@ -6,7 +6,7 @@ import { IsAccess, AccessInput } from '@certd/pipeline';
|
|||
desc: '腾讯云的域名解析接口已迁移到dnspod',
|
||||
deprecated: 'dnspod已废弃,请换成腾讯云',
|
||||
})
|
||||
export class DnspodAccess {
|
||||
export class DnspodAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: '端点',
|
||||
component: {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
|
@ -9,7 +9,7 @@ import { IsAccess, AccessInput } from '@certd/pipeline';
|
|||
title: '西部数码授权',
|
||||
desc: '',
|
||||
})
|
||||
export class WestAccess {
|
||||
export class WestAccess extends BaseAccess {
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue