zzw
昨天 0642bc9c44d1c8277ada33059c4a3e6156335b30
emergency-repair-web/src/main.js
@@ -11,6 +11,26 @@
Vue.prototype.$appName = '临抢修管理系统'
Vue.prototype.$hasPermission = function(code) {
  const raw = sessionStorage.getItem('permissions')
  if (raw === null) return true
  try {
    const list = JSON.parse(raw)
    if (!Array.isArray(list)) return true
    return list.indexOf(code) >= 0
  } catch (e) {
    return true
  }
}
Vue.directive('permission', {
  inserted(el, binding) {
    if (binding.value && !Vue.prototype.$hasPermission(binding.value) && el.parentNode) {
      el.parentNode.removeChild(el)
    }
  }
})
new Vue({
  router,
  render: h => h(App)