|
|
@@ -102,14 +102,26 @@ router.onError((error) => {
|
|
|
error.message.includes("Failed to fetch dynamically imported module") ||
|
|
|
error.message.includes("Importing a module script failed")
|
|
|
) {
|
|
|
- ElNotification.warning({
|
|
|
- title: "系统更新",
|
|
|
- message: "检测到版本更新,正在刷新页面...",
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- window.location.reload();
|
|
|
- }, 2000);
|
|
|
+ // 开发模式下这类失败大多是 Vite 按需预构建/热更新导致,Vite 自身会重载,
|
|
|
+ // 这里不再强制刷新(避免把依赖预构建误报成"版本更新"、并打断同页并行加载)。
|
|
|
+ // 生产模式保留原兜底:重新部署后旧 hash chunk 会 404,需刷新拿到新 index.html。
|
|
|
+ // import.meta.env.DEV 为编译期常量,build 时会被替换并 tree-shake 掉 dev 分支,生产行为不变。
|
|
|
+ if (import.meta.env.DEV) {
|
|
|
+ ElNotification.warning({
|
|
|
+ title: "开发提示",
|
|
|
+ message: "模块加载失败(Vite 依赖预构建/热更新),Vite 将自动重载;如未恢复请手动刷新。",
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ ElNotification.warning({
|
|
|
+ title: "系统更新",
|
|
|
+ message: "检测到版本更新,正在刷新页面...",
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ window.location.reload();
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
} else {
|
|
|
ElNotification.error({
|
|
|
title: "路由错误",
|