This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
The following commit(s) were added to refs/heads/dev by this push:
new a0f24b3c refactor(pluginKit): update useRender hooks to include
request parameter
a0f24b3c is described below
commit a0f24b3cbff380da4661910a4a60e98d26067994
Author: robin <[email protected]>
AuthorDate: Wed Sep 25 16:32:12 2024 +0800
refactor(pluginKit): update useRender hooks to include request parameter
---
ui/src/utils/pluginKit/index.ts | 5 +++--
ui/src/utils/pluginKit/interface.ts | 6 +++++-
2 files changed, 8 insertions(+), 3 deletions(-)
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>;