This commit is contained in:
parent
b51e366577
commit
4ba40cf547
|
@ -48,4 +48,43 @@ const router = createRouter({
|
|||
]
|
||||
})
|
||||
|
||||
function getCookie(cname) {
|
||||
var name = cname + '='
|
||||
var ca = document.cookie.split(';')
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i].trim()
|
||||
if (c.indexOf(name) == 0)
|
||||
return c.substring(name.length, c.length)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
router.beforeEach((to, form, next) => {
|
||||
var token = getCookie('lytoken')
|
||||
if (token == '') {
|
||||
window.location.href =
|
||||
'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
window.location.href
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/api/zzdn_event/auditToken?token=' + token,
|
||||
type: 'GET',
|
||||
async: true,
|
||||
success: function (res) {
|
||||
if (res.code == '500') {
|
||||
window.location.href =
|
||||
'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
window.location.href
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
$.ajaxSetup({
|
||||
beforeSend: function (xhr) {
|
||||
token && xhr.setRequestHeader('x-token', token)
|
||||
return true
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
Loading…
Reference in New Issue