Ant-design-pro: V4 TS版登录成功又返回登录页面

Created on 18 Jun 2019  ·  12Comments  ·  Source: ant-design/ant-design-pro

使用V4最新TS版,登录成功后一直跳回登录页面,浏览器直接输入/可以访问主页面,请问怎么解决?

🛑 bug

All 12 comments

我也遇到了这个问题,请问您的解决了吗

解决了,但是办法比较粗暴,在*login这个effect里面,登录成功不走routerRedux.push,直接
window.location.href = '/'
进去首页

哦哦,routerRedux.push(),时常出现这样的问题,重新npm run start又可以登陆进去了,好奇怪

但是,我重新清除缓存,然后在npm run start,就不行了

你看下,调用的API是不是返回了401的错误,调用API里面只要有一个有401的错误。
图片

这个会让回到登陆界面。

返回是200

我也遇到这个问题,没有好的解决方法吗

你们都开始用V4 的版本了?

权限的问题,因为我断点调试,它进入了Authorized.tsx文件,并重定向到了/user/login,造成了“返回登录页面”的假象

已解决问题: v4版本安装的login组件:
if (response.status === 'ok') {
const urlParams = new URL(window.location.href);
缺少了:
reloadAuthorized();

改为:
if (response.status === 'ok') {
reloadAuthorized();
const urlParams = new URL(window.location.href);

导致登录后没有刷新身份,从而重定向到了被Authorized.ts这个组件重定向到了/user/login。

@huang714669 的解决方案确实可以解决问题,但代价是刷新网页。

@keke122765 正解,多谢!

@chenshuai2144 I think this method(add reloadAuthorized()) should be added to the code repository. For the moment, I didn't expect any better solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lvzheng0404 picture lvzheng0404  ·  3Comments

RichardStark picture RichardStark  ·  3Comments

yaoleiroyal picture yaoleiroyal  ·  3Comments

yjz1004 picture yjz1004  ·  3Comments

happier2 picture happier2  ·  3Comments