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

View File

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