You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/components/RequireAuth.jsx

20 lines
511 B
React

import { Result } from 'antd'
import useAuthStore from '@/stores/Auth'
export default function RequireAuth({ children, ...props }, ) {
const isPermitted = useAuthStore((state) => state.isPermitted)
if (isPermitted(props.subject)) {
// if (props.subject === '/account/management') {
return children
} else if (props.result) {
return (
<Result
status='403'
title='403'
subTitle={'抱歉,你没有权限使用该功能。'}
/>
)
}
}