Browse Source

刷新提示

wolyshaw 4 years ago
parent
commit
c94e9ad7b8
5 changed files with 27 additions and 23 deletions
  1. 0 0
      dist/index.html
  2. 0 0
      dist/static/js/app.ca31fbc9.js
  3. 0 0
      dist/static/js/app.fb9c8b1c.js
  4. 2 2
      package.json
  5. 25 21
      src/permission.js

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.ca31fbc9.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.fb9c8b1c.js


+ 2 - 2
package.json

@@ -7,7 +7,7 @@
   "scripts": {
     "dev": "vue-cli-service serve",
     "build": "vue-cli-service build",
-    "preview": "node build/index.js --preview",
+    "preview": "npx http-server ./dist -P http://dev.dayaedu.com",
     "lint": "eslint --ext .js,.vue src",
     "test:unit": "jest --clearCache && vue-cli-service test:unit",
     "test:ci": "npm run lint && npm run test:unit",
@@ -78,4 +78,4 @@
     "> 1%",
     "last 2 versions"
   ]
-}
+}

+ 25 - 21
src/permission.js

@@ -1,4 +1,4 @@
-import Vue from 'vue'
+// import Vue from 'vue'
 import router from './router'
 import store from './store'
 import { Message } from 'element-ui'
@@ -11,27 +11,31 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 const whiteList = ['/login'] // no redirect whitelist
 
-// router.onError((error) => {
-//   const isChunkLoadFailed = error.message.indexOf('chunk')
-//   const targetPath = router.history.pending.fullPath;
-//   if (isChunkLoadFailed) {
-//     // console.log(router.app.$confirm)
-//     // router.push({ path: "/403", query: { path: targetPath } })
-//     router.app.$confirm("网站有更新请点击确定刷新页面?", "更新提示", {
-//       confirmButtonText: "确定",
-//       cancelButtonText: "取消",
-//       type: "warning"
-//     })
-//       .then(() => {
-//         // router.replace(targetPath);
-//         window.reload()
-//       })
-//       .catch(() => {
-//         return
-//       });
+let isOpen = false
 
-//   }
-// });
+router.onError((error) => {
+  if (error instanceof Error) {
+    const isChunkLoadFailed = error.name.indexOf('chunk')
+    // const targetPath = router.history.pending.fullPath;
+    if (isChunkLoadFailed && !isOpen) {
+      isOpen = true
+      // console.log(router.app.$confirm)
+      // router.push({ path: "/403", query: { path: targetPath } })
+      router.app.$confirm("网站有更新请点击确定刷新页面?", "更新提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          // router.replace(targetPath);
+          window.location.reload()
+        })
+        .catch(() => {
+          return
+        });
+    }
+  }
+});
 
 router.beforeEach(async (to, from, next) => {
   // from.query = to.query

Some files were not shown because too many files changed in this diff