feat: 登入后跳转至原地址
This commit is contained in:
parent
37f07b473e
commit
a609ca7638
|
@ -26,6 +26,9 @@ const router = new VueRouter({
|
|||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
|
||||
redirectLoginPath(to.fullPath);
|
||||
|
||||
//解决localStorage清空,cookie没失效导致的卡死问题
|
||||
if (!localStorage.getItem('Admin-Token')) {
|
||||
axios.get("/signout");
|
||||
|
@ -38,4 +41,17 @@ router.beforeEach((to, from, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
// 登入后跳转至原路径
|
||||
function redirectLoginPath(originPath) {
|
||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||
let loginSuccess = sessionStorage.getItem('loginSuccess');
|
||||
sessionStorage.setItem('redirectUrl', originPath);
|
||||
if (redirectUrl && loginSuccess) {
|
||||
sessionStorage.removeItem('loginSuccess');
|
||||
router.push(redirectUrl);
|
||||
}
|
||||
sessionStorage.removeItem('loginSuccess');
|
||||
}
|
||||
|
||||
|
||||
export default router
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0368a1888936d4ae75554e5341509379982e243c
|
||||
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
|
Loading…
Reference in New Issue