import React from 'react';
import RenderAuthorized from '@/components/Authorized';
import Exception from '@/components/Exception';
import { matchRoutes } from 'react-router-config';
import uniq from 'lodash/uniq';
const Authorized = RenderAuthorized(['admin', 'user']);
const noMatch = ;
export default ({ children, route, location }) => {
const routes = matchRoutes(route.routes, location.pathname);
let authorities = [];
routes.forEach(item => {
if (Array.isArray(item.authority)) {
authorities = authorities.concat(item.authority);
} else if (typeof item.authority === 'string') {
authorities.push(item.authority);
}
});
return (
{children}
);
};