浏览代码

bug修复

chenrui 4 年之前
父节点
当前提交
e501837ef1
共有 2 个文件被更改,包括 20 次插入5 次删除
  1. 19 4
      src/permission.js
  2. 1 1
      src/views/CarWashManagement/DetailsCarWashModal.vue

+ 19 - 4
src/permission.js

@@ -43,10 +43,25 @@ router.beforeEach((to, from, next) => {
             const roles = res
             // console.log(roles, 'roles')
             if (roles.permissionList.length == 0 || !roles) {
-              store.dispatch('Logout').then(() => {
-                store.dispatch('ResetRoutes').then(() => {
-                  next({ path: '/user/login', query: { redirect: to.fullPath } })
-                })
+              // 账号无权限登录之后则直接退出
+              // store.dispatch('Logout').then(() => {
+              //   store.dispatch('ResetRoutes').then(() => {
+              //     next({ path: '/user/login', query: { redirect: to.fullPath } })
+              //   })
+              // })
+              //  账号无权限登录进去则只有首页
+              store.dispatch('GenerateRoutes', { roles }).then(() => {
+                // 根据roles权限生成可访问的路由表
+                // 动态添加可访问路由表
+                // router.addRoutes(store.getters.addRouters)
+                const redirect = decodeURIComponent(from.query.redirect || to.path)
+                if (to.path === redirect) {
+                  // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
+                  next()
+                } else {
+                  // 跳转到目的路由
+                  next({ path: redirect })
+                }
               })
             } else {
               store.dispatch('GenerateRoutes', { roles }).then(() => {

+ 1 - 1
src/views/CarWashManagement/DetailsCarWashModal.vue

@@ -82,7 +82,7 @@
           <p class="item-label">现场照片:</p>
           <p class="item-main"><img :src="pic" class="small-pic" @click="isPicModal = true" /></p>
         </a-col>
-        <a-col :span="24" class="btn-cont"><a-button @click="isShow = false">取消</a-button></a-col>
+        <a-col :span="24" class="btn-cont"><a-button @click="isShow = false">返回列表</a-button></a-col>
       </a-row>
     </a-modal>