RuoYi лет назад: 5
Родитель
Сommit
4edaa14e28
2 измененных файлов с 3 добавлено и 5 удалено
  1. 2 4
      ruoyi-ui/src/permission.js
  2. 1 1
      ruoyi-ui/src/store/modules/user.js

+ 2 - 4
ruoyi-ui/src/permission.js

@@ -19,10 +19,8 @@ router.beforeEach((to, from, next) => {
19 19
     } else {
20 20
       if (store.getters.roles.length === 0) {
21 21
         // 判断当前用户是否已拉取完user_info信息
22
-        store.dispatch('GetInfo').then(res => {
23
-          // 拉取user_info
24
-          const roles = res.roles
25
-          store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
22
+        store.dispatch('GetInfo').then(() => {
23
+          store.dispatch('GenerateRoutes').then(accessRoutes => {
26 24
             // 根据roles权限生成可访问的路由表
27 25
             router.addRoutes(accessRoutes) // 动态添加可访问路由表
28 26
             next({ ...to, replace: true }) // hack方法 确保addRoutes已完成

+ 1 - 1
ruoyi-ui/src/store/modules/user.js

@@ -55,7 +55,7 @@ const user = {
55 55
     // 获取用户信息
56 56
     GetInfo({ commit, state }) {
57 57
       return new Promise((resolve, reject) => {
58
-        getInfo(state.token).then(res => {
58
+        getInfo().then(res => {
59 59
           const user = res.user
60 60
           const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : user.avatar;
61 61
           if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组