From 160858d6deb2522820ff405c70eb39cbc8c3a397 Mon Sep 17 00:00:00 2001 From: pany <939630029@qq.com> Date: Fri, 26 Aug 2022 19:16:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=9A=E8=BF=87=20T?= =?UTF-8?q?agsView=20=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20query=20=E5=8F=82=E6=95=B0=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/TagsView/index.vue | 7 +++++-- src/store/modules/tags-view.ts | 14 +++++++++++++- src/views/redirect/index.vue | 6 +++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index c34b122..66b7d2d 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -68,7 +68,7 @@ const addTags = () => { } const refreshSelectedTag = (view: ITagView) => { - router.replace({ path: "/redirect" + view.fullPath }) + router.replace({ path: "/redirect" + view.path, query: view.query }) } const closeSelectedTag = (view: ITagView) => { @@ -133,9 +133,12 @@ const closeMenu = () => { } watch( - () => route.name, + route, () => { addTags() + }, + { + deep: true } ) diff --git a/src/store/modules/tags-view.ts b/src/store/modules/tags-view.ts index c8d5363..5c97160 100644 --- a/src/store/modules/tags-view.ts +++ b/src/store/modules/tags-view.ts @@ -8,7 +8,19 @@ export const useTagsViewStore = defineStore("tags-view", () => { const visitedViews = ref([]) const addVisitedView = (view: ITagView) => { - if (visitedViews.value.some((v) => v.path === view.path)) return + if ( + visitedViews.value.some((v, index) => { + if (v.path === view.path) { + if (v.fullPath !== view.fullPath) { + // 防止 query 参数丢失 + visitedViews.value[index] = Object.assign({}, view) + } + return true + } + }) + ) { + return + } visitedViews.value.push(Object.assign({}, view)) } const delVisitedView = (view: ITagView) => { diff --git a/src/views/redirect/index.vue b/src/views/redirect/index.vue index 3a12b60..2fb46b3 100644 --- a/src/views/redirect/index.vue +++ b/src/views/redirect/index.vue @@ -1,10 +1,10 @@