Skip to content

Commit

Permalink
Merge pull request #27 from Azir-11/main
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc authored Jul 12, 2024
2 parents 7fd59b4 + d7fba4b commit a13fb16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/vue/src/core/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ declare module "@elegant-router/types" {
/**
* custom route key
*/
*/
export type CustomRouteKey = Extract<
RouteKey,`;

Expand All @@ -96,7 +96,7 @@ declare module "@elegant-router/types" {
/**
* the generated route key
*/
*/
export type GeneratedRouteKey = Exclude<RouteKey, CustomRouteKey>;
/**
Expand Down
17 changes: 8 additions & 9 deletions packages/vue/src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function transformElegantRouteToVueRoute(
if (component) {
if (isSingleLevelRoute(route)) {
const { layout, view } = getSingleLevelRouteComponent(component);
const singleLevelRoute: RouteRecordRaw = {
path,
component: layouts[layout],
Expand All @@ -137,36 +137,35 @@ function transformElegantRouteToVueRoute(
} as RouteRecordRaw
]
};
return [singleLevelRoute];
}
if (isLayout(component)) {
const layoutName = getLayoutName(component);
vueRoute.component = layouts[layoutName];
}
if (isView(component)) {
const viewName = getViewName(component);
vueRoute.component = views[viewName];
}
}
} catch (error: any) {
console.error(\`Error transforming route "\${route.name}": \${error.toString()}\`);
return [];
}
// add redirect to child
if (children?.length && !vueRoute.redirect) {
vueRoute.redirect = {
name: children[0].name
};
}
if (children?.length) {
const childRoutes = children.flatMap(child => transformElegantRouteToVueRoute(child, layouts, views));
Expand Down

0 comments on commit a13fb16

Please sign in to comment.