From fd2df1505b0dbd277dbeb434835fdc491eb0c4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Wed, 24 Sep 2025 10:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=9B=9E=E9=80=80=E5=88=B0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=88=B7=E6=96=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index ba03ec5c..5c339f65 100644 --- a/src/App.js +++ b/src/App.js @@ -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); } });