Commit 5bbc94fc authored by zhanglw's avatar zhanglw

后台登录重定向

parent 473529cb
...@@ -9,7 +9,8 @@ import { filterAsyncRouter } from '@/store/modules/permission' ...@@ -9,7 +9,8 @@ import { filterAsyncRouter } from '@/store/modules/permission'
NProgress.configure({ showSpinner: false })// NProgress Configuration NProgress.configure({ showSpinner: false })// NProgress Configuration
const whiteList = ['/login', '/home']// no redirect whitelist const whiteList = ['/login', '/backlogin', '/home']// 免登录路由白名单
const backUrlList = ['/dashboard', '/system', '/monitor', '/sys-tools', '/backstage']// 后台路由
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.meta.title) { if (to.meta.title) {
...@@ -41,9 +42,21 @@ router.beforeEach((to, from, next) => { ...@@ -41,9 +42,21 @@ router.beforeEach((to, from, next) => {
} }
} }
} else { } else {
const findUrl = (urlList, path) => {
let flag = false
urlList.forEach(url => {
if (path.indexOf(url) !== -1) {
flag = true
}
})
return flag
}
/* has no token*/ /* has no token*/
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入 if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
next() next()
} else if (findUrl(backUrlList, to.path)) { // 后台路由重定向到后台登录
next(`/backlogin?redirect=${to.fullPath}`)
NProgress.done()
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
NProgress.done() NProgress.done()
......
...@@ -10,6 +10,11 @@ export const constantRouterMap = [ ...@@ -10,6 +10,11 @@ export const constantRouterMap = [
component: (resolve) => require(['@/views/login'], resolve), component: (resolve) => require(['@/views/login'], resolve),
hidden: true hidden: true
}, },
{ path: '/backlogin',
meta: { title: '后台登录', noCache: true },
component: (resolve) => require(['@/views/login'], resolve),
hidden: true
},
{ {
path: '/404', path: '/404',
component: (resolve) => require(['@/views/features/404'], resolve), component: (resolve) => require(['@/views/features/404'], resolve),
......
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