feat: 角色认证判断
This commit is contained in:
@@ -15,7 +15,20 @@ export function useAuth() {
|
|||||||
return codes.some(code => authStore.userInfo.buttons.includes(code));
|
return codes.some(code => authStore.userInfo.buttons.includes(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasRole(role: string | string[]) {
|
||||||
|
if (!authStore.isLogin) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof role === 'string') {
|
||||||
|
return authStore.userInfo.roles.includes(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
return role.some(code => authStore.userInfo.roles.includes(code));
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasAuth
|
hasAuth,
|
||||||
|
hasRole,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user