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.
19 lines
440 B
React
19 lines
440 B
React
1 year ago
|
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)) {
|
||
|
return children
|
||
|
} else {
|
||
|
return (
|
||
|
<Result
|
||
|
status='403'
|
||
|
title='403'
|
||
|
subTitle={'抱歉,你没有权限使用该功能。'}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
}
|