登陆后自动重定向到之前的页面
Former-commit-id: 21da16e18630a8b3064f6bdd1b8cdd2c1b760439 [formerly 21da16e18630a8b3064f6bdd1b8cdd2c1b760439 [formerly 21da16e18630a8b3064f6bdd1b8cdd2c1b760439 [formerly 21da16e18630a8b3064f6bdd1b8cdd2c1b760439 [formerly 80fff8f10f84df7860d79293a4203c93c835ab7d [formerly 4058e66ecf06d1121f63f05950c7eba795ef4f43]]]]] Former-commit-id: 193dfc5044ad4be16c9de7ee233eb98a0b7d5090 Former-commit-id: 81588f7befd8834d0a908a0a21c8d51f4f64b0c5 Former-commit-id: 7175bd2c811fb738e3698d0d120e4292363e2315 [formerly e5dbd4dfdb31f6a8474843f57d3242d9d5d6734b] Former-commit-id: a9776650ed2f81a32d47389a04e0d914b6dab62b Former-commit-id: 983a77dffbfbd6c10b6943d953552333ac34f276 Former-commit-id: d582b38c28027aa7caa1a165c5ea457dbba97f8d Former-commit-id: 0b5c23c4b6ac208cc9dfe36b76211351a4b2de06 Former-commit-id: 584fa36572a92cabbb07640ed8ec741cc7a50bf4
This commit is contained in:
@@ -26,6 +26,8 @@ router.beforeEach((to, from, next) => {
|
||||
if (token && token !== 'undefined') {
|
||||
next()
|
||||
} else {
|
||||
// 将当前预计打开的页面完整地址临时存储 登陆后继续跳转
|
||||
// 这个 cookie(redirect) 会在登陆后自动删除
|
||||
util.cookies.set('redirect', to.fullPath)
|
||||
// 没有登陆的时候跳转到登陆界面
|
||||
next({
|
||||
|
||||
@@ -41,8 +41,12 @@ export default {
|
||||
}, { root: true })
|
||||
// 用户登陆后从持久化数据加载一系列的设置
|
||||
commit('load')
|
||||
// 更新路由
|
||||
vm.$router.replace(route)
|
||||
// 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
|
||||
const path = util.cookies.get('redirect')
|
||||
// 根据是否存有重定向页面判断如何重定向
|
||||
vm.$router.replace(path ? { path } : route)
|
||||
// 删除 cookie 中保存的重定向页面
|
||||
util.cookies.remove('redirect')
|
||||
})
|
||||
.catch(err => {
|
||||
console.group('登陆结果')
|
||||
|
||||
Reference in New Issue
Block a user