This commit is contained in:
X1627315083
2024-01-15 17:05:55 +08:00
parent 2fca178eeb
commit bf9556378c
11 changed files with 182 additions and 50 deletions

View File

@@ -1,5 +1,7 @@
import { createRouter, createWebHistory, RouteRecordRaw, createWebHashHistory } from 'vue-router'
import { defineAsyncComponent } from 'vue'
import {getBrowserInfo,murmur} from '@/tool/util'
import { getCookie,setCookie } from "@/tool/cookie";
const _import = (path: string) => defineAsyncComponent(() => import(`../views/${path}.vue`));
const routes: Array<RouteRecordRaw> = [
@@ -9,6 +11,12 @@ const routes: Array<RouteRecordRaw> = [
redirect: "/login"
// redirect: "/Upgrade"
},
{
path: "/",
// redirect重定向
redirect: "/home"
// redirect: "/Upgrade"
},
{
path: '/login',
name: 'login',
@@ -56,12 +64,52 @@ const router = createRouter({
// history: createWebHashHistory(),
routes
})
// router.beforeEach((to, from, next) => {
// const toName = to.name === 'upgrade';
// if (toName) {
// next();
// } else {
// next({ name: 'upgrade' });
// }
// });
router.beforeEach((to, from, next) => {
// // 获取路由配置对象
// const route = router.resolve({ path: '/' }).route
// // 修改重定向
// route.redirect = '/new-path'
// router.addRoute(route)
// next();
// let token = getCookie("token");
// console.log(to,from);
// if(from.path == '/' && !token){
// console.log(111);
// murmur().then((rv)=>{
// console.log(rv);
// if(rv){
// console.log(123123);
// next({ name: 'history' });
// }
// })
// }else{
// console.log(333);
// next()
// }
//系统维护
// const toName = to.name === 'upgrade';
// if (toName) {
// next();
// } else {
// next({ name: 'upgrade' });
// }
//机房用户
let murmurStr:any = localStorage.getItem('murmurStr')
let getIsMurmur:any = getCookie("isMurmur")
let isMurmur = JSON.parse(getIsMurmur)
if(isMurmur&& murmurStr){
const toName = to.name === 'login';
if (toName) {
next({ name: 'home' });
} else {
next();
}
}else{
next();
}
});
export default router