68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router';
|
|
import { CommonStore } from '@/stores/common';
|
|
import EmptyLayout from '@/layouts/empty.vue';
|
|
import DefaultLayout from '@/layouts/default.vue';
|
|
import CidLayout from '@/layouts/cid.vue';
|
|
// import { routerData } from '@/router/router';
|
|
import { routerData } from '@/tenants/lyric/router';
|
|
import eontecRouter from '@/tenants/yian/router';
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
path: '/login',
|
|
component: EmptyLayout,
|
|
children: [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
// component: () => import('@/views/login/index.vue'),
|
|
component: () => import('@/views/error/developing.vue'),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: '/onlyOffice',
|
|
name: 'OnlyOffice',
|
|
component: () => import('@/views/index/onlyOffice.vue'),
|
|
},
|
|
{
|
|
path: '/',
|
|
component: window?.__POWERED_BY_WUJIE__ ? CidLayout : DefaultLayout,
|
|
children: routerData,
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
component: EmptyLayout,
|
|
children: [
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
name: '404',
|
|
component: () => import('@/views/error/404.vue'),
|
|
},
|
|
],
|
|
},
|
|
...eontecRouter,
|
|
],
|
|
});
|
|
|
|
const eachFun = (to: any, data: any) => {
|
|
return data.some((menu: any) => {
|
|
if (menu.path === to.path) {
|
|
menu.query = to.query;
|
|
CommonStore().addAlivePage(menu);
|
|
return true;
|
|
}
|
|
if (menu.children && menu.children.length > 0) {
|
|
return eachFun(to, menu.children);
|
|
}
|
|
});
|
|
};
|
|
|
|
router.afterEach((to) => {
|
|
eachFun(to, routerData);
|
|
});
|
|
|
|
export default router;
|