wangzhonglu hace 1 año
padre
commit
e0e4064929
Se han modificado 2 ficheros con 12 adiciones y 10 borrados
  1. 1
    9
      src/router/index.js
  2. 11
    1
      src/views/layout.vue

+ 1
- 9
src/router/index.js Ver fichero

@@ -63,15 +63,7 @@ router.beforeEach((to, from, next) => {
63 63
   } else {
64 64
     let u = localStorage.getItem("xhWebAdminUser");
65 65
     if (u) {
66
-      let ju = JSON.parse(u);
67
-      if (ju) {
68
-        next();
69
-      } else {
70
-        next({
71
-          path: "/login",
72
-          query: to.query
73
-        });
74
-      }
66
+      next();
75 67
     } else {
76 68
       next({
77 69
         path: "/login",

+ 11
- 1
src/views/layout.vue Ver fichero

@@ -23,7 +23,7 @@
23 23
         <router-link class="header_html_item" :to="{ path: '/log' }"
24 24
           >登录日志</router-link
25 25
         >
26
-        <router-link class="log_out" :to="{ path: '/login' }">退出</router-link>
26
+        <div class="log_out" @click="toLogOut()">退出</div>
27 27
       </div>
28 28
     </div>
29 29
     <div class="layout_out">
@@ -33,6 +33,16 @@
33 33
     </div>
34 34
   </div>
35 35
 </template>
36
+<script>
37
+export default {
38
+  methods: {
39
+    toLogOut() {
40
+      localStorage.setItem("xhWebAdminUser", "");
41
+      this.$router.replace({ path: "/login" });
42
+    }
43
+  }
44
+};
45
+</script>
36 46
 
37 47
 <style scoped lang="less">
38 48
 html,

Loading…
Cancelar
Guardar