From 5efb195a3e0c956c4b254408a8868368135eb773 Mon Sep 17 00:00:00 2001 From: zhangxiao <898441624@qq.com> Date: 星期五, 16 八月 2024 14:11:52 +0800 Subject: [PATCH] fix: 模型修改 --- src/components/menu/index.vue | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/menu/index.vue b/src/components/menu/index.vue index 0702897..d7db1e6 100644 --- a/src/components/menu/index.vue +++ b/src/components/menu/index.vue @@ -2,12 +2,11 @@ import { defineComponent, ref, h, compile, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute, useRouter, RouteRecordRaw } from 'vue-router'; - import type { RouteMeta } from 'vue-router'; + import type, { RouteMeta } from 'vue-router'; import { useAppStore } from '@/store'; import { listenerRouteChange } from '@/utils/route-listener'; import { openWindow, regexUrl } from '@/utils'; import useMenuTree from './use-menu-tree'; - export default defineComponent({ emit: ['collapse'], setup() { @@ -32,6 +31,7 @@ const goto = (item: RouteRecordRaw) => { // Open external link + if (regexUrl.test(item.path)) { openWindow(item.path); selectedKey.value = [item.name as string]; @@ -39,11 +39,25 @@ } // 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){ + // router.push({ + // name: `${item.name}${suffix}`, + // }); + // } else{ + // router.push({ + // name: item.name, + // }); + // } // Trigger router change + router.push({ name: item.name, }); @@ -71,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 ); @@ -83,6 +98,7 @@ activeMenu || menuOpenKeys[menuOpenKeys.length - 1], ]; } + console.log(selectedKey.value, 48877); }, true); const setCollapse = (val: boolean) => { if (appStore.device === 'desktop') @@ -125,6 +141,8 @@ return travel(menuTree.value); }; + // selected-keys={selectedKey.value} + console.log(selectedKey.value, 68877); return () => ( <a-menu mode={topMenu.value ? 'horizontal' : 'vertical'} @@ -132,8 +150,8 @@ v-model:open-keys={openKeys.value} show-collapse-button={appStore.device !== 'mobile'} auto-open={false} - selected-keys={selectedKey.value} auto-open-selected={true} + selected-keys={selectedKey.value} level-indent={34} style="height: 100%;width:100%;" onCollapse={setCollapse} -- Gitblit v1.8.0