From 7ad5625f2f434535a92cf367a84a967a0b38931d Mon Sep 17 00:00:00 2001 From: Soybean Date: Sun, 5 Nov 2023 20:51:02 +0800 Subject: [PATCH] fix(projects): fix add redirect to child --- examples/template-vue/src/router/elegant/transform.ts | 6 ++---- examples/template-vue/src/router/routes/index.ts | 4 +--- packages/vue/src/core/transform.ts | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/template-vue/src/router/elegant/transform.ts b/examples/template-vue/src/router/elegant/transform.ts index e6de701..8c5a8d1 100644 --- a/examples/template-vue/src/router/elegant/transform.ts +++ b/examples/template-vue/src/router/elegant/transform.ts @@ -95,8 +95,6 @@ function transformElegantRouteToVueRoute( return [singleLevelRoute]; } - - if (isLayout(component)) { const layoutName = getLayoutName(component); @@ -111,8 +109,8 @@ function transformElegantRouteToVueRoute( } - // center level layout add redirect to child - if (!component && children?.length) { + // add redirect to child + if (children?.length) { vueRoute.redirect = { name: children[0].name }; diff --git a/examples/template-vue/src/router/routes/index.ts b/examples/template-vue/src/router/routes/index.ts index 8e3c28c..053a3d5 100644 --- a/examples/template-vue/src/router/routes/index.ts +++ b/examples/template-vue/src/router/routes/index.ts @@ -7,9 +7,7 @@ const customRoutes: CustomRoute[] = [ { name: 'root', path: '/', - redirect: { - name: '403' - } + redirect: '/403' }, { name: 'not-found', diff --git a/packages/vue/src/core/transform.ts b/packages/vue/src/core/transform.ts index b5cba84..3eb8ab5 100644 --- a/packages/vue/src/core/transform.ts +++ b/packages/vue/src/core/transform.ts @@ -115,8 +115,6 @@ function transformElegantRouteToVueRoute( return [singleLevelRoute]; } - - if (isLayout(component)) { const layoutName = getLayoutName(component); @@ -131,8 +129,8 @@ function transformElegantRouteToVueRoute( } - // center level layout add redirect to child - if (!component && children?.length) { + // add redirect to child + if (children?.length) { vueRoute.redirect = { name: children[0].name };