Commit 7c1e9d41 authored by ι™ˆε°θͺ's avatar ι™ˆε°θͺ Committed by ι™ˆεΈ…

Route authority attribute behavior (#3514)

parent bb045ead
...@@ -88,20 +88,29 @@ class BasicLayout extends React.Component { ...@@ -88,20 +88,29 @@ class BasicLayout extends React.Component {
return breadcrumbNameMap[pathKey]; return breadcrumbNameMap[pathKey];
}; };
getRouterAuthority = (pathname, routeData) => { getRouteAuthority = (pathname, routeData) => {
let routeAuthority = ['noAuthority']; const routes = routeData.slice(); // clone
const getAuthority = (key, routes) => { let authorities;
routes.forEach(route => {
if (route.path && pathToRegexp(route.path).test(key)) { while (routes.length > 0) {
routeAuthority = route.authority; const route = routes.shift();
} else if (route.routes) { // check partial route
routeAuthority = getAuthority(key, route.routes); if (pathToRegexp(`${route.path}(.*)`).test(pathname)) {
if (route.authority) {
authorities = route.authority;
} }
return route; // is exact route?
}); if (pathToRegexp(route.path).test(pathname)) {
return routeAuthority; break;
}; }
return getAuthority(pathname, routeData);
if (route.routes) {
route.routes.forEach(r => routes.push(r));
}
}
}
return authorities;
}; };
getPageTitle = (pathname, breadcrumbNameMap) => { getPageTitle = (pathname, breadcrumbNameMap) => {
...@@ -161,7 +170,7 @@ class BasicLayout extends React.Component { ...@@ -161,7 +170,7 @@ class BasicLayout extends React.Component {
} = this.props; } = this.props;
const isTop = PropsLayout === 'topmenu'; const isTop = PropsLayout === 'topmenu';
const routerConfig = this.getRouterAuthority(pathname, routes); const routerConfig = this.getRouteAuthority(pathname, routes);
const contentStyle = !fixedHeader ? { paddingTop: 0 } : {}; const contentStyle = !fixedHeader ? { paddingTop: 0 } : {};
const layout = ( const layout = (
<Layout> <Layout>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment