Skip to content

Commit

Permalink
fix(projects): fix add redirect to child
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Nov 5, 2023
1 parent 59c4348 commit 7ad5625
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions examples/template-vue/src/router/elegant/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function transformElegantRouteToVueRoute(
return [singleLevelRoute];
}



if (isLayout(component)) {
const layoutName = getLayoutName(component);

Expand All @@ -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
};
Expand Down
4 changes: 1 addition & 3 deletions examples/template-vue/src/router/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const customRoutes: CustomRoute[] = [
{
name: 'root',
path: '/',
redirect: {
name: '403'
}
redirect: '/403'
},
{
name: 'not-found',
Expand Down
6 changes: 2 additions & 4 deletions packages/vue/src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ function transformElegantRouteToVueRoute(
return [singleLevelRoute];
}
if (isLayout(component)) {
const layoutName = getLayoutName(component);
Expand All @@ -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
};
Expand Down

0 comments on commit 7ad5625

Please sign in to comment.