Skip to content

Commit

Permalink
feat(projects): support directory menu hide all child menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Mar 11, 2024
1 parent 6a5aaec commit cd72e7a
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/locales/lang/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ const local: App.I18n.Schema = {
function: 'System Function',
function_tab: 'Tab',
'function_multi-tab': 'Multi Tab',
'function_hide-child': 'Hide Child',
'function_hide-child_one': 'Hide Child',
'function_hide-child_two': 'Two',
'function_hide-child_three': 'Three',
manage: 'System Manage',
manage_user: 'User Manage',
'manage_user-detail': 'User Detail',
Expand Down
4 changes: 4 additions & 0 deletions src/locales/lang/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ const local: App.I18n.Schema = {
function: '系统功能',
function_tab: '标签页',
'function_multi-tab': '多标签页',
'function_hide-child': '隐藏子菜单',
'function_hide-child_one': '隐藏子菜单',
'function_hide-child_two': '菜单二',
'function_hide-child_three': '菜单三',
manage: '系统管理',
manage_user: '用户管理',
'manage_user-detail': '用户详情',
Expand Down
3 changes: 3 additions & 0 deletions src/router/elegant/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
500: () => import("@/views/_builtin/500/index.vue"),
login: () => import("@/views/_builtin/login/index.vue"),
about: () => import("@/views/about/index.vue"),
"function_hide-child_one": () => import("@/views/function/hide-child/one/index.vue"),
"function_hide-child_three": () => import("@/views/function/hide-child/three/index.vue"),
"function_hide-child_two": () => import("@/views/function/hide-child/two/index.vue"),
"function_multi-tab": () => import("@/views/function/multi-tab/index.vue"),
function_tab: () => import("@/views/function/tab/index.vue"),
home: () => import("@/views/home/index.vue"),
Expand Down
46 changes: 46 additions & 0 deletions src/router/elegant/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,52 @@ export const generatedRoutes: GeneratedRoute[] = [
order: 6
},
children: [
{
name: 'function_hide-child',
path: '/function/hide-child',
meta: {
title: 'function_hide-child',
i18nKey: 'route.function_hide-child',
icon: 'material-symbols:filter-list-off'
},
redirect: '/function/hide-child/one',
children: [
{
name: 'function_hide-child_one',
path: '/function/hide-child/one',
component: 'view.function_hide-child_one',
meta: {
title: 'function_hide-child_one',
i18nKey: 'route.function_hide-child_one',
icon: 'material-symbols:filter-list-off',
hideInMenu: true,
activeMenu: 'function_hide-child'
}
},
{
name: 'function_hide-child_three',
path: '/function/hide-child/three',
component: 'view.function_hide-child_three',
meta: {
title: 'function_hide-child_three',
i18nKey: 'route.function_hide-child_three',
hideInMenu: true,
activeMenu: 'function_hide-child'
}
},
{
name: 'function_hide-child_two',
path: '/function/hide-child/two',
component: 'view.function_hide-child_two',
meta: {
title: 'function_hide-child_two',
i18nKey: 'route.function_hide-child_two',
hideInMenu: true,
activeMenu: 'function_hide-child'
}
}
]
},
{
name: 'function_multi-tab',
path: '/function/multi-tab',
Expand Down
4 changes: 4 additions & 0 deletions src/router/elegant/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const routeMap: RouteMap = {
"500": "/500",
"about": "/about",
"function": "/function",
"function_hide-child": "/function/hide-child",
"function_hide-child_one": "/function/hide-child/one",
"function_hide-child_three": "/function/hide-child/three",
"function_hide-child_two": "/function/hide-child/two",
"function_multi-tab": "/function/multi-tab",
"function_tab": "/function/tab",
"home": "/home",
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/route/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function getGlobalMenusByAuthRoutes(routes: ElegantConstRoute[]) {
if (!route.meta?.hideInMenu) {
const menu = getGlobalMenuByBaseRoute(route);

if (route.children?.length) {
if (route.children?.some(child => !child.meta?.hideInMenu)) {
menu.children = getGlobalMenusByAuthRoutes(route.children);
}

Expand Down
7 changes: 7 additions & 0 deletions src/typings/elegant-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ declare module "@elegant-router/types" {
"500": "/500";
"about": "/about";
"function": "/function";
"function_hide-child": "/function/hide-child";
"function_hide-child_one": "/function/hide-child/one";
"function_hide-child_three": "/function/hide-child/three";
"function_hide-child_two": "/function/hide-child/two";
"function_multi-tab": "/function/multi-tab";
"function_tab": "/function/tab";
"home": "/home";
Expand Down Expand Up @@ -109,6 +113,9 @@ declare module "@elegant-router/types" {
| "500"
| "login"
| "about"
| "function_hide-child_one"
| "function_hide-child_three"
| "function_hide-child_two"
| "function_multi-tab"
| "function_tab"
| "home"
Expand Down
2 changes: 1 addition & 1 deletion src/typings/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ declare module 'vue-router' {
* @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').LastLevelRouteKey;
activeMenu?: import('@elegant-router/types').RouteKey;
/** By default, the same route path will use one tab, if set to true, it will use multiple tabs */
multiTab?: boolean;
/** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */
Expand Down
7 changes: 7 additions & 0 deletions src/views/function/hide-child/one/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>one</div>
</template>

<style scoped></style>
7 changes: 7 additions & 0 deletions src/views/function/hide-child/three/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>three</div>
</template>

<style scoped></style>
7 changes: 7 additions & 0 deletions src/views/function/hide-child/two/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts"></script>

<template>
<div>two</div>
</template>

<style scoped></style>

0 comments on commit cd72e7a

Please sign in to comment.