From 378feceb5f8f42203fc246cab72576a218e00791 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Wed, 18 May 2022 10:29:26 +0800 Subject: [PATCH] perf: tag demo --- src/views/tabs/hooks.ts | 2 +- src/views/tabs/index.vue | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/views/tabs/hooks.ts b/src/views/tabs/hooks.ts index 51f4e3167..fae0551e8 100644 --- a/src/views/tabs/hooks.ts +++ b/src/views/tabs/hooks.ts @@ -28,5 +28,5 @@ export function useDetail() { }); } - return { toDetail, initToDetail, id }; + return { toDetail, initToDetail, id, router }; } diff --git a/src/views/tabs/index.vue b/src/views/tabs/index.vue index 37eec26c3..80bc8d915 100644 --- a/src/views/tabs/index.vue +++ b/src/views/tabs/index.vue @@ -10,7 +10,7 @@ import { getNodeByUniqueId } from "/@/utils/tree"; import { useDetail } from "./hooks"; -const { toDetail } = useDetail(); +const { toDetail, router } = useDetail(); let treeData = computed(() => { return appendFieldByUniqueId( @@ -22,12 +22,20 @@ let treeData = computed(() => { const value = ref([]); +let multiTags = computed(() => { + return useMultiTagsStoreHook()?.multiTags; +}); + function onCloseTags() { value.value.forEach(uniqueId => { let currentPath = getNodeByUniqueId(treeData.value, uniqueId).redirect ?? getNodeByUniqueId(treeData.value, uniqueId).path; useMultiTagsStoreHook().handleTags("splice", currentPath); + if (currentPath === "/tabs/index") + router.push({ + path: multiTags.value[multiTags.value.length - 1].path + }); }); } @@ -68,5 +76,17 @@ function onCloseTags() { 关闭标签 +
+

+ 注意:此demo并未开启标签页缓存,如果需要在 + 刷新页面 + 的时候同时 + 保留标签页的显示 + 或者 + 保留url的参数 + ,那么就需要开启标签页持久化。 +
+ 开启方式:在页面最右上角有个设置的小图标,点进去,会看到项目配置面板,找到标签页持久化开启即可。 +