feat: add v-access directive

This commit is contained in:
vince
2024-07-18 21:31:34 +08:00
parent 910a3553ac
commit 01e95e029f
14 changed files with 89 additions and 36 deletions

View File

@@ -14,7 +14,7 @@ function useAccess() {
* @description: Determine whether there is permissionThe role is judged by the user's role
* @param roles
*/
function hasAuthByRoles(roles: string[]) {
function hasAccessByRoles(roles: string[]) {
const userRoleSet = new Set(coreAccessStore.userRoles);
const intersection = roles.filter((item) => userRoleSet.has(item));
return intersection.length > 0;
@@ -25,7 +25,7 @@ function useAccess() {
* @description: Determine whether there is permissionThe permission code is judged by the user's permission code
* @param codes
*/
function hasAuthByCodes(codes: string[]) {
function hasAccessByCodes(codes: string[]) {
const userCodesSet = new Set(coreAccessStore.accessCodes);
const intersection = codes.filter((item) => userCodesSet.has(item));
@@ -43,8 +43,8 @@ function useAccess() {
return {
accessMode,
hasAuthByCodes,
hasAuthByRoles,
hasAccessByCodes,
hasAccessByRoles,
toggleAccessMode,
};
}