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 @@