From 7e7626ff798d43d9c5cfbfc8e75acf124737c555 Mon Sep 17 00:00:00 2001 From: wang <1509326266@qq.com> Date: Sun, 25 Aug 2024 14:08:29 +0800 Subject: [PATCH] feat(projects): the attribute of the jump path is changed from redirectTo to redirect --- src/route-core/transform.ts | 12 ++++++------ src/types/index.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/route-core/transform.ts b/src/route-core/transform.ts index 7a07b20..f3c6aba 100644 --- a/src/route-core/transform.ts +++ b/src/route-core/transform.ts @@ -34,7 +34,7 @@ import type { LazyRouteFunction, RouteObject,IndexRouteObject } from "react-rout import type { FunctionComponent } from "react"; import type { ElegantConstRoute } from '@ohh-889/react-auto-route'; import type { RouteMap, RouteKey, RoutePath } from '@elegant-router/types'; -import { redirect } from 'react-router-dom' +import { redirect as redirectTo } from 'react-router-dom' import ErrorBoundary from "${options.errorBoundaryPath||'../../../ErrorBoundary.tsx'}" @@ -119,7 +119,7 @@ export function transformElegantRouteToReactRoute( } - const { name,props, path,meta, component, children,redirectTo,layout,loader, ...rest } = route; + const { name,props, path,meta, component, children,redirect,layout,loader, ...rest } = route; const reactRoute = {id:name, path,handle: { ...meta @@ -197,15 +197,15 @@ export function transformElegantRouteToReactRoute( if (children?.length) { reactRoute.children = children.flatMap(child => transformElegantRouteToReactRoute(child, layouts, views)); - const defaultRedirectPath = redirectTo || getRedirectPath(path as string, children[0].path as string); + const defaultRedirectPath = redirect || getRedirectPath(path as string, children[0].path as string); reactRoute.children.unshift({ index: true, - loader: () => redirect(defaultRedirectPath), + loader: () => redirectTo(defaultRedirectPath), ...rest }); - }else if (redirectTo) { - reactRoute.loader=()=>redirect(redirectTo) + }else if (redirect) { + reactRoute.loader=()=>redirectTo(redirect) } if (loader) { diff --git a/src/types/index.ts b/src/types/index.ts index 17ebf78..40b28e7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -139,7 +139,7 @@ export type ElegantConstRoute = Omit & meta?: RouteMeta; props?: Record; layout?: string; - redirectTo?: string; + redirect?: string; children?: ElegantConstRoute[]; };