committed by
偏右
4 changed files with 27 additions and 2 deletions
@ -0,0 +1,18 @@ |
|||
import React from 'react'; |
|||
import RenderAuthorized from '@/components/Authorized'; |
|||
import Exception from '@/components/Exception'; |
|||
import { matchRoutes } from 'react-router-config'; |
|||
|
|||
const Authorized = RenderAuthorized('user'); |
|||
const noMatch = <Exception type="403" style={{ minHeight: 500, height: '80%' }} />; |
|||
|
|||
export default ({ children, route, location }) => { |
|||
const branch = |
|||
matchRoutes(route.routes, location.pathname).filter(item => item.match.isExact)[0] || {}; |
|||
const { authority } = branch.route || {}; |
|||
return ( |
|||
<Authorized authority={authority} noMatch={noMatch}> |
|||
{children} |
|||
</Authorized> |
|||
); |
|||
}; |
|||
Loading…
Reference in new issue