Commit da2d88a984dc308b929fac0fbeeae34a53d5f573
1 parent
50915c97
wip(menu): add hideChildrenInMenu option
Showing
10 changed files
with
32 additions
and
40 deletions
package.json
@@ -108,7 +108,7 @@ | @@ -108,7 +108,7 @@ | ||
108 | "stylelint-order": "^4.1.0", | 108 | "stylelint-order": "^4.1.0", |
109 | "ts-node": "^9.1.1", | 109 | "ts-node": "^9.1.1", |
110 | "typescript": "4.2.3", | 110 | "typescript": "4.2.3", |
111 | - "vite": "2.1.1", | 111 | + "vite": "2.0.5", |
112 | "vite-plugin-compression": "^0.2.3", | 112 | "vite-plugin-compression": "^0.2.3", |
113 | "vite-plugin-html": "^2.0.3", | 113 | "vite-plugin-html": "^2.0.3", |
114 | "vite-plugin-imagemin": "^0.2.9", | 114 | "vite-plugin-imagemin": "^0.2.9", |
src/components/Menu/src/components/BasicSubMenuItem.vue
@@ -39,6 +39,7 @@ | @@ -39,6 +39,7 @@ | ||
39 | const getShowMenu = computed(() => !props.item.meta?.hideMenu); | 39 | const getShowMenu = computed(() => !props.item.meta?.hideMenu); |
40 | function menuHasChildren(menuTreeItem: MenuType): boolean { | 40 | function menuHasChildren(menuTreeItem: MenuType): boolean { |
41 | return ( | 41 | return ( |
42 | + !menuTreeItem.meta?.hideChildrenInMenu && | ||
42 | Reflect.has(menuTreeItem, 'children') && | 43 | Reflect.has(menuTreeItem, 'children') && |
43 | !!menuTreeItem.children && | 44 | !!menuTreeItem.children && |
44 | menuTreeItem.children.length > 0 | 45 | menuTreeItem.children.length > 0 |
src/components/SimpleMenu/src/SimpleSubMenu.vue
@@ -91,6 +91,7 @@ | @@ -91,6 +91,7 @@ | ||
91 | 91 | ||
92 | function menuHasChildren(menuTreeItem: Menu): boolean { | 92 | function menuHasChildren(menuTreeItem: Menu): boolean { |
93 | return ( | 93 | return ( |
94 | + !menuTreeItem.meta?.hideChildrenInMenu && | ||
94 | Reflect.has(menuTreeItem, 'children') && | 95 | Reflect.has(menuTreeItem, 'children') && |
95 | !!menuTreeItem.children && | 96 | !!menuTreeItem.children && |
96 | menuTreeItem.children.length > 0 | 97 | menuTreeItem.children.length > 0 |
src/layouts/default/header/components/Breadcrumb.vue
@@ -54,7 +54,13 @@ | @@ -54,7 +54,13 @@ | ||
54 | watchEffect(async () => { | 54 | watchEffect(async () => { |
55 | if (currentRoute.value.name === REDIRECT_NAME) return; | 55 | if (currentRoute.value.name === REDIRECT_NAME) return; |
56 | const menus = await getMenus(); | 56 | const menus = await getMenus(); |
57 | - const path = currentRoute.value.path; | 57 | + const routeMatched = currentRoute.value.matched; |
58 | + const cur = routeMatched?.[routeMatched.length - 1]; | ||
59 | + let path = currentRoute.value.path; | ||
60 | + | ||
61 | + if (cur && cur?.meta?.currentActiveMenu) { | ||
62 | + path = cur.meta.currentActiveMenu as string; | ||
63 | + } | ||
58 | 64 | ||
59 | const parent = getAllParentPath(menus, path); | 65 | const parent = getAllParentPath(menus, path); |
60 | 66 | ||
@@ -70,27 +76,23 @@ | @@ -70,27 +76,23 @@ | ||
70 | (item) => item.path !== PageEnum.BASE_HOME | 76 | (item) => item.path !== PageEnum.BASE_HOME |
71 | ); | 77 | ); |
72 | 78 | ||
73 | - // if (filterBreadcrumbList.length === breadcrumbList.length) { | ||
74 | - // filterBreadcrumbList.unshift(({ | ||
75 | - // path: PageEnum.BASE_HOME, | ||
76 | - // meta: { | ||
77 | - // title: t('layout.header.home'), | ||
78 | - // isLink: true, | ||
79 | - // }, | ||
80 | - // } as unknown) as RouteLocationMatched); | ||
81 | - // } | ||
82 | - | ||
83 | if (currentRoute.value.meta?.currentActiveMenu) { | 79 | if (currentRoute.value.meta?.currentActiveMenu) { |
84 | - filterBreadcrumbList.push((currentRoute.value as unknown) as RouteLocationMatched); | 80 | + filterBreadcrumbList.push(({ |
81 | + ...currentRoute.value, | ||
82 | + name: currentRoute.value.meta?.title || currentRoute.value.name, | ||
83 | + } as unknown) as RouteLocationMatched); | ||
85 | } | 84 | } |
86 | - routes.value = subRouteExtraction(filterBreadcrumbList); | 85 | + routes.value = filterBreadcrumbList; |
87 | }); | 86 | }); |
88 | 87 | ||
89 | function getMatched(menus: Menu[], parent: string[]) { | 88 | function getMatched(menus: Menu[], parent: string[]) { |
90 | const metched: Menu[] = []; | 89 | const metched: Menu[] = []; |
91 | menus.forEach((item) => { | 90 | menus.forEach((item) => { |
92 | if (parent.includes(item.path)) { | 91 | if (parent.includes(item.path)) { |
93 | - metched.push(item); | 92 | + metched.push({ |
93 | + ...item, | ||
94 | + name: item.meta?.title || item.name, | ||
95 | + }); | ||
94 | } | 96 | } |
95 | if (item.children?.length) { | 97 | if (item.children?.length) { |
96 | metched.push(...getMatched(item.children, parent)); | 98 | metched.push(...getMatched(item.children, parent)); |
@@ -99,22 +101,6 @@ | @@ -99,22 +101,6 @@ | ||
99 | return metched; | 101 | return metched; |
100 | } | 102 | } |
101 | 103 | ||
102 | - function subRouteExtraction(routeList: RouteLocationMatched[]) { | ||
103 | - const resultRoutes: RouteLocationMatched[] = []; | ||
104 | - routeList.forEach((route) => { | ||
105 | - if (route.children?.length === 1) { | ||
106 | - const subRoute = route.children[0] as RouteLocationMatched; | ||
107 | - const subRouteName = subRoute.name as string; | ||
108 | - const routeName = route.name; | ||
109 | - if (subRouteName && `${subRouteName}Parent` === routeName) { | ||
110 | - route = subRoute; | ||
111 | - } | ||
112 | - } | ||
113 | - resultRoutes.push(route); | ||
114 | - }); | ||
115 | - return resultRoutes; | ||
116 | - } | ||
117 | - | ||
118 | function filterItem(list: RouteLocationMatched[]) { | 104 | function filterItem(list: RouteLocationMatched[]) { |
119 | let resultList = filter(list, (item) => { | 105 | let resultList = filter(list, (item) => { |
120 | const { meta } = item; | 106 | const { meta } = item; |
src/layouts/default/header/index.less
@@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
67 | .@{header-trigger-prefix-cls} { | 67 | .@{header-trigger-prefix-cls} { |
68 | display: flex; | 68 | display: flex; |
69 | height: 100%; | 69 | height: 100%; |
70 | - padding: 1px 10px 0 16px; | 70 | + padding: 1px 10px 0 10px; |
71 | cursor: pointer; | 71 | cursor: pointer; |
72 | align-items: center; | 72 | align-items: center; |
73 | 73 |
src/router/routes/modules/dashboard.ts
@@ -11,6 +11,7 @@ const dashboard: AppRouteModule = { | @@ -11,6 +11,7 @@ const dashboard: AppRouteModule = { | ||
11 | meta: { | 11 | meta: { |
12 | icon: 'ion:grid-outline', | 12 | icon: 'ion:grid-outline', |
13 | title: t('routes.dashboard.dashboard'), | 13 | title: t('routes.dashboard.dashboard'), |
14 | + hideChildrenInMenu: true, | ||
14 | }, | 15 | }, |
15 | children: [ | 16 | children: [ |
16 | { | 17 | { |
src/router/routes/modules/demo/feat.ts
@@ -81,7 +81,7 @@ const feat: AppRouteModule = { | @@ -81,7 +81,7 @@ const feat: AppRouteModule = { | ||
81 | component: () => import('/@/views/demo/feat/breadcrumb/ChildrenList.vue'), | 81 | component: () => import('/@/views/demo/feat/breadcrumb/ChildrenList.vue'), |
82 | meta: { | 82 | meta: { |
83 | title: t('routes.demo.feat.breadcrumbChildren'), | 83 | title: t('routes.demo.feat.breadcrumbChildren'), |
84 | - hideBreadcrumb: true, | 84 | + // hideBreadcrumb: true, |
85 | }, | 85 | }, |
86 | }, | 86 | }, |
87 | { | 87 | { |
src/router/types.ts
@@ -30,6 +30,9 @@ export interface RouteMeta { | @@ -30,6 +30,9 @@ export interface RouteMeta { | ||
30 | // Whether the route has been dynamically added | 30 | // Whether the route has been dynamically added |
31 | hideBreadcrumb?: boolean; | 31 | hideBreadcrumb?: boolean; |
32 | 32 | ||
33 | + // Hide submenu | ||
34 | + hideChildrenInMenu?: boolean; | ||
35 | + | ||
33 | // Carrying parameters | 36 | // Carrying parameters |
34 | carryParam?: boolean; | 37 | carryParam?: boolean; |
35 | 38 |
src/settings/designSetting.ts
@@ -31,8 +31,8 @@ export const HEADER_PRESET_BG_COLOR_LIST: string[] = [ | @@ -31,8 +31,8 @@ export const HEADER_PRESET_BG_COLOR_LIST: string[] = [ | ||
31 | 31 | ||
32 | // sider preset color | 32 | // sider preset color |
33 | export const SIDE_BAR_BG_COLOR_LIST: string[] = [ | 33 | export const SIDE_BAR_BG_COLOR_LIST: string[] = [ |
34 | - '#273352', | ||
35 | '#001529', | 34 | '#001529', |
35 | + '#273352', | ||
36 | '#ffffff', | 36 | '#ffffff', |
37 | '#191b24', | 37 | '#191b24', |
38 | '#191a23', | 38 | '#191a23', |
yarn.lock
@@ -4734,7 +4734,7 @@ esbuild-register@^2.2.0: | @@ -4734,7 +4734,7 @@ esbuild-register@^2.2.0: | ||
4734 | dependencies: | 4734 | dependencies: |
4735 | jsonc-parser "^3.0.0" | 4735 | jsonc-parser "^3.0.0" |
4736 | 4736 | ||
4737 | -esbuild@^0.8.57: | 4737 | +esbuild@^0.8.52, esbuild@^0.8.57: |
4738 | version "0.8.57" | 4738 | version "0.8.57" |
4739 | resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.57.tgz#a42d02bc2b57c70bcd0ef897fe244766bb6dd926" | 4739 | resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.57.tgz#a42d02bc2b57c70bcd0ef897fe244766bb6dd926" |
4740 | integrity sha512-j02SFrUwFTRUqiY0Kjplwjm1psuzO1d6AjaXKuOR9hrY0HuPsT6sV42B6myW34h1q4CRy+Y3g4RU/cGJeI/nNA== | 4740 | integrity sha512-j02SFrUwFTRUqiY0Kjplwjm1psuzO1d6AjaXKuOR9hrY0HuPsT6sV42B6myW34h1q4CRy+Y3g4RU/cGJeI/nNA== |
@@ -11634,12 +11634,12 @@ vite-plugin-windicss@0.8.4: | @@ -11634,12 +11634,12 @@ vite-plugin-windicss@0.8.4: | ||
11634 | "@windicss/plugin-utils" "0.8.4" | 11634 | "@windicss/plugin-utils" "0.8.4" |
11635 | windicss "^2.4.5" | 11635 | windicss "^2.4.5" |
11636 | 11636 | ||
11637 | -vite@2.1.1: | ||
11638 | - version "2.1.1" | ||
11639 | - resolved "https://registry.npmjs.org/vite/-/vite-2.1.1.tgz#13c7a7a5665b435f28fe8549caab181e0ad9af7b" | ||
11640 | - integrity sha512-nlTQrfYIkahcElD8O/oogbLbuKgAZRbvoFOth3GmRSglfPdY4RgfBjj0Fu7HeCU/2u3Jxc6jW4UuV22LGw1Yaw== | 11637 | +vite@2.0.5: |
11638 | + version "2.0.5" | ||
11639 | + resolved "https://registry.npmjs.org/vite/-/vite-2.0.5.tgz#ac46857a3fa8686d077921e61bd48a986931df1d" | ||
11640 | + integrity sha512-QTgEDbq1WsTtr6j+++ewjhBFEk6c8v0xz4fb/OWJQKNYU8ZZtphOshwOqAlnarSstPBtWCBR0tsugXx6ajfoUg== | ||
11641 | dependencies: | 11641 | dependencies: |
11642 | - esbuild "^0.9.2" | 11642 | + esbuild "^0.8.52" |
11643 | postcss "^8.2.1" | 11643 | postcss "^8.2.1" |
11644 | resolve "^1.19.0" | 11644 | resolve "^1.19.0" |
11645 | rollup "^2.38.5" | 11645 | rollup "^2.38.5" |