广丰卷烟厂数采质量分析系统
zhuguifei
2026-03-02 80ff784bf60637cd348ae665fc907f7b1e527dd8
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
import type { RouteMeta } from 'vue-router';
import ElegantVueRouter from '@elegant-router/vue/vite';
import type { RouteKey } from '@elegant-router/types';
 
export function setupElegantRouter() {
  return ElegantVueRouter({
    layouts: {
      base: 'src/layouts/base-layout/index.vue',
      blank: 'src/layouts/blank-layout/index.vue'
    },
    customRoutes: {
      names: ['exception_403', 'exception_404', 'exception_500']
    },
    routePathTransformer(routeName, routePath) {
      const key = routeName as RouteKey;
 
      if (key === 'login') {
        const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];
 
        const moduleReg = modules.join('|');
 
        return `/login/:module(${moduleReg})?`;
      }
 
      return routePath;
    },
    onRouteMetaGen(routeName) {
      const key = routeName as RouteKey;
 
      const constantRoutes: RouteKey[] = ['login', '403', '404', '500'];
 
      const meta: Partial<RouteMeta> = {
        title: key,
        i18nKey: `route.${key}` as App.I18n.I18nKey
      };
 
      if (constantRoutes.includes(key)) {
        meta.constant = true;
      }
 
      return meta;
    }
  });
}