export default {
  install(Vue) {
    Vue.prototype.checkPermission = function(menuName, btnName) {
      const funcArr = zzSessionStorage.getItem('FuncTree') ? JSON.parse(zzSessionStorage.getItem('FuncTree')) : {}
      if (Object.keys(funcArr).length !== 0) {
        if (funcArr[menuName] && funcArr[menuName] instanceof Array && funcArr[menuName].length > 0) {
          const permissionBtn = btnName
          const hasPermission = funcArr[menuName].some(item => {
            return permissionBtn === item
          })
          return hasPermission
        } else {
          return false
        }
      } else {
        return false
      }
    }
  }
}
