Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复路由跳转,参数相同的情况下,标签页同时高亮的问题 #465

Closed
wants to merge 1 commit into from

Conversation

achangchangchang
Copy link

@achangchangchang achangchangchang commented Mar 1, 2023

问题

动画
image

复现步骤

将src\views\tabs\hooks.ts文件做以下修改,跳转路径不同,参数相同,模拟此问题的场景
image

@xiaoxian521
Copy link
Member

方面把上图代码贴出来吗 我方便测试

@xiaoxian521 xiaoxian521 self-requested a review March 1, 2023 08:47
@achangchangchang
Copy link
Author

替换一下src\views\tabs\hooks.ts文件中的toDetail方法

  function toDetail(
    index: number | string | string[] | number[],
    model: string
  ) {
    if (model === "query") {
      // 保存信息到标签页
      useMultiTagsStoreHook().handleTags("push", {
        path: `/tabs/query-detail`,
        name: "TabQueryDetail",
        query: { id: "1" },
        meta: {
          title: {
            zh: `No.${index} - 详情信息`,
            en: `No.${index} - DetailInfo`
          }
        }
      });
      // 路由跳转
      router.push({ name: "TabQueryDetail", query: { id: "1" } });
    } else {
      useMultiTagsStoreHook().handleTags("push", {
        path: `/permission/button/index`,
        name: "PermissionButton",
        query: { id: "1" },
        meta: {
          title: {
            zh: `No.${index} - 按钮页面`,
            en: `No.${index} - DetailInfo`
          }
        }
      });
      router.push({ name: "PermissionButton", query: { id: "1" } });
    }
  }

@xiaoxian521
Copy link
Member

我看了下 如果你想跳转到别的已存在菜单的话 就不应该使用 useMultiTagsStoreHook().handleTags() 方法了,比如上面代码你改成下面就行

  function toDetail(
    index: number | string | string[] | number[],
    model: string
  ) {
    if (model === "query") {
      // 保存信息到标签页
      useMultiTagsStoreHook().handleTags("push", {
        path: `/tabs/query-detail`,
        name: "TabQueryDetail",
        query: { id: "1" },
        meta: {
          title: {
            zh: `No.${index} - 详情信息`,
            en: `No.${index} - DetailInfo`
          }
        }
      });
      // 路由跳转
      router.push({ name: "TabQueryDetail", query: { id: "1" } });
    } else {
      router.push({ name: "PermissionButton", query: { id: "1" } });
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants