2025-09-23 14:15:32 +09:00
|
|
|
/**
|
|
|
|
|
* 권한 체크를 위한 컴포저블
|
|
|
|
|
* 컴포넌트에서 권한을 쉽게 체크할 수 있도록 도와주는 유틸리티 함수들
|
|
|
|
|
*/
|
|
|
|
|
export const usePermission = () => {
|
|
|
|
|
const permissionsStore = usePermissionsStore();
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
// 페이지 권한 체크
|
|
|
|
|
hasPagePermission: (page: string) =>
|
|
|
|
|
permissionsStore.hasPagePermission(page),
|
|
|
|
|
|
2025-09-23 15:21:00 +09:00
|
|
|
// 페이지그룹 권한 체크
|
|
|
|
|
hasPageGroupPermission: (pageGroup: string) =>
|
|
|
|
|
permissionsStore.hasPageGroupPermission(pageGroup),
|
2025-09-23 14:15:32 +09:00
|
|
|
|
|
|
|
|
// 컴포넌트 권한 체크
|
|
|
|
|
hasComponentPermission: (component: string) =>
|
|
|
|
|
permissionsStore.hasComponentPermission(component),
|
|
|
|
|
|
|
|
|
|
// 여러 권한 중 하나라도 있는지 체크
|
|
|
|
|
hasAnyPagePermission: (pages: string[]) =>
|
|
|
|
|
permissionsStore.hasAnyPagePermission(pages),
|
2025-09-23 15:21:00 +09:00
|
|
|
hasAnyPageGroupPermission: (pageGroups: string[]) =>
|
|
|
|
|
permissionsStore.hasAnyPageGroupPermission(pageGroups),
|
2025-09-23 14:15:32 +09:00
|
|
|
hasAnyComponentPermission: (components: string[]) =>
|
|
|
|
|
permissionsStore.hasAnyComponentPermission(components),
|
|
|
|
|
|
|
|
|
|
// 모든 권한이 있는지 체크
|
|
|
|
|
hasAllPagePermissions: (pages: string[]) =>
|
|
|
|
|
pages.every(page => permissionsStore.hasPagePermission(page)),
|
2025-09-23 15:21:00 +09:00
|
|
|
hasAllPageGroupPermissions: (pageGroups: string[]) =>
|
|
|
|
|
pageGroups.every(pageGroup =>
|
|
|
|
|
permissionsStore.hasPageGroupPermission(pageGroup)
|
|
|
|
|
),
|
2025-09-23 14:15:32 +09:00
|
|
|
hasAllComponentPermissions: (components: string[]) =>
|
|
|
|
|
components.every(component =>
|
|
|
|
|
permissionsStore.hasComponentPermission(component)
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// 권한 데이터 직접 접근
|
2025-09-23 17:12:41 +09:00
|
|
|
permissions: computed(() => permissionsStore.permissions),
|
|
|
|
|
resources: computed(() => permissionsStore.permissions?.resources),
|
|
|
|
|
isLoading: computed(() => permissionsStore.isLoading),
|
|
|
|
|
|
|
|
|
|
// 리소스별 전체 접근 함수
|
|
|
|
|
getPageGroups: () =>
|
|
|
|
|
permissionsStore.permissions?.resources?.pageGroups || [],
|
|
|
|
|
getPages: () => permissionsStore.permissions?.resources?.pages || [],
|
|
|
|
|
getComponents: () =>
|
|
|
|
|
permissionsStore.permissions?.resources?.components || [],
|
2025-09-23 14:15:32 +09:00
|
|
|
};
|
|
|
|
|
};
|