Commit e183ea0f07a4a2ad4f8fd51a4c76c0cc1d88d282
Merge branch 'fix/board-menu-display' into 'main_dev'
fix: 修复点击看板详情时候,菜单栏选中问题 See merge request yunteng/thingskit-front!827
Showing
3 changed files
with
33 additions
and
2 deletions
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | import { openWindow } from '/@/utils'; |
34 | 34 | |
35 | 35 | import { useOpenKeys } from './useOpenKeys'; |
36 | + import { useMenuActiveFix } from '/@/hooks/business/useMenuActiveFix'; | |
36 | 37 | export default defineComponent({ |
37 | 38 | name: 'SimpleMenu', |
38 | 39 | components: { |
... | ... | @@ -120,7 +121,10 @@ |
120 | 121 | isClickGo.value = false; |
121 | 122 | return; |
122 | 123 | } |
123 | - const path = (route || unref(currentRoute)).path; | |
124 | + console.log(route); | |
125 | + | |
126 | + let { flag, path } = useMenuActiveFix(route || unref(currentRoute)); | |
127 | + path = flag ? path : (route || unref(currentRoute)).path; | |
124 | 128 | |
125 | 129 | menuState.activeName = path; |
126 | 130 | ... | ... |
src/hooks/business/useMenuActiveFix.ts
0 → 100644
1 | +import { RouteLocationNormalizedLoaded } from 'vue-router'; | |
2 | + | |
3 | +const menuMap = new Map(); | |
4 | + | |
5 | +menuMap.set('/visual/board/detail/:boardId/:boardName?', '/visual/board'); | |
6 | + | |
7 | +export const useMenuActiveFix = (route: RouteLocationNormalizedLoaded) => { | |
8 | + let flag = false; | |
9 | + let path; | |
10 | + | |
11 | + const matchPath = route.matched.map((item) => item.path); | |
12 | + const needFixMenus: string[] = Array.from(menuMap.keys()); | |
13 | + | |
14 | + for (const item of matchPath) { | |
15 | + for (const menu of needFixMenus) { | |
16 | + if (menu === item) { | |
17 | + flag = true; | |
18 | + path = menuMap.get(menu); | |
19 | + break; | |
20 | + } | |
21 | + } | |
22 | + } | |
23 | + | |
24 | + return { | |
25 | + flag, | |
26 | + path, | |
27 | + }; | |
28 | +}; | ... | ... |