import { useRoute } from 'vue-router' import { storeToRefs } from 'pinia' import { useUserStore } from '@/store/modules/user' import { useAppMode } from '@/hooks/core/useAppMode' const userStore = useUserStore() const useAuth = () => { const route = useRoute() const { isFrontendMode } = useAppMode() const { info } = storeToRefs(userStore) const frontendAuthList = info.value?.buttons ?? [] const backendAuthList = Array.isArray(route.meta.authList) ? route.meta.authList : [] const hasAuth = (auth) => { if (isFrontendMode.value) { return frontendAuthList.includes(auth) } return backendAuthList.some((item) => item?.authMark === auth) } return { hasAuth } } export { useAuth }