zzw
昨天 f9114ffadfab1c01198dd980c3afb66d0c44a5ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router'
import './styles/global.css'
import { installSensitiveWords } from './utils/sensitive'
 
Vue.use(ElementUI, { size: 'small' })
Vue.config.productionTip = false
 
Vue.prototype.$appName = 'rk_SystemName'
 
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)
}).$mount('#app')
 
installSensitiveWords()