parent
9c5352ecd6
commit
ed4427243d
|
@ -52,7 +52,7 @@ router.beforeEach((to, from, next) => {
|
||||||
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
|
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next('/login') // 否则全部重定向到登录页
|
next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页
|
||||||
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,9 +96,19 @@ export default {
|
||||||
},
|
},
|
||||||
passwordType: 'password',
|
passwordType: 'password',
|
||||||
loading: false,
|
loading: false,
|
||||||
showDialog: false
|
showDialog: false,
|
||||||
|
redirect: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
$route: {
|
||||||
|
handler: function(route) {
|
||||||
|
this.redirect = route.query && route.query.redirect
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
// window.addEventListener('hashchange', this.afterQRScan)
|
// window.addEventListener('hashchange', this.afterQRScan)
|
||||||
},
|
},
|
||||||
|
@ -119,7 +129,7 @@ export default {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
|
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.$router.push({ path: '/' })
|
this.$router.push({ path: this.redirect || '/' })
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue