2
0

perf: 路由重构

This commit is contained in:
TsMask
2024-11-29 16:51:14 +08:00
parent 5d2b71bb37
commit d7d471e552
13 changed files with 100 additions and 369 deletions

View File

@@ -1,6 +1,6 @@
import type { CustomRoute, ElegantConstRoute, ElegantRoute } from '@elegant-router/types';
import type { ElegantConstRoute } from '@elegant-router/types';
import { generatedRoutes } from '../elegant/routes';
import { layouts, views } from '../elegant/imports';
import { layouts } from '../elegant/imports';
import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
/**
@@ -8,7 +8,7 @@ import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
*
* @link https://github.com/soybeanjs/elegant-router?tab=readme-ov-file#custom-route
*/
const customRoutes: CustomRoute[] = [
const customRoutes: any[] = [
{
name: 'exception',
path: '/exception',
@@ -23,7 +23,7 @@ const customRoutes: CustomRoute[] = [
{
name: 'exception_403',
path: '/exception/403',
component: 'view.403',
component: 'view._builtin_403',
meta: {
title: 'exception_403',
i18nKey: 'route.exception_403',
@@ -33,7 +33,7 @@ const customRoutes: CustomRoute[] = [
{
name: 'exception_404',
path: '/exception/404',
component: 'view.404',
component: 'view._builtin_404',
meta: {
title: 'exception_404',
i18nKey: 'route.exception_404',
@@ -43,7 +43,7 @@ const customRoutes: CustomRoute[] = [
{
name: 'exception_500',
path: '/exception/500',
component: 'view.500',
component: 'view._builtin_500',
meta: {
title: 'exception_500',
i18nKey: 'route.exception_500',
@@ -56,9 +56,9 @@ const customRoutes: CustomRoute[] = [
/** create routes when the auth route mode is static */
export function createStaticRoutes() {
const constantRoutes: ElegantRoute[] = [];
const constantRoutes: any[] = [];
const authRoutes: ElegantRoute[] = [];
const authRoutes: any[] = [];
[...customRoutes, ...generatedRoutes].forEach(item => {
if (item.meta?.constant) {
@@ -80,5 +80,5 @@ export function createStaticRoutes() {
* @param routes Elegant routes
*/
export function getAuthVueRoutes(routes: ElegantConstRoute[]) {
return transformElegantRoutesToVueRoutes(routes, layouts, views);
return transformElegantRoutesToVueRoutes(routes, layouts);
}