Skip to content

Commit cbb4144

Browse files
committed
fix: 修复params传参模式下标签页右键菜单显示不正确的问题
1 parent acf15af commit cbb4144

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
353353
break;
354354
}
355355
setTimeout(() => {
356-
showMenuModel(route.fullPath, route.query);
356+
showMenuModel(route.fullPath, route.query, route.params);
357357
});
358358
}
359359
@@ -388,15 +388,18 @@ function disabledMenus(value: boolean, fixedTag = false) {
388388
function showMenuModel(
389389
currentPath: string,
390390
query: object = {},
391+
params: object = {},
391392
refresh = false
392393
) {
393394
const allRoute = multiTags.value;
394395
const routeLength = multiTags.value.length;
395396
let currentIndex = -1;
396-
if (isAllEmpty(query)) {
397-
currentIndex = allRoute.findIndex(v => v.path === currentPath);
398-
} else {
397+
if (!isAllEmpty(params)) {
398+
currentIndex = allRoute.findIndex(v => isEqual(v.params, params));
399+
} else if (!isAllEmpty(query)) {
399400
currentIndex = allRoute.findIndex(v => isEqual(v.query, query));
401+
} else {
402+
currentIndex = allRoute.findIndex(v => v.path === currentPath);
400403
}
401404
function fixedTagDisabled() {
402405
if (allRoute[currentIndex]?.meta?.fixedTag) {
@@ -462,14 +465,17 @@ function openMenu(tag, e) {
462465
} else if (route.path !== tag.path && route.name !== tag.name) {
463466
// 右键菜单不匹配当前路由,隐藏刷新
464467
tagsViews[0].show = false;
465-
showMenuModel(tag.path, tag.query);
468+
showMenuModel(tag.path, tag.query, tag.params);
466469
} else if (multiTags.value.length === 2 && route.path !== tag.path) {
467470
showMenus(true);
468471
// 只有两个标签时不显示关闭其他标签页
469472
tagsViews[4].show = false;
473+
showMenuModel(tag.path, tag.query, tag.params);
470474
} else if (route.path === tag.path) {
471475
// 右键当前激活的菜单
472-
showMenuModel(tag.path, tag.query, true);
476+
showMenuModel(tag.path, tag.query, tag.params, true);
477+
} else {
478+
showMenuModel(tag.path, tag.query, tag.params, true);
473479
}
474480
475481
currentSelect.value = tag;

0 commit comments

Comments
 (0)