Sanakey
5 天以前 2af71bcf522c485ea005184c977986374a7dcc4a
提交 | 用户 | age
4d2fb0 1 import type { AppRouteRecordRaw, AppRouteModule } from '@/router/types';
2f6253 2
4d2fb0 3 import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '@/router/routes/basic';
00fe0e 4 import { useEmailRouterStoreWithout } from '@/store/modules/emailRouter';
c303ec 5
930383 6 import { mainOutRoutes } from './mainOut';
4d2fb0 7 import { PageEnum } from '@/enums/pageEnum';
X 8 import { t } from '@/hooks/web/useI18n';
99ac30 9
1262e1 10 // import.meta.glob() 直接引入所有的模块 Vite 独有的功能
X 11 const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
00fe0e 12
e23336 13 const routeModuleList: AppRouteModule[] = [];
2f6253 14
19dc88 15 // 加入到路由集合中
8a1bfd 16 Object.keys(modules).forEach((key) => {
1262e1 17   const mod = (modules as Recordable)[key].default || {};
99ac30 18   const modList = Array.isArray(mod) ? [...mod] : [mod];
V 19   routeModuleList.push(...modList);
00fe0e 20   if (mod.name === 'Email'){
H 21     const emailRouter = useEmailRouterStoreWithout();
22     emailRouter.setEmailRouters(mod.children)
23   }
8a1bfd 24 });
e12c58 25
c303ec 26 export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
e23336 27
19dc88 28 // 根路由
dddda5 29 export const RootRoute: AppRouteRecordRaw = {
V 30   path: '/',
31   name: 'Root',
32   redirect: PageEnum.BASE_HOME,
33   meta: {
34     title: 'Root',
35   },
36 };
37
31e271 38 export const LoginRoute: AppRouteRecordRaw = {
V 39   path: '/login',
40   name: 'Login',
4d2fb0 41   component: () => import('@/views/sys/login/Login.vue'),
31e271 42   meta: {
a0b05e 43     title: t('routes.basic.login'),
31e271 44   },
V 45 };
46
bba776 47 // Basic routing without permission
cfbd52 48 // 未经许可的基本路由
237e65 49 export const basicRoutes = [
50   LoginRoute,
51   RootRoute,
52   ...mainOutRoutes,
53   REDIRECT_ROUTE,
54   PAGE_NOT_FOUND_ROUTE,
55 ];