| | |
| | | |
| | | 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) |