From ba65f750d461b35f6beaa10c4700664870efe124 Mon Sep 17 00:00:00 2001
From: dap <15891557205@163.com>
Date: Wed, 14 Jan 2026 15:45:39 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E5=85=A8=E5=B1=80):=20=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E5=85=A8=E5=B1=80=E5=BC=B9=E7=AA=97=E4=B8=8A=E4=B8=8B=E6=96=87?=
=?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=B9=B6=E5=A3=B0=E6=98=8E=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
添加 PopupContext 组件用于全局提供 message、modal 和 notification 方法
在 global.d.ts 中声明对应的 window 类型
将 analytics 页面的 notification 调用改为使用全局方法
---
apps/web-antd/src/app.vue | 2 ++
apps/web-antd/src/utils/context.tsx | 20 +++++++++++++++++++
.../src/views/dashboard/analytics/index.vue | 4 ++--
apps/web-antd/types/global.d.ts | 11 ++++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 apps/web-antd/src/utils/context.tsx
create mode 100644 apps/web-antd/types/global.d.ts
diff --git a/apps/web-antd/src/app.vue b/apps/web-antd/src/app.vue
index 4921d77d..46515f7a 100644
--- a/apps/web-antd/src/app.vue
+++ b/apps/web-antd/src/app.vue
@@ -9,6 +9,7 @@ import { App, ConfigProvider, theme } from 'antdv-next';
import { antdLocale } from '#/locales';
import { useUploadTip } from './upload-tip';
+import { PopupContext } from './utils/context';
defineOptions({ name: 'App' });
@@ -38,6 +39,7 @@ useUploadTip();
+
diff --git a/apps/web-antd/src/utils/context.tsx b/apps/web-antd/src/utils/context.tsx
new file mode 100644
index 00000000..f7d5ca82
--- /dev/null
+++ b/apps/web-antd/src/utils/context.tsx
@@ -0,0 +1,20 @@
+import { defineComponent } from 'vue';
+
+import { App } from 'antdv-next';
+
+/**
+ * 弹窗上下文
+ * 提供 message, modal, notification 方法
+ * @see https://ant.design/components/app-cn#global-scene-redux
+ */
+export const PopupContext = defineComponent({
+ name: 'PopupContext',
+ render() {
+ const staticFunction = App.useApp();
+ window.message = staticFunction.message;
+ window.modal = staticFunction.modal;
+ window.notification = staticFunction.notification;
+
+ return null;
+ },
+});
diff --git a/apps/web-antd/src/views/dashboard/analytics/index.vue b/apps/web-antd/src/views/dashboard/analytics/index.vue
index a93a98ca..86a8a4c3 100644
--- a/apps/web-antd/src/views/dashboard/analytics/index.vue
+++ b/apps/web-antd/src/views/dashboard/analytics/index.vue
@@ -15,7 +15,7 @@ import {
SvgDownloadIcon,
} from '@vben/icons';
-import { Alert, notification } from 'antdv-next';
+import { Alert } from 'antdv-next';
import AnalyticsTrends from './analytics-trends.vue';
import AnalyticsVisitsData from './analytics-visits-data.vue';
@@ -67,7 +67,7 @@ const chartTabs: TabOption[] = [
];
function handleClick() {
- notification.success({
+ window.notification.success({
title: '新的 notification 样式',
description: 'ant design',
});
diff --git a/apps/web-antd/types/global.d.ts b/apps/web-antd/types/global.d.ts
new file mode 100644
index 00000000..0ac11cc1
--- /dev/null
+++ b/apps/web-antd/types/global.d.ts
@@ -0,0 +1,11 @@
+import type { MessageInstance } from 'antdv-next/dist/message/interface';
+import type { ModalStaticFunctions } from 'antdv-next/dist/modal/confirm';
+import type { NotificationInstance } from 'antdv-next/dist/notification/interface';
+
+declare global {
+ interface Window {
+ message: MessageInstance;
+ modal: Omit;
+ notification: NotificationInstance;
+ }
+}