zzw
13 小时以前 3edc06d8b1e2449be45dbaa552f635eee72d1519
emergency-repair-web/src/main.js
@@ -5,15 +5,38 @@
import router from './router'
import './styles/global.css'
import { installSensitiveWords } from './utils/sensitive'
import { loadDictionary } from './utils/dict'
Vue.use(ElementUI, { size: 'small' })
Vue.config.productionTip = false
Vue.prototype.$appName = '临抢修管理系统'
Vue.prototype.$appName = 'rk_SystemName'
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
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
  }
}
installSensitiveWords()
Vue.directive('permission', {
  inserted(el, binding) {
    if (binding.value && !Vue.prototype.$hasPermission(binding.value) && el.parentNode) {
      el.parentNode.removeChild(el)
    }
  }
})
loadDictionary().then(() => {
  new Vue({
    router,
    render: h => h(App)
  }).$mount('#app')
  installSensitiveWords()
})