import store from '@/store'

export function actionToObject (json) {
  try {
    return JSON.parse(json)
  } catch (e) {
    console.log('err', e.message)
  }
  return []
}

/**
 * 控制按钮是否显示
 */
export function hasBtnPermission (permission) {
  const myBtns = store.getters.buttons
  if (myBtns.indexOf('*:*:*') > -1) {
     return true
  }
  return myBtns.indexOf(permission) > -1
}