diff --git a/src/router/index.js b/src/router/index.js index 931554e..2b69a7d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -52,9 +52,9 @@ const router = createRouter({ function getCookie(cname) { var cn = cname - console.log('cname',cname) + console.log('cname', cname) const cookies = document.cookie.split('; '); - console.log('cookies',cookies) + console.log('cookies', cookies) for (let i = 0; i < cookies.length; i++) { const [name, value] = cookies[i].split('='); if (name === cn) { @@ -71,27 +71,27 @@ function getCookie(cname) { // return '' } -// router.beforeEach((to, form, next) => { -// var token = getCookie('lytoken') -// console.log('token',token) -// if (token == '') { -// window.location.href = -// 'http://220.191.238.50:996/api/login?returnURL=' + -// window.location.href -// } else { -// // http.get("/api/zzdn_event/auditToken?token=" + token).then((res) => { -// // if (res.code == '500') { -// // window.location.href = -// // 'http://220.191.238.50:996/api/login?returnURL=' + -// // window.location.href -// // } else { -// // tools.data.set('token',token) -// // next(); -// // } -// // }); -// tools.data.set('token',token) -// next(); -// } -// }) +router.beforeEach((to, form, next) => { + var token = getCookie('lytoken') + console.log('token', token) + if (token == '') { + window.location.href = + 'http://220.191.238.50:996/api/login?returnURL=' + + window.location.href + } else { + // http.get("/api/zzdn_event/auditToken?token=" + token).then((res) => { + // if (res.code == '500') { + // window.location.href = + // 'http://220.191.238.50:996/api/login?returnURL=' + + // window.location.href + // } else { + // tools.data.set('token',token) + // next(); + // } + // }); + tools.data.set('token', token) + next(); + } +}) export default router \ No newline at end of file