From f904467d3083f40ee364c70a3e1c1f37342a06d1 Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Tue, 26 Jun 2018 14:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BD=BF=E7=94=A8replace?= =?UTF-8?q?=EF=BC=8C=E7=99=BB=E5=87=BA=E6=90=BA=E5=B8=A6redirect=20for=20#?= =?UTF-8?q?1728?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/login.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/models/login.js b/src/models/login.js index 274621cb..d01b2c27 100644 --- a/src/models/login.js +++ b/src/models/login.js @@ -31,28 +31,21 @@ export default { return; } } - yield put(routerRedux.push(redirect || '/')); + yield put(routerRedux.replace(redirect || '/')); } }, - *logout(_, { put, select }) { - try { - // get location pathname - const urlParams = new URL(window.location.href); - const pathname = yield select(state => state.routing.location.pathname); - // add the parameters in the url - urlParams.searchParams.set('redirect', pathname); - window.history.replaceState(null, 'login', urlParams.href); - } finally { - yield put({ - type: 'changeLoginStatus', - payload: { - status: false, - currentAuthority: 'guest', - }, - }); - reloadAuthorized(); - yield put(routerRedux.push('/user/login')); - } + *logout(_, { put }) { + yield put({ + type: 'changeLoginStatus', + payload: { + status: false, + currentAuthority: 'guest', + }, + }); + reloadAuthorized(); + yield put( + routerRedux.push(`/user/login?redirect=${encodeURIComponent(window.location.href)}`) + ); }, }, -- GitLab