From c6d3d9d4eb0e99272b5e13a54084b5afc62aa497 Mon Sep 17 00:00:00 2001 From: wang <1509326266@qq.com> Date: Sun, 8 Sep 2024 20:54:15 +0800 Subject: [PATCH] feat(projects): props are supported just like normal components --- src/route-core/transform.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/route-core/transform.ts b/src/route-core/transform.ts index cc67380..2d4d078 100644 --- a/src/route-core/transform.ts +++ b/src/route-core/transform.ts @@ -133,12 +133,13 @@ export function transformElegantRouteToReactRoute( if (layout) { const singleLevelRoute:RouteObject= { path, - lazy: layouts[layout], ErrorBoundary, + lazy: layouts[layout], children: [ { id:name, index: true, + ErrorBoundary, lazy: views[view], handle: { ...meta @@ -173,11 +174,16 @@ export function transformElegantRouteToReactRoute( if (isView(component)) { const viewName = getViewName(component); if (props) { - reactRoute.lazy = async () => { - const data= (await views[viewName]()).Component as FunctionComponent + reactRoute.lazy = async () => { + const data = await views[viewName]() + reactRoute.ErrorBoundary=data.ErrorBoundary||ErrorBoundary return { - Component: ()=>data(props) , - ErrorBoundary: null + Component: ()=>{ + const Component = data.Component as FunctionComponent + return Component(props) + }, + loader: data.loader, + action: data.action, } } } else { @@ -201,6 +207,7 @@ export function transformElegantRouteToReactRoute( reactRoute.children.unshift({ index: true, + ErrorBoundary, loader: () => redirectTo(defaultRedirectPath), ...rest }); @@ -208,9 +215,7 @@ export function transformElegantRouteToReactRoute( reactRoute.loader=()=>redirectTo(redirect) } - if (loader) { - reactRoute.loader = () => loader - } + if (layout) {