fix: 修复动态路由重定向造成标签页出现重复内容

This commit is contained in:
xiaoxian521 2023-05-23 20:43:16 +08:00
parent b6ae64a89b
commit a4a691de3e
2 changed files with 18 additions and 7 deletions

View File

@ -23,7 +23,7 @@ import {
formatFlatteningRoutes formatFlatteningRoutes
} from "./utils"; } from "./utils";
import { buildHierarchyTree } from "@/utils/tree"; import { buildHierarchyTree } from "@/utils/tree";
import { isUrl, openLink, storageSession } from "@pureadmin/utils"; import { isUrl, openLink, storageSession, isAllEmpty } from "@pureadmin/utils";
import remainingRouter from "./modules/remaining"; import remainingRouter from "./modules/remaining";
@ -158,11 +158,22 @@ router.beforeEach((to: toRouteType, _from, next) => {
getTopMenu(true); getTopMenu(true);
// query、params模式路由传参数的标签页不在此处处理 // query、params模式路由传参数的标签页不在此处处理
if (route && route.meta?.title) { if (route && route.meta?.title) {
if (isAllEmpty(route.parentId) && route.meta?.backstage) {
// 此处为动态顶级路由(目录)
const { path, name, meta } = route.children[0];
useMultiTagsStoreHook().handleTags("push", { useMultiTagsStoreHook().handleTags("push", {
path: route.path, path,
name: route.name, name,
meta: route.meta meta
}); });
} else {
const { path, name, meta } = route;
useMultiTagsStoreHook().handleTags("push", {
path,
name,
meta
});
}
} }
} }
router.push(to.fullPath); router.push(to.fullPath);

View File

@ -3,7 +3,7 @@ import { components } from "@/router/enums";
export default { export default {
path: "/components", path: "/components",
redirect: "/components/video", redirect: "/components/dialog",
meta: { meta: {
icon: "menu", icon: "menu",
title: $t("menus.hscomponents"), title: $t("menus.hscomponents"),