Commit c6a08a93ae584e74c86f8e2ce433d6529acf4532

Authored by loveumiko
1 parent 9590a599

fix: 修复点击看板详情时候,菜单栏选中问题

@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
33 import { openWindow } from '/@/utils'; 33 import { openWindow } from '/@/utils';
34 34
35 import { useOpenKeys } from './useOpenKeys'; 35 import { useOpenKeys } from './useOpenKeys';
  36 + import { useMenuActiveFix } from '/@/hooks/business/useMenuActiveFix';
36 export default defineComponent({ 37 export default defineComponent({
37 name: 'SimpleMenu', 38 name: 'SimpleMenu',
38 components: { 39 components: {
@@ -120,7 +121,10 @@ @@ -120,7 +121,10 @@
120 isClickGo.value = false; 121 isClickGo.value = false;
121 return; 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 menuState.activeName = path; 129 menuState.activeName = path;
126 130
@@ -29,7 +29,6 @@ export function useOpenKeys( @@ -29,7 +29,6 @@ export function useOpenKeys(
29 return; 29 return;
30 } 30 }
31 const keys = getAllParentPath(menuList, path); 31 const keys = getAllParentPath(menuList, path);
32 -  
33 if (!unref(accordion)) { 32 if (!unref(accordion)) {
34 menuState.openNames = uniq([...menuState.openNames, ...keys]); 33 menuState.openNames = uniq([...menuState.openNames, ...keys]);
35 } else { 34 } else {
  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 +};