zhangxiao
2024-08-16 5efb195a3e0c956c4b254408a8868368135eb773
src/components/menu/index.vue
@@ -31,6 +31,7 @@
      const goto = (item: RouteRecordRaw) => {
        // Open external link
        if (regexUrl.test(item.path)) {
          openWindow(item.path);
          selectedKey.value = [item.name as string];
@@ -38,10 +39,12 @@
        }
        // Eliminate external link side effects
        const { hideInMenu, activeMenu } = item.meta as RouteMeta;
        if (route.name === item.name && !hideInMenu && !activeMenu) {
          selectedKey.value = [item.name as string];
          return;
        }
        // const firstMenuNameArr=['model','knowledge','session','sessionRecords'];
        // const suffix='Manager';
        // if(firstMenuNameArr.indexOf(item.name)!=-1){
@@ -54,6 +57,7 @@
        //   });
        // }
        // Trigger router change
        router.push({
          name: item.name,
        });
@@ -81,7 +85,8 @@
      };
      listenerRouteChange((newRoute) => {
        const { requiresAuth, activeMenu, hideInMenu } = newRoute.meta;
        if (requiresAuth && (!hideInMenu || activeMenu)) {
        //  if (requiresAuth && (!hideInMenu || activeMenu)) {//除去这两个判断后,可以正常展开菜单
        if (requiresAuth) {
          const menuOpenKeys = findMenuOpenKeys(
            (activeMenu || newRoute.name) as string
          );
@@ -93,6 +98,7 @@
            activeMenu || menuOpenKeys[menuOpenKeys.length - 1],
          ];
        }
        console.log(selectedKey.value, 48877);
      }, true);
      const setCollapse = (val: boolean) => {
        if (appStore.device === 'desktop')
@@ -136,6 +142,7 @@
      };
      // selected-keys={selectedKey.value}
      console.log(selectedKey.value, 68877);
      return () => (
        <a-menu
          mode={topMenu.value ? 'horizontal' : 'vertical'}
@@ -144,6 +151,7 @@
          show-collapse-button={appStore.device !== 'mobile'}
          auto-open={false}
          auto-open-selected={true}
          selected-keys={selectedKey.value}
          level-indent={34}
          style="height: 100%;width:100%;"
          onCollapse={setCollapse}