Pārlūkot izejas kodu

桥梁选择以及切换

luyanan 6 gadi atpakaļ
vecāks
revīzija
895b7e866f
2 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 2 2
      src/permission.js
  2. 1 1
      src/views/layout/components/TopNavbar.vue

+ 2 - 2
src/permission.js

23
      NProgress.done()
23
      NProgress.done()
24
    } else {
24
    } else {
25
      if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
25
      if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
26
        console.log(5555)
26
        // console.log(5555)
27
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
27
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
28
          const roles = [res.data.type.toString()]
28
          const roles = [res.data.type.toString()]
29
          store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
29
          store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
37
          })
37
          })
38
        })
38
        })
39
      } else {
39
      } else {
40
        console.log(4444)
40
        // console.log(4444)
41
        if (hasPermission(store.getters.roles, to.meta.roles)) {
41
        if (hasPermission(store.getters.roles, to.meta.roles)) {
42
          next()
42
          next()
43
        }
43
        }

+ 1 - 1
src/views/layout/components/TopNavbar.vue

52
      'roles'
52
      'roles'
53
    ])
53
    ])
54
  },
54
  },
55
  watch:{
55
  watch: {
56
    '$route'(to, from) {
56
    '$route'(to, from) {
57
      if (this.$route.path === '/') {
57
      if (this.$route.path === '/') {
58
        this.showName = ''
58
        this.showName = ''