This commit is contained in:
lnn19986213 2024-05-08 11:08:00 +08:00
parent b51e366577
commit 4ba40cf547
1 changed files with 45 additions and 6 deletions

View File

@ -14,32 +14,32 @@ const router = createRouter({
component: () => import('../view/home.vue'), component: () => import('../view/home.vue'),
children: [ children: [
{ {
name:'首页', name: '首页',
path: '/home/index', path: '/home/index',
component: () => import('../view/sy.vue'), component: () => import('../view/sy.vue'),
}, },
{ {
name:'养老', name: '养老',
path: '/home/yl', path: '/home/yl',
component: () => import('../view/yl.vue'), component: () => import('../view/yl.vue'),
}, },
{ {
name:'卫生', name: '卫生',
path: '/home/hygiene', path: '/home/hygiene',
component: () => import('../view/hygiene.vue'), component: () => import('../view/hygiene.vue'),
}, },
{ {
name:'教育', name: '教育',
path: '/home/education', path: '/home/education',
component: () => import('../view/education.vue'), component: () => import('../view/education.vue'),
}, },
{ {
name:'就业补助', name: '就业补助',
path: '/home/work', path: '/home/work',
component: () => import('../view/work.vue'), component: () => import('../view/work.vue'),
}, },
{ {
name:'智能分析', name: '智能分析',
path: '/home/analyze', path: '/home/analyze',
component: () => import('../view/analyze.vue'), component: () => import('../view/analyze.vue'),
}, },
@ -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 export default router