mo il y a 2 ans
Parent
commit
12d5be6746
3 fichiers modifiés avec 203 ajouts et 211 suppressions
  1. 6 2
      src/permission.js
  2. 183 201
      src/store/modules/permission.js
  3. 14 8
      src/views/noPermission.vue

+ 6 - 2
src/permission.js

@@ -9,7 +9,7 @@ import getPageTitle from '@/utils/get-page-title'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
-const whiteList = ['/login','/404','/noPermission'] // no redirect whitelist
+const whiteList = ['/login','/noPermission'] // no redirect whitelist
 
 let isOpen = false
 
@@ -108,7 +108,11 @@ router.beforeEach(async (to, from, next) => {
           const accessRoutes = await store.dispatch('permission/generateRoutes')
           // console.log(accessRoutes, 'accessRoutes')
           const isMenu = accessRoutes && accessRoutes.length > 0 ? true : false
-          accessRoutes.push({ path: '*', redirect: '/404', hidden: true })
+
+            accessRoutes.push({ path: '*', redirect: '/404', hidden: true })
+
+
+          console.log(accessRoutes,'accessRoutes')
           // 动态添加可访问的路由
           router.addRoutes(accessRoutes)
           // 确保addroutes完整的hack方法

Fichier diff supprimé car celui-ci est trop grand
+ 183 - 201
src/store/modules/permission.js


+ 14 - 8
src/views/noPermission.vue

@@ -1,5 +1,5 @@
 <template>
-  <div style="background: #fff;height: 100%;">
+  <div style="background: #fff; height: 100%">
     <div class="wscn-http404-container">
       <div class="wscn-http404">
         <div class="pic-404">
@@ -28,20 +28,26 @@
 </template>
 
 <script>
+import { removeToken } from "@/utils/auth";
 export default {
   name: "Page404",
   computed: {
     message() {
       return "很抱歉,你访问的页面不存在";
-    }
+    },
   },
   methods: {
-    onChange() {
-      this.$store.dispatch('user/resetToken').then(() => {
-        location.reload()
-      })
-    }
-  }
+    async onChange() {
+      removeToken();
+      await this.$store.dispatch("user/logout");
+      localStorage.removeItem("firstMenuUrl");
+      this.$router.push("/login");
+      // location.reload();
+      // this.$store.dispatch('user/resetToken').then(() => {
+      //   location.reload()
+      // })
+    },
+  },
 };
 </script>
 

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff