This commit is contained in:
2023-06-08 21:09:28 +08:00
parent d778ceab61
commit f8947d332a
158 changed files with 17210 additions and 259 deletions

View File

@@ -0,0 +1,29 @@
import role from "./role"
const checkRole = (el, binding) => {
const { value } = binding
if (Array.isArray(value)) {
if (value.length > 0) {
let isHas = false
value.map((item) => {
isHas = role(item)
})
if (!isHas && el.parentNode) {
el.parentNode.removeChild(el)
}
}
} else {
throw new Error(`need role! Like v-role="['seo', 'cfo']"`)
}
}
export default {
mounted(el, binding) {
checkRole(el, binding)
},
updated(el, binding) {
checkRole(el, binding)
}
}

View File

@@ -0,0 +1,11 @@
import { useUserStore } from "@/store"
const role = (name) => {
const userStore = useUserStore()
return (
(userStore.roles && userStore.roles.includes(name)) ||
(userStore.roles && userStore.roles.includes("superAdmin"))
)
}
export default role