| | |
| | | import { useUserStore } from '@/store/modules/user' |
| | | |
| | | function extractRoleCodes(roles) { |
| | | if (!Array.isArray(roles)) { |
| | | return [] |
| | | } |
| | | |
| | | return roles |
| | | .map((item) => { |
| | | if (typeof item === 'string') { |
| | | return item |
| | | } |
| | | if (item && typeof item === 'object') { |
| | | return item.code || item.name || '' |
| | | } |
| | | return '' |
| | | }) |
| | | .filter(Boolean) |
| | | } |
| | | |
| | | function checkRolePermission(el, binding) { |
| | | const userStore = useUserStore() |
| | | const userRoles = userStore.getUserInfo.roles |
| | | const userRoles = extractRoleCodes(userStore.getUserInfo.roles) |
| | | if (!userRoles?.length) { |
| | | removeElement(el) |
| | | return |