修复项目详情页回退到首页,页面不刷新问题

This commit is contained in:
谢思 2025-09-24 10:16:12 +08:00
parent be8f926cbd
commit fd2df1505b
1 changed files with 9 additions and 3 deletions

View File

@ -193,10 +193,16 @@ class App extends Component {
this.props.history.push(`/${login}`);
}
// 添加路由监听,决定组织还是个人
this.unlisten = this.props.history.listen((location,history) => {
// if(login && )
this.unlisten = this.props.history.listen((location,action) => {
let newPathname = location.pathname.split('/')[1];
if (this.state.pathName !== newPathname) {
if (location.pathname === '/' && action === 'POP') { // 浏览器回退/前进
this.setState({
pathName: null,
pathType: null
});
return;
}
if (newPathname !== this.state.pathName) {
newPathname && this.getPathnameType(newPathname);
}
});