2
0

perf: 合并用户平台框架修改

This commit is contained in:
TsMask
2024-12-03 16:46:39 +08:00
parent 13ee5a3849
commit c6b0c60392
30 changed files with 631 additions and 874 deletions

View File

@@ -1,4 +1,4 @@
import { useAuthStore } from '@/store/modules/auth';
import {useAuthStore} from '@/store/modules/auth';
export function useAuth() {
const authStore = useAuthStore();
@@ -15,7 +15,20 @@ export function useAuth() {
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 {
hasAuth
hasAuth,
hasRole,
};
}