From aa6758808281f749c8f16e6904a53d507fdcab35 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Fri, 16 Mar 2018 10:07:47 +0800 Subject: [PATCH] fix redirect loop (#1103) * fix redirect loop #1098 * remove useless param --- src/layouts/BasicLayout.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index e1534d05..60339b99 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -17,7 +17,7 @@ import { getMenuData } from '../common/menu'; import logo from '../assets/logo.svg'; const { Content, Header, Footer } = Layout; -const { AuthorizedRoute } = Authorized; +const { AuthorizedRoute, check } = Authorized; /** * 根据菜单取得重定向地址. @@ -109,7 +109,11 @@ class BasicLayout extends React.PureComponent { urlParams.searchParams.delete('redirect'); window.history.replaceState(null, 'redirect', urlParams.href); } else { - return '/dashboard/analysis'; + const { routerData } = this.props; + // get the first authorized route path in routerData + const authorizedPath = Object.keys(routerData).find(item => + check(routerData[item].authority, item) && item !== '/'); + return authorizedPath; } return redirect; } -- GitLab