|
|
@ -4,6 +4,7 @@ import { Message } from 'element-ui' |
|
|
|
import NProgress from 'nprogress' |
|
|
|
import 'nprogress/nprogress.css' |
|
|
|
import { getToken } from '@/utils/auth' |
|
|
|
import { loginProxy } from './api/login' |
|
|
|
|
|
|
|
NProgress.configure({ showSpinner: false }) |
|
|
|
|
|
|
@ -65,7 +66,17 @@ router.beforeEach((to, from, next) => { |
|
|
|
// 在免登录白名单,直接进入
|
|
|
|
next() |
|
|
|
} else { |
|
|
|
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
|
|
loginProxy().then(res => { |
|
|
|
if (res.code === 200) { |
|
|
|
var type = res.data.type |
|
|
|
if(type === 'redirect'){ |
|
|
|
window.location.href = res.data.url |
|
|
|
} |
|
|
|
} else { |
|
|
|
Message.error(res.msg) |
|
|
|
} |
|
|
|
next(`/login?redirect=${to.fullPath}`) |
|
|
|
}) |
|
|
|
NProgress.done() |
|
|
|
} |
|
|
|
} |
|
|
|