Skip to content

Commit

Permalink
refactor(pluginKit): update useRender hooks to include request parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
robinv8 committed Sep 25, 2024
1 parent 3698389 commit 106aeab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ui/src/utils/pluginKit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -227,7 +228,7 @@ const useRenderHtmlPlugin = (
})
.forEach((plugin) => {
plugin.hooks?.useRender?.forEach((hook) => {
hook(element);
hook(element, request);
});
});
};
Expand All @@ -247,7 +248,7 @@ const useRenderPlugin = (
})
.forEach((plugin) => {
plugin.hooks?.useRender?.forEach((hook) => {
hook(element);
hook(element, request);
});
});
};
Expand Down
6 changes: 5 additions & 1 deletion ui/src/utils/pluginKit/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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>;
Expand Down

0 comments on commit 106aeab

Please sign in to comment.