Skip to content

Commit

Permalink
chore(deps): update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Oct 23, 2023
1 parent a77843c commit 56931a2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"vue-router": "4.2.5"
},
"devDependencies": {
"@elegant-router/vue": "0.2.3",
"@elegant-router/vue": "0.2.5",
"@iconify-json/heroicons": "1.1.13",
"@iconify-json/ic": "1.1.14",
"@iconify-json/icon-park-outline": "1.1.12",
Expand All @@ -50,11 +50,11 @@
"@types/lodash-es": "4.17.10",
"@types/node": "20.8.7",
"@types/nprogress": "0.2.2",
"@unocss/preset-icons": "0.56.5",
"@unocss/preset-uno": "0.56.5",
"@unocss/transformer-directives": "0.56.5",
"@unocss/transformer-variant-group": "0.56.5",
"@unocss/vite": "0.56.5",
"@unocss/preset-icons": "0.57.0",
"@unocss/preset-uno": "0.57.0",
"@unocss/transformer-directives": "0.57.0",
"@unocss/transformer-variant-group": "0.57.0",
"@unocss/vite": "0.57.0",
"@vitejs/plugin-vue": "4.4.0",
"@vitejs/plugin-vue-jsx": "3.0.2",
"cross-env": "7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"serve": "vitepress serve"
},
"devDependencies": {
"vitepress": "1.0.0-rc.22"
"vitepress": "1.0.0-rc.23"
}
}
50 changes: 50 additions & 0 deletions src/router/elegant/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,53 @@ function isView(component: string) {
function getViewName(component: string) {
return component.replace(VIEW_PREFIX, '');
}

/**
* transform elegant route to tree route
* @param routes elegant routes
*/
export function transformElegantRouteToTreeRoute(routes: AutoRoute[]) {
const treeRoutes = routes.map(route => {
const { children = [], ...rest } = route;

const treeRoute: AutoRoute = { ...rest, children: [] };

const treeMap = new Map<string, AutoRoute>();

children.forEach(child => {
treeMap.set(child.name as string, { ...child });
});

const treeChildren: AutoRoute[] = [];

children.forEach(child => {
// current route level is 2, if has parent, then level is 3 or more
const hasParent = (child.name as string).split('_').length > 2;

const current = treeMap.get(child.name as string)!;

if (hasParent) {
const parentName = (child.name as string).split('_').slice(0, -1).join('_');

const parent = treeMap.get(parentName);

if (parent) {
if (!parent.children) {
parent.children = [];
}
parent.children.push(current);
}
} else {
treeChildren.push(current);
}
});

if (treeChildren.length) {
treeRoute.children = treeChildren;
}

return treeRoute;
});

return treeRoutes;
}
2 changes: 1 addition & 1 deletion uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export default defineConfig<Theme>({
}
},
transformers: [transformerDirectives(), transformerVariantGroup()],
presets: [presetUno({ dark: 'class' }), presetScrollbar(), presetSoybeanAdmin()]
presets: [presetUno({ dark: 'class' }), presetScrollbar() as any, presetSoybeanAdmin()]
});

0 comments on commit 56931a2

Please sign in to comment.