diff --git a/packages/core/pipeline/src/core/handler.ts b/packages/core/pipeline/src/core/handler.ts
new file mode 100644
index 000000000..8180a627b
--- /dev/null
+++ b/packages/core/pipeline/src/core/handler.ts
@@ -0,0 +1,33 @@
+import _ from "lodash-es";
+import { HttpClient, ILogger } from "../utils";
+
+export type PluginRequest = {
+ type: "plugin" | "access";
+ typeName: string;
+ action: string;
+ input: any;
+ data: any;
+};
+
+export type RequestHandleContext = {
+ http: HttpClient;
+ logger: ILogger;
+};
+
+export class RequestHandler {
+ async onRequest(req: PluginRequest, ctx: RequestHandleContext) {
+ if (!req.action) {
+ throw new Error("action is required");
+ }
+
+ const 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`);
+ }
+}
diff --git a/packages/core/pipeline/src/core/index.ts b/packages/core/pipeline/src/core/index.ts
index ea038be6b..6059e8589 100644
--- a/packages/core/pipeline/src/core/index.ts
+++ b/packages/core/pipeline/src/core/index.ts
@@ -4,3 +4,4 @@ export * from "./context.js";
export * from "./storage.js";
export * from "./file-store.js";
export * from "./license.js";
+export * from "./handler.js";
diff --git a/packages/core/pipeline/src/utils/util.request.ts b/packages/core/pipeline/src/utils/util.request.ts
index 12e841fd3..ca0c11b9c 100644
--- a/packages/core/pipeline/src/utils/util.request.ts
+++ b/packages/core/pipeline/src/utils/util.request.ts
@@ -45,7 +45,7 @@ export function createAxiosService({ logger }: { logger: Logger }) {
// 创建一个 axios 实例
const service = axios.create();
- const defaultAgents = createAgent();
+ // const defaultAgents = createAgent();
// 请求拦截
service.interceptors.request.use(
(config: any) => {
@@ -53,13 +53,14 @@ export function createAxiosService({ logger }: { logger: Logger }) {
if (config.timeout == null) {
config.timeout = 15000;
}
- let agents = defaultAgents;
- if (config.skipSslVerify) {
- agents = createAgent({ rejectUnauthorized: config.rejectUnauthorized });
- }
-
- config.httpsAgent = agents.httpsAgent;
- config.httpAgent = agents.httpAgent;
+ // let agents = defaultAgents;
+ // if (config.skipSslVerify) {
+ // logger.info("跳过SSL验证");
+ // agents = createAgent({ rejectUnauthorized: config.rejectUnauthorized });
+ // }
+ // delete config.skipSslVerify;
+ // config.httpsAgent = agents.httpsAgent;
+ // config.httpAgent = agents.httpAgent;
return config;
},
diff --git a/packages/ui/certd-client/src/components/index.ts b/packages/ui/certd-client/src/components/index.ts
index 3df02964a..7e0034529 100644
--- a/packages/ui/certd-client/src/components/index.ts
+++ b/packages/ui/certd-client/src/components/index.ts
@@ -8,6 +8,7 @@ import { CheckCircleOutlined, InfoCircleOutlined, UndoOutlined } from "@ant-desi
import CronEditor from "./cron-editor/index.vue";
import { CronLight } from "@vue-js-cron/light";
import "@vue-js-cron/light/dist/light.css";
+import Plugins from "./plugins/index";
export default {
install(app: any) {
app.component("PiContainer", PiContainer);
@@ -24,5 +25,6 @@ export default {
app.component("UndoOutlined", UndoOutlined);
app.use(vip);
+ app.use(Plugins);
}
};
diff --git a/packages/ui/certd-client/src/components/plugins/index.ts b/packages/ui/certd-client/src/components/plugins/index.ts
new file mode 100644
index 000000000..d999d9921
--- /dev/null
+++ b/packages/ui/certd-client/src/components/plugins/index.ts
@@ -0,0 +1,6 @@
+import PiSynologyIdDeviceGetter from "./synology/device-id-getter.vue";
+export default {
+ install(app: any) {
+ app.component("PiSynologyDeviceIdGetter", PiSynologyIdDeviceGetter);
+ }
+};
diff --git a/packages/ui/certd-client/src/components/plugins/synology/device-id-getter.vue b/packages/ui/certd-client/src/components/plugins/synology/device-id-getter.vue
new file mode 100644
index 000000000..f58149bbd
--- /dev/null
+++ b/packages/ui/certd-client/src/components/plugins/synology/device-id-getter.vue
@@ -0,0 +1,73 @@
+
+
+
+
+
diff --git a/packages/ui/certd-server/src/modules/pipeline/controller/handle-controller.ts b/packages/ui/certd-server/src/modules/pipeline/controller/handle-controller.ts
new file mode 100644
index 000000000..ccd238267
--- /dev/null
+++ b/packages/ui/certd-server/src/modules/pipeline/controller/handle-controller.ts
@@ -0,0 +1,36 @@
+import { ALL, Body, Controller, Post, Provide } from '@midwayjs/core';
+import { Constants } from '../../../basic/constants.js';
+import { accessRegistry, http, logger, PluginRequest, RequestHandleContext } from '@certd/pipeline';
+import { merge } from 'lodash-es';
+import { BaseController } from '../../../basic/base-controller.js';
+@Provide()
+@Controller('/api/pi/handle')
+export class HandleController extends BaseController {
+ @Post('/', { summary: Constants.per.authOnly })
+ async request(@Body(ALL) body: PluginRequest) {
+ const type = body.type;
+ if (type === 'access') {
+ const accessItem = accessRegistry.get(body.typeName);
+ const accessCls = accessItem.target;
+ if (accessCls == null) {
+ throw new Error(`access ${body.typeName} not found`);
+ }
+ //实例化access
+ //@ts-ignore
+ const access = new accessCls();
+ //注入input
+ merge(access, body.input);
+ const ctx: RequestHandleContext = {
+ http: http,
+ logger: logger,
+ };
+ const res = await access.onRequest(body, ctx);
+
+ return this.ok(res);
+ } else if (type === 'plugin') {
+ throw new Error(`plugin:${body.typeName} not support`);
+ } else {
+ throw new Error(`type:${type} not support`);
+ }
+ }
+}