zzw
7 小时以前 3edc06d8b1e2449be45dbaa552f635eee72d1519
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
40
41
42
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'
import { loadDictionary } from './utils/dict'
 
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)
    }
  }
})
 
loadDictionary().then(() => {
  new Vue({
    router,
    render: h => h(App)
  }).$mount('#app')
 
  installSensitiveWords()
})