release(custom): i
This commit is contained in:
21
src/main.js
21
src/main.js
@@ -18,6 +18,27 @@ async function setupApp() {
|
||||
|
||||
await setupRouter(app)
|
||||
|
||||
app.directive('perms', {
|
||||
mounted: (el, binding) => {
|
||||
const { value } = binding
|
||||
const permissions = JSON.parse(localStorage.getItem('roles'))
|
||||
const all_permission = '*'
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length > 0) {
|
||||
const hasPermission = permissions.some((key) => {
|
||||
return all_permission == key || value.includes(key)
|
||||
})
|
||||
|
||||
if (!hasPermission) {
|
||||
el.parentNode && el.parentNode.removeChild(el)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error('like v-perms="[\'auth/menu/edit\']"')
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
app.mount('#app')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user