Skip to content

Commit 6b179e6

Browse files
authored
fix: 修复params传参模式下标签页右键菜单显示不正确的问题 (#1221)
1 parent e1fde7d commit 6b179e6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/layout/components/lay-tag/index.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
356356
break;
357357
}
358358
setTimeout(() => {
359-
showMenuModel(route.fullPath, route.query);
359+
showMenuModel(route.fullPath, route.query, route.params);
360360
});
361361
}
362362
@@ -391,15 +391,18 @@ function disabledMenus(value: boolean, fixedTag = false) {
391391
function showMenuModel(
392392
currentPath: string,
393393
query: object = {},
394+
params: object = {},
394395
refresh = false
395396
) {
396397
const allRoute = multiTags.value;
397398
const routeLength = multiTags.value.length;
398399
let currentIndex = -1;
399-
if (isAllEmpty(query)) {
400-
currentIndex = allRoute.findIndex(v => v.path === currentPath);
401-
} else {
400+
if (!isAllEmpty(params)) {
401+
currentIndex = allRoute.findIndex(v => isEqual(v.params, params));
402+
} else if (!isAllEmpty(query)) {
402403
currentIndex = allRoute.findIndex(v => isEqual(v.query, query));
404+
} else {
405+
currentIndex = allRoute.findIndex(v => v.path === currentPath);
403406
}
404407
function fixedTagDisabled() {
405408
if (allRoute[currentIndex]?.meta?.fixedTag) {
@@ -465,14 +468,14 @@ function openMenu(tag, e) {
465468
} else if (route.path !== tag.path && route.name !== tag.name) {
466469
// 右键菜单不匹配当前路由,隐藏刷新
467470
tagsViews[0].show = false;
468-
showMenuModel(tag.path, tag.query);
471+
showMenuModel(tag.path, tag.query, tag.params);
469472
} else if (multiTags.value.length === 2 && route.path !== tag.path) {
470473
showMenus(true);
471474
// 只有两个标签时不显示关闭其他标签页
472475
tagsViews[4].show = false;
473-
} else if (route.path === tag.path) {
474-
// 右键当前激活的菜单
475-
showMenuModel(tag.path, tag.query, true);
476+
showMenuModel(tag.path, tag.query, tag.params);
477+
} else {
478+
showMenuModel(tag.path, tag.query, tag.params, true);
476479
}
477480
478481
currentSelect.value = tag;

0 commit comments

Comments
 (0)