mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	feat(projects): support directory menu hide all child menus. fixed #325
This commit is contained in:
		@@ -129,6 +129,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',
 | 
			
		||||
 
 | 
			
		||||
@@ -129,6 +129,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': '用户详情',
 | 
			
		||||
 
 | 
			
		||||
@@ -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"),
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,50 @@ 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'
 | 
			
		||||
        },
 | 
			
		||||
        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',
 | 
			
		||||
              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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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",
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								src/typings/elegant-router.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								src/typings/elegant-router.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -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";
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								src/typings/router.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/typings/router.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -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 */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								src/views/function/hide-child/one/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/views/function/hide-child/one/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
<script setup lang="ts"></script>
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <div>one</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<style scoped></style>
 | 
			
		||||
							
								
								
									
										7
									
								
								src/views/function/hide-child/three/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/views/function/hide-child/three/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
<script setup lang="ts"></script>
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <div>three</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<style scoped></style>
 | 
			
		||||
							
								
								
									
										7
									
								
								src/views/function/hide-child/two/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/views/function/hide-child/two/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
<script setup lang="ts"></script>
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <div>two</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<style scoped></style>
 | 
			
		||||
		Reference in New Issue
	
	Block a user