ant design pro路由重定向出错

ant design pro动态路由,进行用户权限控制,但是路由跳不到指定页面,
每次重新登录会缓存上次请求的路由列表,重定向地址也不对,

clipboard.png
重新登录又走了上一次登录的时候的路由
没有请求menu之前莫名获取到了上次登录的列表,

getBashRedirect = () => {

// 这里是重定向的,重定向到 url 的 redirect 参数所示地址
let { routerData } = this.props;
const urlParams = new URL(window.location.href);
const redirect = urlParams.searchParams.get('redirect');

if (redirect) {
  urlParams.searchParams.delete('redirect');
  window.history.replaceState(null, 'redirect', urlParams.href);
} else {
  
  const authorizedPath = Object.keys(routerData).find(
    item => check(routerData[item].authority, item) && item !== '/'
  );
  console.log('authorizedPath', authorizedPath);
  return authorizedPath;
}
return redirect;

};

阅读 8.8k
1 个回答

解决了已经,每次重新登录的时候清空props里面存储的menu routerData就可以了

推荐问题