[메뉴 권한 1차 작업]
This commit is contained in:
43
composables/usePermission.ts
Normal file
43
composables/usePermission.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 권한 체크를 위한 컴포저블
|
||||
* 컴포넌트에서 권한을 쉽게 체크할 수 있도록 도와주는 유틸리티 함수들
|
||||
*/
|
||||
export const usePermission = () => {
|
||||
const permissionsStore = usePermissionsStore();
|
||||
|
||||
return {
|
||||
// 페이지 권한 체크
|
||||
hasPagePermission: (page: string) =>
|
||||
permissionsStore.hasPagePermission(page),
|
||||
|
||||
// 메뉴 권한 체크
|
||||
hasMenuPermission: (menu: string) =>
|
||||
permissionsStore.hasMenuPermission(menu),
|
||||
|
||||
// 컴포넌트 권한 체크
|
||||
hasComponentPermission: (component: string) =>
|
||||
permissionsStore.hasComponentPermission(component),
|
||||
|
||||
// 여러 권한 중 하나라도 있는지 체크
|
||||
hasAnyPagePermission: (pages: string[]) =>
|
||||
permissionsStore.hasAnyPagePermission(pages),
|
||||
hasAnyMenuPermission: (menus: string[]) =>
|
||||
permissionsStore.hasAnyMenuPermission(menus),
|
||||
hasAnyComponentPermission: (components: string[]) =>
|
||||
permissionsStore.hasAnyComponentPermission(components),
|
||||
|
||||
// 모든 권한이 있는지 체크
|
||||
hasAllPagePermissions: (pages: string[]) =>
|
||||
pages.every(page => permissionsStore.hasPagePermission(page)),
|
||||
hasAllMenuPermissions: (menus: string[]) =>
|
||||
menus.every(menu => permissionsStore.hasMenuPermission(menu)),
|
||||
hasAllComponentPermissions: (components: string[]) =>
|
||||
components.every(component =>
|
||||
permissionsStore.hasComponentPermission(component)
|
||||
),
|
||||
|
||||
// 권한 데이터 직접 접근
|
||||
permissions: permissionsStore.permissions,
|
||||
isLoading: permissionsStore.isLoading,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user