Jelajahi Sumber

招采变更

zhuangyunsheng 1 tahun lalu
induk
melakukan
bdf8d6fe28
1 mengubah file dengan 18 tambahan dan 8 penghapusan
  1. 18 8
      src/router/index.js

+ 18 - 8
src/router/index.js

@@ -1,5 +1,5 @@
 import { createRouter, createWebHashHistory } from "vue-router";
-import { ElNotification, ElMessageBox } from "element-plus";
+import { ElMessageBox } from "element-plus";//ElNotification, 
 import config from "@/config";
 import NProgress from "nprogress";
 import "nprogress/nprogress.css";
@@ -170,14 +170,24 @@ router.afterEach((to, from) => {
 });
 
 router.onError((error) => {
-    console.log('routerError:message', error.message)
-    console.log('routerError:targetPath', router.history.pending.fullPath)
+    ElMessageBox.confirm(`routerError:message: ${error.message}`, 'Warning', {
+        confirmButtonText: 'OK',
+        cancelButtonText: 'Cancel',
+        type: 'warning',
+        center: true,
+    })
+    ElMessageBox.confirm(`routerError:targetPath: ${router.history.pending.fullPath}`, 'Warning', {
+        confirmButtonText: 'OK',
+        cancelButtonText: 'Cancel',
+        type: 'warning',
+        center: true,
+    })
     NProgress.done();
-    const pattern = /Loading chunk (\d)+ failed/g;
-    const isChunkLoadFailed = error.message.match(pattern);
-    const targetPath = router.history.pending.fullPath;
-    if (isChunkLoadFailed) router.replace(targetPath);
-    else ElNotification.error({ title: "路由错误", message: error.message });
+    // const pattern = /Loading chunk (\d)+ failed/g;
+    // const isChunkLoadFailed = error.message.match(pattern);
+    // const targetPath = router.history.pending.fullPath;
+    // if (isChunkLoadFailed) router.replace(targetPath);
+    // else ElNotification.error({ title: "路由错误", message: error.message });
 });
 
 // 生成路由对象