fix: 解决window.xxx在路由报错情况下的undefined问题

This commit is contained in:
dap
2026-03-23 11:38:51 +08:00
parent 46e8d50d40
commit 3a2d051992
3 changed files with 43 additions and 13 deletions

View File

@@ -1,6 +1,23 @@
import { defineComponent } from 'vue';
import { App } from 'antdv-next';
import { App, message, Modal, notification } from 'antdv-next';
/**
* 初始化全局弹窗方法(静态API作为fallback)
* 在app.mount之前调用, 防止路由守卫等早期逻辑访问window.message时报错
* app.mount之后PopupContext会用带上下文的实例覆盖
*/
export function initPopupContext() {
if (!window.message) {
window.message = message;
}
if (!window.modal) {
window.modal = Modal;
}
if (!window.notification) {
window.notification = notification;
}
}
/**
* 弹窗上下文