This commit is contained in:
X1627315083
2024-03-05 10:33:29 +08:00
parent a459d2abb3
commit ec0b488004
3 changed files with 604 additions and 16 deletions

View File

@@ -36,6 +36,11 @@ const routes: Array<RouteRecordRaw> = [
name: 'history',
component: _import('HistoryPage')
},
{
path: '/testClickData',
name: 'testClickData',
component: _import('TestClickData')
},
// {//老版本history
// path: '/oldHistory',
// name: 'oldHistory',
@@ -83,11 +88,16 @@ router.beforeEach((to, from, next) => {
// }
// 检查路由是否存在
// 机房用户
let userInfo = JSON.parse(getCookie("userInfo") as any);
console.log(userInfo);
let murmurStr: any = localStorage.getItem('murmurStr')
let getIsMurmur: any = getCookie("isMurmur")
let token = getCookie("token");
let isMurmur = JSON.parse(getIsMurmur)
let routeList = ['/testClickData']
let userIdList = [83]
const routeExists = router.getRoutes().some(({ name }) =>{
if(name){
return name === to.name
@@ -95,22 +105,33 @@ router.beforeEach((to, from, next) => {
return false
}
});
if (routeExists) {
if (isMurmur && murmurStr && token) {
const toName = to.name === 'login';
if (toName) {
next({ name: 'home' });
} else {
next();
}
} else {
// 如果页面存在,正常跳转
next();
}
} else {
// 如果页面不存在可以跳转到404页面或者其他页面
next('/404');
}
// if (routeExists) {
// if (isMurmur && murmurStr && token) {
// const toName = to.name === 'login';
// if (toName) {
// next({ name: 'home' });
// } else {
// next();
// }
// } else {
// if (routeList.indexOf(to.path) > -1 ) {
// if(userIdList.indexOf(userInfo.userId) > -1){
// next();
// }else{
// next({ name: 'home' });
// }
// }else{
// next();
// }
// // 如果页面存在,正常跳转
// }
// } else {
// // 如果页面不存在可以跳转到404页面或者其他页面
// next('/404');
// }
});