From ec29c057c4a283127fe5f09b7c4b52b5195e5ca1 Mon Sep 17 00:00:00 2001 From: LiuHao Date: Fri, 5 May 2023 10:36:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AFTopNav?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E7=BA=A7=E8=8F=9C=E5=8D=95=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TopNav/index.vue | 10 ++++++++-- src/types/router.d.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/TopNav/index.vue b/src/components/TopNav/index.vue index 79b7786..2092415 100644 --- a/src/components/TopNav/index.vue +++ b/src/components/TopNav/index.vue @@ -104,7 +104,7 @@ const setVisibleNumber = () => { visibleNumber.value = parseInt(String(width / 85)); } -const handleSelect = (key: string, keyPath: string[]) => { +const handleSelect = (key: string) => { currentIndex.value = key; const route = routers.value.find(item => item.path === key); if (isHttp(key)) { @@ -112,7 +112,13 @@ const handleSelect = (key: string, keyPath: string[]) => { window.open(key, "_blank"); } else if (!route || !route.children) { // 没有子路由路径内部打开 - router.push({ path: key, fullPath: '' }); + const routeMenu = childrenMenus.value.find(item => item.path === key); + if (routeMenu && routeMenu.query) { + let query = JSON.parse(routeMenu.query); + router.push({ path: key, query: query }); + } else { + router.push({ path: key }); + } appStore.toggleSideBarHide(true); } else { // 显示左侧联动菜单 diff --git a/src/types/router.d.ts b/src/types/router.d.ts index 0f2b026..b60b831 100644 --- a/src/types/router.d.ts +++ b/src/types/router.d.ts @@ -13,6 +13,7 @@ declare module 'vue-router' { title: string; icon: string; }; + query?: string; } & RouteRecordRaw; interface _RouteLocationBase {