mo 4 years ago
parent
commit
50f5f801f4
3 changed files with 51 additions and 22 deletions
  1. 26 2
      src/App.vue
  2. 20 20
      src/permission.js
  3. 5 0
      src/utils/version.js

+ 26 - 2
src/App.vue

@@ -6,6 +6,10 @@
 </template>
 
 <script>
+import version from '@/utils/version.js'
+import Vue from 'vue'
+Vue.use(version)
+
 export default {
   name: 'App',
   provide () {
@@ -15,7 +19,26 @@ export default {
   },
   data () {
     return {
-      isRouterAlive: true
+      isRouterAlive: true,
+      ver: '1.0.0'
+    }
+  },
+  created () {
+    let version = this.version
+
+    if (version !== this.ver) {
+      this.$confirm("网站有更新请点击确定刷新页面?", "更新提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          // router.replace(targetPath);
+          location.reload()
+        })
+        .catch(() => {
+          return
+        });
     }
   },
   methods: {
@@ -138,7 +161,8 @@ input[type="number"] {
   color: #fff;
   margin-bottom: 20px;
   min-width: 100px;
-  &:focus, &:hover {
+  &:focus,
+  &:hover {
     background-color: #0e726c;
     border-color: #0e726c;
     color: #fff;

+ 20 - 20
src/permission.js

@@ -11,27 +11,27 @@ 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
-      });
+// 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
+//       });
 
-  }
-});
+//   }
+// });
 
 router.beforeEach(async (to, from, next) => {
   // from.query = to.query

+ 5 - 0
src/utils/version.js

@@ -0,0 +1,5 @@
+export default {
+  install (_this, options) {
+    _this.prototype.version = '1.0.0'//版本号
+  }
+}