2022-04-04 02:54:31 +08:00
|
|
|
import { useAuthStore } from "../stores"
|
2022-03-06 02:06:07 +08:00
|
|
|
import { IGroup } from "../models/auth";
|
2021-10-29 07:18:28 +08:00
|
|
|
|
2022-03-07 04:39:34 +08:00
|
|
|
async function canAccessPage(pageName: string) {
|
2022-04-04 02:54:31 +08:00
|
|
|
const authStore = useAuthStore();
|
|
|
|
|
|
|
|
const groups = authStore.auth?.user?.groups
|
2022-03-07 04:39:34 +08:00
|
|
|
|
|
|
|
if(!groups || groups?.length == 0 ) return false
|
|
|
|
|
2022-03-06 02:06:07 +08:00
|
|
|
const group = groups![0] as IGroup;
|
2021-10-29 07:18:28 +08:00
|
|
|
|
2022-03-06 02:06:07 +08:00
|
|
|
if (group) {
|
|
|
|
return group?.pages?.includes(pageName);
|
|
|
|
}
|
2021-10-29 07:18:28 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default canAccessPage;
|