Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route authority attribute behavior no use while #3522

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions src/layouts/BasicLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,52 @@ class BasicLayout extends React.Component {

getRouteAuthority = (pathname, routeData) => {
const routes = routeData.slice(); // clone
let authorities;

while (routes.length > 0) {
const route = routes.shift();
// check partial route
if (pathToRegexp(`${route.path}(.*)`).test(pathname)) {
if (route.authority) {
authorities = route.authority;
}
// is exact route?
if (pathToRegexp(route.path).test(pathname)) {
break;
}

if (route.routes) {
route.routes.forEach(r => routes.push(r));
const getAuthority = (routeDatas, path) => {
let authorities;
routeDatas.forEach(route => {
// check partial route
if (pathToRegexp(`${route.path}(.*)`).test(path)) {
if (route.authority) {
authorities = route.authority;
}
// is exact route?
if (!pathToRegexp(route.path).test(path) && route.routes) {
getAuthority(route.routes, path);
}
}
}
}
});
return authorities;
};

return authorities;
return getAuthority(routes, pathname);
xiaohuoni marked this conversation as resolved.
Show resolved Hide resolved
};

// getRouteAuthority = (pathname, routeData) => {
// const routes = routeData.slice(); // clone
// let authorities;

// while (routes.length > 0) {
// const route = routes.shift();
// // check partial route
// if (pathToRegexp(`${route.path}(.*)`).test(pathname)) {
// if (route.authority) {
// authorities = route.authority;
// }
// // is exact route?
// if (pathToRegexp(route.path).test(pathname)) {
// break;
// }

// if (route.routes) {
// route.routes.forEach(r => routes.push(r));
// }
// }
// }

// return authorities;
// };
xiaohuoni marked this conversation as resolved.
Show resolved Hide resolved

getPageTitle = (pathname, breadcrumbNameMap) => {
const currRouterData = this.matchParamsPath(pathname, breadcrumbNameMap);

Expand Down