feat: add hasPermissions util

This commit is contained in:
xiaoxian521 2021-12-13 14:08:12 +08:00
parent 653bafaa2b
commit e97bd9c8c4

View File

@ -249,11 +249,31 @@ const getHistoryMode = (): RouterHistory => {
}
};
// 是否有权限
const hasPermissions = (value: Array<string>): boolean => {
if (value && value instanceof Array && value.length > 0) {
const roles = usePermissionStoreHook().buttonAuth;
const permissionRoles = value;
const hasPermission = roles.some(role => {
return permissionRoles.includes(role);
});
if (!hasPermission) {
return false;
}
return true;
} else {
return false;
}
};
export {
ascending,
filterTree,
initRouter,
resetRouter,
hasPermissions,
getHistoryMode,
addAsyncRoutes,
delAliveRoutes,