From ec29c057c4a283127fe5f09b7c4b52b5195e5ca1 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail>
Date: 星期五, 05 五月 2023 10:36:21 +0800
Subject: [PATCH] 修复开启TopNav后一级菜单路由参数设置无效问题
---
src/types/router.d.ts | 1 +
src/components/TopNav/index.vue | 10 ++++++++--
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 @@
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 @@
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 @@
title: string;
icon: string;
};
+ query?: string;
} & RouteRecordRaw;
interface _RouteLocationBase {
--
Gitblit v1.9.3