Commit 87ca9fd5 authored by jim's avatar jim

fix #729 prevent pollution url history

parent df93c649
......@@ -102,10 +102,15 @@ class BasicLayout extends React.PureComponent {
// According to the url parameter to redirect
// ่ฟ™้‡Œๆ˜ฏ้‡ๅฎšๅ‘็š„,้‡ๅฎšๅ‘ๅˆฐ url ็š„ redirect ๅ‚ๆ•ฐๆ‰€็คบๅœฐๅ€
const urlParams = new URL(window.location.href);
const redirect = urlParams.searchParams.get('redirect') || '/dashboard/analysis';
const redirect = urlParams.searchParams.get('redirect');
// Remove the parameters in the url
urlParams.searchParams.delete('redirect');
window.history.pushState(null, 'redirect', urlParams.href);
if (redirect) {
urlParams.searchParams.delete('redirect');
window.history.replaceState(null, 'redirect', urlParams.href);
} else {
return '/dashboard/analysis';
}
return redirect;
}
handleMenuCollapse = (collapsed) => {
......
......@@ -31,7 +31,7 @@ export default {
const pathname = yield select(state => state.routing.location.pathname);
// add the parameters in the url
urlParams.searchParams.set('redirect', pathname);
window.history.pushState(null, 'login', urlParams.href);
window.history.replaceState(null, 'login', urlParams.href);
} finally {
// yield put(routerRedux.push('/user/login'));
// Login out after permission changes to admin or user
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment