|
|
|
@ -11,12 +11,23 @@ import {
|
|
|
|
|
|
|
|
|
|
let loadAsyncRouter = false
|
|
|
|
|
const whiteList = ['/login', '/welcome'] // 不重定向白名单
|
|
|
|
|
// 获取参数
|
|
|
|
|
function getUrlKey(name, url) {
|
|
|
|
|
// eslint-disable-next-line no-sparse-arrays
|
|
|
|
|
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ''])[1].replace(/\+/g, '%20')) || null
|
|
|
|
|
}
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
if (to.meta.disabled) {
|
|
|
|
|
next(false)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
NProgress.start()
|
|
|
|
|
if (!getAuth() && window.location.href.indexOf('authkey') >= 0) {
|
|
|
|
|
store.commit('SET_AUTH', {
|
|
|
|
|
authKey: getUrlKey('authkey', window.location.href),
|
|
|
|
|
sessionId: getUrlKey('sessionid', window.location.href)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/** 请求头包含授权信息 并且 页面必须授权 直接进入 */
|
|
|
|
|
if (getAuth()) {
|
|
|
|
|
if (whiteList.includes(to.path)) {
|
|
|
|
|