163 lines
4.6 KiB
TypeScript
163 lines
4.6 KiB
TypeScript
import type { RouteRecordRaw } from 'vue-router';
|
|
import type { MenuItemType } from 'ele-admin-pro/es';
|
|
import { menuToRoutes, eachTreeData } from 'ele-admin-pro/es';
|
|
import { HOME_PATH, LAYOUT_PATH, REDIRECT_PATH } from '@/config/setting';
|
|
import EleLayout from '@/layout/index.vue';
|
|
import RedirectLayout from '@/components/RedirectLayout';
|
|
const modules = import.meta.glob('/src/views/**/index.vue');
|
|
|
|
/**
|
|
* 静态路由
|
|
*/
|
|
export const routes = [
|
|
{
|
|
path: '/login',
|
|
component: () => import('@/views/passport/login/index.vue'),
|
|
meta: { title: '登录' }
|
|
},
|
|
{
|
|
path: '/home',
|
|
component: () => import('@/views/index/index.vue'),
|
|
meta: { title: '首页' }
|
|
},
|
|
{
|
|
path: '/index',
|
|
component: () => import('@/views/welcome/index.vue'),
|
|
meta: { title: '欢迎页' }
|
|
},
|
|
{
|
|
path: '/ai',
|
|
component: () => import('@/views/oa/chatgpt/index.vue'),
|
|
meta: { title: 'AI' }
|
|
},
|
|
{
|
|
path: '/forget',
|
|
component: () => import('@/views/passport/forget/index.vue'),
|
|
meta: { title: '忘记密码' }
|
|
},
|
|
{
|
|
path: '/wx-work-login',
|
|
component: () => import('@/views/passport/wx-work/index.vue'),
|
|
meta: { title: '企业微信登录' }
|
|
},
|
|
{
|
|
path: '/common',
|
|
component: EleLayout,
|
|
children: [
|
|
{
|
|
path: '/common/iframe',
|
|
component: () => import('@/views/iframe/index.vue'),
|
|
meta: { title: 'iframe', tabUnique: false }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/gxmu',
|
|
component: EleLayout,
|
|
children: [
|
|
{
|
|
path: '/gxmu/project-topic-semantic-search',
|
|
component: () =>
|
|
import('@/views/gxmu/projectTopicSemanticSearch/index.vue'),
|
|
meta: { title: '项目主题语义检索', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/cross-school-activity-board',
|
|
component: () =>
|
|
import('@/views/gxmu/crossSchoolActivityBoard/index.vue'),
|
|
meta: { title: '跨校活动情报看板', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/tzb-project-list',
|
|
component: () =>
|
|
import('@/views/gxmu/tzbProjectList/index.vue'),
|
|
meta: { title: '挑战杯项目库', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/tzb-talent-list',
|
|
component: () =>
|
|
import('@/views/gxmu/tzbTalentList/index.vue'),
|
|
meta: { title: '挑战杯人才库', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/competition-history-files',
|
|
component: () =>
|
|
import('@/views/gxmu/competitionHistoryFiles/index.vue'),
|
|
meta: { title: '历史竞赛文件维护', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/league-committee-ledger',
|
|
component: () =>
|
|
import('@/views/gxmu/LeagueCommitteeLedger/index.vue'),
|
|
meta: { title: '基层团委工作台账', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/league-branch-ledger',
|
|
component: () =>
|
|
import('@/views/gxmu/LeagueBranchLedger/index.vue'),
|
|
meta: { title: '基层团支部工作台帐', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/college-management',
|
|
component: () => import('@/views/gxmu/collegeManagement/index.vue'),
|
|
meta: { title: '学院管理', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/class-management',
|
|
component: () => import('@/views/gxmu/classManagement/index.vue'),
|
|
meta: { title: '班级管理', tabUnique: false }
|
|
},
|
|
{
|
|
path: '/gxmu/declareHistory',
|
|
component: () => import('@/views/gxmu/declareHistory/index.vue'),
|
|
meta: { title: '我的申报历史', tabUnique: false }
|
|
}
|
|
]
|
|
},
|
|
// 404
|
|
{
|
|
path: '/:path(.*)*',
|
|
component: () => import('@/views/exception/404/index.vue')
|
|
}
|
|
];
|
|
|
|
/**
|
|
* 动态路由
|
|
* @param menus 菜单数据
|
|
* @param homePath 主页地址
|
|
*/
|
|
export function getMenuRoutes(menus?: MenuItemType[], homePath?: string) {
|
|
const routes: RouteRecordRaw[] = [
|
|
// 用于刷新的路由
|
|
{
|
|
path: REDIRECT_PATH + '/:path(.*)',
|
|
component: RedirectLayout,
|
|
meta: { hideFooter: true }
|
|
}
|
|
];
|
|
// 路由铺平处理
|
|
eachTreeData(menuToRoutes(menus, getComponent), (route) => {
|
|
routes.push(Object.assign({}, route, { children: void 0 }));
|
|
});
|
|
return {
|
|
path: LAYOUT_PATH,
|
|
component: EleLayout,
|
|
redirect: HOME_PATH ?? homePath,
|
|
children: routes
|
|
};
|
|
}
|
|
|
|
/**
|
|
* 解析路由组件
|
|
* @param component 组件名称
|
|
*/
|
|
function getComponent(component?: string) {
|
|
if (component) {
|
|
const module = modules[`/src/views/${component}.vue`];
|
|
if (!module) {
|
|
return modules[`/src/views/${component}/index.vue`];
|
|
}
|
|
return module;
|
|
}
|
|
}
|