|
|
|
|
@ -2,7 +2,8 @@ import router from './router'
|
|
|
|
|
import store from './store'
|
|
|
|
|
import {
|
|
|
|
|
Message
|
|
|
|
|
} from 'element-ui'
|
|
|
|
|
} from 'element-ui'
|
|
|
|
|
import { deepCopy } from '@/utils'
|
|
|
|
|
import NProgress from 'nprogress' // progress bar
|
|
|
|
|
import 'nprogress/nprogress.css' // progress bar style
|
|
|
|
|
import {
|
|
|
|
|
@ -39,7 +40,7 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
// determine whether the user has obtained his permission roles through getInfo
|
|
|
|
|
const hasRoles = store.getters.roles && store.getters.roles.length > 0
|
|
|
|
|
if (hasRoles) {
|
|
|
|
|
next()
|
|
|
|
|
to.query.tourl ? next(to.query.tourl) : next()
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
// get user info
|
|
|
|
|
@ -56,10 +57,11 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
|
|
|
|
// hack method to ensure that addRoutes is complete
|
|
|
|
|
// set the replace: true, so the navigation will not leave a history record
|
|
|
|
|
next({
|
|
|
|
|
...to,
|
|
|
|
|
replace: true
|
|
|
|
|
})
|
|
|
|
|
let resetTo = deepCopy(to)
|
|
|
|
|
resetTo.path = to.query.tourl || to.path
|
|
|
|
|
resetTo.replace = true
|
|
|
|
|
console.log(resetTo)
|
|
|
|
|
next(resetTo)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
// remove token and go to login page to re-login
|
|
|
|
|
@ -83,10 +85,15 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
try {
|
|
|
|
|
await store.dispatch('user/loginskip', {
|
|
|
|
|
token: to.query.token,
|
|
|
|
|
tp: to.query.tp
|
|
|
|
|
tp: to.query.tp,
|
|
|
|
|
loginId: to.query.loginId
|
|
|
|
|
})
|
|
|
|
|
console.log("to.path",to.path)
|
|
|
|
|
next(to.path || '/')
|
|
|
|
|
console.log("to.path",to.path)
|
|
|
|
|
if(to.query.tourl){
|
|
|
|
|
next(to.query.tourl || '/')
|
|
|
|
|
}else{
|
|
|
|
|
next(to.path || '/')
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("/login",e)
|
|
|
|
|
next('/login')
|
|
|
|
|
|