fanzhen1219
This commit is contained in:
@@ -30,7 +30,7 @@ import cs from '@/views/cs.vue'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
export default new Router({
|
||||
let RouterObj = new Router({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes: [{
|
||||
@@ -105,3 +105,23 @@ export default new Router({
|
||||
}
|
||||
]
|
||||
})
|
||||
RouterObj.beforeEach((to, from, next) => {
|
||||
console.log(to, 'to')
|
||||
if (to.name === 'personalCenter' || to.name === 'datasweb') {
|
||||
console.log(localStorage.getItem('token'), 'localStorage.getItem()')
|
||||
if (!localStorage.getItem('token')) {
|
||||
alert('您没有该账号的登陆权限,请重新登录后再次操作!')
|
||||
// 权限通过时赋值
|
||||
console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
|
||||
Vue.prototype.$auth.auth = true
|
||||
console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
|
||||
// localStorage.clear()
|
||||
// window.location.reload()
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
export default RouterObj
|
||||
|
||||
Reference in New Issue
Block a user