| 1234567891011121314151617181920212223242526272829303132333435 |
- 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: [
- ]
- },
- routePathTransformer(_, routePath) {
- 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}`
- };
- if (constantRoutes.includes(key)) {
- meta.constant = true;
- }
- return meta;
- }
- });
- }
|