ソースを参照

优化进入login页面后依然可以回退到页面的问题

zhangliang2 2 年 前
コミット
28105ed12c
2 ファイル変更15 行追加3 行削除
  1. 12 2
      src/router/filter.js
  2. 3 1
      src/views/login.vue

+ 12 - 2
src/router/filter.js

@@ -9,7 +9,8 @@ Router.prototype.push = function push(location) {
 
 
 router.beforeEach((to, from, next) => {
-    // console.log(to);
+    console.log(from);
+    console.log(to);
     if (to.fullPath === '/' || to.name === '*') {
         let {
             code,
@@ -32,6 +33,15 @@ router.beforeEach((to, from, next) => {
             });
         }
     } else {
-        next();
+        if (from.path === '/login' || from.name === 'login') {
+            if (localStorage.getItem('Authorization')) {
+                next();
+            } else {
+                // next(false);
+                return false
+            }
+        } else {
+            next();
+        }
     }
 });

+ 3 - 1
src/views/login.vue

@@ -128,7 +128,9 @@ export default {
         },
     },
 
-    // mounted: {},
+    mounted() {
+        localStorage.clear();
+    },
 };
 </script>