Blame view

src/router/routes/index.ts 1.26 KB
陈文彬 authored
1
2
import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types';
3
import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic';
vben authored
4
vben authored
5
import { mainOutRoutes } from './mainOut';
vben authored
6
import { PageEnum } from '/@/enums/pageEnum';
7
8
import { t } from '/@/hooks/web/useI18n';
9
// import.meta.globEager() 直接引入所有的模块 Vite 独有的功能
10
const modules = import.meta.globEager('./modules/**/*.ts');
vben authored
11
const routeModuleList: AppRouteModule[] = [];
陈文彬 authored
12
13
// 加入到路由集合中
vben authored
14
Object.keys(modules).forEach((key) => {
vben authored
15
16
17
  const mod = modules[key].default || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
vben authored
18
19
});
vben authored
20
export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
vben authored
21
22
// 根路由
vben authored
23
24
25
26
27
28
29
30
31
export const RootRoute: AppRouteRecordRaw = {
  path: '/',
  name: 'Root',
  redirect: PageEnum.BASE_HOME,
  meta: {
    title: 'Root',
  },
};
vben authored
32
33
34
35
36
export const LoginRoute: AppRouteRecordRaw = {
  path: '/login',
  name: 'Login',
  component: () => import('/@/views/sys/login/Login.vue'),
  meta: {
37
    title: t('routes.basic.login'),
vben authored
38
39
40
  },
};
41
// Basic routing without permission
Jim authored
42
// 未经许可的基本路由
43
44
45
46
47
48
49
export const basicRoutes = [
  LoginRoute,
  RootRoute,
  ...mainOutRoutes,
  REDIRECT_ROUTE,
  PAGE_NOT_FOUND_ROUTE,
];