Skip to content

Commit

Permalink
feat(projects): the attribute of the jump path is changed from redire…
Browse files Browse the repository at this point in the history
…ctTo to redirect
  • Loading branch information
mufeng889 committed Aug 25, 2024
1 parent 90dc1fc commit 7e7626f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/route-core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export type ElegantConstRoute = Omit<RouteObject, 'id' | 'path' | 'children'> &
meta?: RouteMeta;
props?: Record<string, unknown>;
layout?: string;
redirectTo?: string;
redirect?: string;
children?: ElegantConstRoute[];
};

Expand Down

0 comments on commit 7e7626f

Please sign in to comment.