Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

refactor(pluginKit): update useRender hooks to include request parameter

robina0f24b3cbff3
diff --git a/ui/src/utils/pluginKit/index.ts b/ui/src/utils/pluginKit/index.ts
index 6d0e9878..12cd0247 100644
--- a/ui/src/utils/pluginKit/index.ts
+++ b/ui/src/utils/pluginKit/index.ts
@@ -25,6 +25,7 @@ import type * as Type from '@/common/interface';
import { LOGGED_TOKEN_STORAGE_KEY } from '@/common/constants';
import { getPluginsStatus } from '@/services';
import Storage from '@/utils/storage';
+import request from '@/utils/request';
import { initI18nResource } from './utils';
import { Plugin, PluginInfo, PluginType } from './interface';
@@ -227,7 +228,7 @@ const useRenderHtmlPlugin = (
})
.forEach((plugin) => {
plugin.hooks?.useRender?.forEach((hook) => {
- hook(element);
+ hook(element, request);
});
});
};
@@ -247,7 +248,7 @@ const useRenderPlugin = (
})
.forEach((plugin) => {
plugin.hooks?.useRender?.forEach((hook) => {
- hook(element);
+ hook(element, request);
});
});
};
diff --git a/ui/src/utils/pluginKit/interface.ts b/ui/src/utils/pluginKit/interface.ts
index 880a524a..d946ed6e 100644
--- a/ui/src/utils/pluginKit/interface.ts
+++ b/ui/src/utils/pluginKit/interface.ts
@@ -20,6 +20,7 @@
import { NamedExoticComponent, FC, RefObject } from 'react';
import type * as Type from '@/common/interface';
+import Request from '@/utils/request';
export enum PluginType {
Connector = 'connector',
@@ -44,7 +45,10 @@ export interface Plugin {
i18nConfig?;
hooks?: {
useRender?: Array<
- (element: HTMLElement | RefObject<HTMLElement> | null) => void
+ (
+ element: HTMLElement | RefObject<HTMLElement> | null,
+ request?: typeof Request,
+ ) => void
>;
useCaptcha?: (props: { captchaKey: Type.CaptchaKey; commonProps: any }) => {
getCaptcha: () => Record<string, any>;