Skip to content

Commit e4996df

Browse files
refactor: added global instances for message, modal and notification
1 parent a3606cb commit e4996df

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { App } from 'antd';
2+
import type { MessageInstance } from 'antd/es/message/interface';
3+
import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
4+
import type { NotificationInstance } from 'antd/es/notification/interface';
5+
6+
let messageInstance: MessageInstance;
7+
let notificationInstance: NotificationInstance;
8+
let modalInstance: Omit<ModalStaticFunctions, 'warn'>;
9+
10+
export default () => {
11+
const staticFunction = App.useApp();
12+
messageInstance = staticFunction.message;
13+
modalInstance = staticFunction.modal;
14+
notificationInstance = staticFunction.notification;
15+
return null;
16+
};
17+
18+
export { messageInstance, notificationInstance, modalInstance };

client/packages/lowcoder-design/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from "./components/CustomModal";
33
export * from "./components/Drawer";
44
export * from "./components/Dropdown";
55
export * from "./components/ExternalLink";
6+
export * from "./components/GlobalInstances";
67
export * from "./components/Input";
78
export * from "./components/Label";
89
export * from "./components/Menu";

client/packages/lowcoder/src/app.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ConfigProvider } from "antd";
1+
import { App, ConfigProvider } from "antd";
22
import {
33
ALL_APPLICATIONS_URL,
44
APP_EDITOR_URL,
@@ -46,6 +46,7 @@ import { isFetchUserFinished } from "redux/selectors/usersSelectors";
4646
import { SystemWarning } from "./components/SystemWarning";
4747
import { getBrandingConfig, getSystemConfigFetching } from "./redux/selectors/configSelectors";
4848
import { buildMaterialPreviewURL } from "./util/materialUtils";
49+
import GlobalInstances from 'components/GlobalInstances';
4950

5051
const LazyUserAuthComp = React.lazy(() => import("pages/userAuth"));
5152
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
@@ -54,9 +55,17 @@ const LazyComponentPlayground = React.lazy(() => import("pages/ComponentPlaygrou
5455
const LazyDebugComp = React.lazy(() => import("./debug"));
5556
const LazyDebugNewComp = React.lazy(() => import("./debugNew"));
5657

57-
const Wrapper = (props: { children: React.ReactNode }) => {
58-
return <ConfigProvider locale={getAntdLocale(language)}>{props.children}</ConfigProvider>;
59-
};
58+
const Wrapper = (props: { children: React.ReactNode }) => (
59+
<ConfigProvider
60+
theme={{ hashed: false }}
61+
locale={getAntdLocale(language)}
62+
>
63+
<App>
64+
<GlobalInstances />
65+
{props.children}
66+
</App>
67+
</ConfigProvider>
68+
);
6069

6170
type AppIndexProps = {
6271
isFetchUserFinished: boolean;

0 commit comments

Comments
 (0)