cshenfu
2024-06-27 58aa6e282bb343503be3cb198948328ea3ed7b79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export default function(Vue){
  // #ifndef VUE3
    Vue.prototype.$hasPermission = function hasPermission(name) {
        const permission = this.$store.state.$user.permission || []
        return permission.indexOf(name) > -1
    }
    Vue.prototype.$hasRole = function hasRole(name) {
        const role = this.$store.state.$user.userInfo.role || []
        return role.indexOf(name) > -1
    }
  // #endif
  
  // #ifdef VUE3
  Vue.config.globalProperties.$hasPermission = function hasPermission(name) {
      const permission = this.$store.state.$user.permission || []
      return permission.indexOf(name) > -1
  }
  Vue.config.globalProperties.$hasRole = function hasRole(name) {
      const role = this.$store.state.$user.userInfo.role || []
      return role.indexOf(name) > -1
  }
   // #endif
}