Commit 6c02c95d authored by zhanglw's avatar zhanglw

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

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