index.js
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
{
path: '/',
name: 'Dashboard',
component: () => import('@/views/Dashboard.vue')
},
{
path: '/login',
name: 'LoginPage',
component: () => import (
'../views/Login.vue'
)
},
{
path: "/404",
name: "notFound",
component: () => import('@/views/notFound.vue')
},
// {
// path: '/:pathMatch(.*)*',
// redirect: '/404'
// }
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
const childRoute = ['/system'];
const isChildRoute = path => childRoute.some(item => path.startsWith(item));
// const rawAppendChild = HTMLHeadElement.prototype.appendChild;
// const rawAddEventListener = window.addEventListener;
router.beforeEach((to, from, next) => {
console.log(from)
// if (to.meta.title) {
// document.title = to.meta.title;
// }
// next();
// 从子项目跳转到主项目
// if(isChildRoute(from.path) && !isChildRoute(to.path)){
// HTMLHeadElement.prototype.appendChild = rawAppendChild;
// window.addEventListener = rawAddEventListener;
// }
//next();
});
export default router