Skip to content

Commit

Permalink
chore(projects): update deps & fix vue-router meta type
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jul 31, 2024
1 parent a13fb16 commit 43eed04
Show file tree
Hide file tree
Showing 12 changed files with 2,087 additions and 3,251 deletions.
24 changes: 12 additions & 12 deletions examples/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
},
"dependencies": {
"@elegant-router/vue": "workspace:*",
"pinia": "2.1.7",
"vue": "3.4.27",
"vue-router": "4.3.2"
"pinia": "2.2.0",
"vue": "3.4.35",
"vue-router": "4.4.1"
},
"devDependencies": {
"@soybeanjs/cli": "1.0.14",
"@types/node": "20.12.12",
"@vitejs/plugin-vue": "5.0.4",
"@vitejs/plugin-vue-jsx": "3.1.0",
"eslint": "9.3.0",
"@soybeanjs/cli": "1.1.0",
"@types/node": "22.0.0",
"@vitejs/plugin-vue": "5.1.1",
"@vitejs/plugin-vue-jsx": "4.0.0",
"eslint": "9.8.0",
"eslint-config-soybeanjs": "0.5.9",
"npm-run-all": "4.1.5",
"typescript": "5.4.5",
"vite": "5.2.11",
"vite-plugin-inspect": "0.8.4",
"vue-tsc": "2.0.19"
"typescript": "5.5.4",
"vite": "5.3.5",
"vite-plugin-inspect": "0.8.5",
"vue-tsc": "2.0.29"
}
}
20 changes: 11 additions & 9 deletions examples/template-vue/src/router/elegant/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ function transformElegantRouteToVueRoute(
if (component) {
if (isSingleLevelRoute(route)) {
const { layout, view } = getSingleLevelRouteComponent(component);

const singleLevelRoute: RouteRecordRaw = {
path,
component: layouts[layout],
meta: {
title: route.meta?.title || ''
},
children: [
{
name,
Expand All @@ -110,36 +113,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
4 changes: 2 additions & 2 deletions examples/template-vue/src/typings/elegant-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ declare module "@elegant-router/types" {

/**
* custom route key
*/
*/
export type CustomRouteKey = Extract<
RouteKey,
| "root"
Expand All @@ -62,7 +62,7 @@ declare module "@elegant-router/types" {

/**
* the generated route key
*/
*/
export type GeneratedRouteKey = Exclude<RouteKey, CustomRouteKey>;

/**
Expand Down
66 changes: 66 additions & 0 deletions examples/template-vue/src/typings/router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'vue-router';

declare module 'vue-router' {
interface RouteMeta {
/**
* Title of the route
*
* It can be used in document title
*/
title: string;
/**
* Roles of the route
*
* Route can be accessed if the current user has at least one of the roles
*
* It only works when the route mode is "static", if the route mode is "dynamic", it will be ignored
*/
roles?: string[];
/** Whether to cache the route */
keepAlive?: boolean | null;
/**
* Is constant route
*
* when it is set to true, there will be no login verification and no permission verification to access the route
*/
constant?: boolean | null;
/**
* Iconify icon
*
* It can be used in the menu or breadcrumb
*/
icon?: string;
/**
* Local icon
*
* In "src/assets/svg-icon", if it is set, the icon will be ignored
*/
localIcon?: string;
/** Icon size. width and height are the same. */
iconFontSize?: number;
/** Router order */
order?: number | null;
/** The outer link of the route */
href?: string | null;
/** Whether to hide the route in the menu */
hideInMenu?: boolean | null;
/**
* The menu key will be activated when entering the route
*
* The route is not in the menu
*
* @example
* the route is "user_detail", if it is set to "user_list", the menu "user_list" will be activated
*/
activeMenu?: import('@elegant-router/types').RouteKey | null;
/**
* By default, the same route path will use one tab, even with different query, if set true, the route with
* different query will use different tabs
*/
multiTab?: boolean | null;
/** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */
fixedIndexInTab?: number | null;
/** if set query parameters, it will be automatically carried when entering the route */
query?: { key: string; value: string }[] | null;
}
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"update-pkg": "soy ncu"
},
"devDependencies": {
"@soybeanjs/cli": "1.0.14",
"@soybeanjs/eslint-config": "1.3.5",
"eslint": "9.3.0",
"eslint-plugin-vue": "9.26.0",
"lint-staged": "15.2.2",
"@soybeanjs/cli": "1.1.0",
"@soybeanjs/eslint-config": "1.4.0",
"eslint": "9.8.0",
"eslint-plugin-vue": "9.27.0",
"lint-staged": "15.2.7",
"simple-git-hooks": "2.11.1",
"tsx": "4.10.5",
"typescript": "5.4.5",
"vue-eslint-parser": "9.4.2"
"tsx": "4.16.3",
"typescript": "5.5.4",
"vue-eslint-parser": "9.4.3"
},
"simple-git-hooks": {
"commit-msg": "pnpm soy git-commit-verify",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"consola": "3.2.3",
"fast-glob": "3.3.2",
"kolorist": "1.8.0",
"micromatch": "4.0.5"
"micromatch": "4.0.7"
},
"devDependencies": {
"@types/micromatch": "4.0.7",
"@types/node": "20.12.12",
"typescript": "5.4.5",
"@types/micromatch": "4.0.9",
"@types/node": "22.0.0",
"typescript": "5.5.4",
"unbuild": "2.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"dependencies": {
"consola": "3.2.3",
"magicast": "0.3.4",
"unplugin": "1.10.1"
"unplugin": "1.12.0"
},
"devDependencies": {
"@elegant-router/core": "workspace:*",
"@types/node": "20.12.12",
"typescript": "5.4.5",
"@types/node": "22.0.0",
"typescript": "5.5.4",
"unbuild": "2.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"dependencies": {
"consola": "3.2.3",
"magicast": "0.3.4",
"unplugin": "1.10.1"
"unplugin": "1.12.0"
},
"devDependencies": {
"@elegant-router/core": "workspace:*",
"@types/node": "20.12.12",
"typescript": "5.4.5",
"@types/node": "22.0.0",
"typescript": "5.5.4",
"unbuild": "2.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"dependencies": {
"consola": "3.2.3",
"magicast": "0.3.4",
"unplugin": "1.10.1"
"unplugin": "1.12.0"
},
"devDependencies": {
"@elegant-router/core": "workspace:*",
"@types/node": "20.12.12",
"typescript": "5.4.5",
"@types/node": "22.0.0",
"typescript": "5.5.4",
"unbuild": "2.0.0"
}
}
18 changes: 9 additions & 9 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@
"@elegant-router/core": "workspace:*",
"consola": "3.2.3",
"kolorist": "1.8.0",
"magic-string": "0.30.10",
"magic-string": "0.30.11",
"magicast": "0.3.4",
"prettier": "3.2.5",
"recast": "0.23.7",
"unplugin": "1.10.1"
"prettier": "3.3.3",
"recast": "0.23.9",
"unplugin": "1.12.0"
},
"devDependencies": {
"@types/node": "20.12.12",
"rollup": "4.17.2",
"typescript": "5.4.5",
"@types/node": "22.0.0",
"rollup": "4.19.1",
"typescript": "5.5.4",
"unbuild": "2.0.0",
"vite": "5.2.11",
"vue-router": "4.3.2"
"vite": "5.3.5",
"vue-router": "4.4.1"
}
}
3 changes: 3 additions & 0 deletions packages/vue/src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ function transformElegantRouteToVueRoute(
const singleLevelRoute: RouteRecordRaw = {
path,
component: layouts[layout],
meta: {
title: route.meta?.title || ''
},
children: [
{
name,
Expand Down
Loading

0 comments on commit 43eed04

Please sign in to comment.