Commit 6c02c95d authored by zhanglw's avatar zhanglw

前后台路由调整,跟路由重定向

parent 828e600f
......@@ -20,7 +20,7 @@ router.beforeEach((to, from, next) => {
if (getToken()) {
// 已登录且要跳转的页面是登录页
if (to.path === '/login') {
next({ path: '/' })
next({ path: '/backstage/dashboard' })
NProgress.done()
} else {
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
......@@ -52,7 +52,9 @@ router.beforeEach((to, from, next) => {
return flag
}
/* has no token*/
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
if (to.path === '/') { // 根路由重定向到前台home页
next('/home')
} else if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
next()
} else if (findUrl(backUrlList, to.path)) { // 后台路由重定向到后台登录
next(`/backlogin?redirect=${to.fullPath}`)
......
......@@ -53,7 +53,7 @@ export const constantRouterMap = [
hidden: true
},
{
path: '/',
path: '/backstage',
component: Layout,
redirect: '/dashboard',
children: [
......
......@@ -140,7 +140,7 @@ export default {
}
this.$store.dispatch('Login', user).then(() => {
this.loading = false
this.$router.push({ path: this.redirect || '/' })
this.$router.push({ path: this.redirect || '/backstage/dashboard' })
}).catch(() => {
this.loading = false
this.getCode()
......
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