mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 14:20:21 +08:00
22 lines
433 B
TypeScript
22 lines
433 B
TypeScript
import { useAuthStore } from '@/store/modules/auth';
|
|
|
|
export function useAuth() {
|
|
const authStore = useAuthStore();
|
|
|
|
function hasAuth(codes: string | string[]) {
|
|
if (!authStore.isLogin) {
|
|
return false;
|
|
}
|
|
|
|
if (typeof codes === 'string') {
|
|
return authStore.userInfo.buttons.includes(codes);
|
|
}
|
|
|
|
return codes.some(code => authStore.userInfo.buttons.includes(code));
|
|
}
|
|
|
|
return {
|
|
hasAuth
|
|
};
|
|
}
|