From 11163146c09c6cdf0e2e354a632e1b9b92d46263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Fri, 14 Sep 2018 17:58:59 +0800 Subject: [PATCH] fix[tagsView]: update tagsview when query is different(#1090) --- src/store/modules/tagsView.js | 13 +++++++++++++ src/views/layout/components/TagsView.vue | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index f2faeb12..cbf9eeb7 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -60,6 +60,15 @@ const tagsView = { }, DEL_ALL_CACHED_VIEWS: state => { state.cachedViews = [] + }, + + UPDATE_VISITED_VIEW: (state, view) => { + for (let v of state.visitedViews) { + if (v.path === view.path) { + v = Object.assign(v, view) + break + } + } } }, @@ -142,6 +151,10 @@ const tagsView = { commit('DEL_ALL_CACHED_VIEWS') resolve([...state.cachedViews]) }) + }, + + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) } } } diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue index 793cc698..c824a38d 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -81,6 +81,12 @@ export default { for (const tag of tags) { if (tag.to.path === this.$route.path) { this.$refs.scrollPane.moveToTarget(tag.$el) + + // when query is different then update + if (tag.to.fullPath !== this.$route.fullPath) { + this.$store.dispatch('updateVisitedView', this.$route) + } + break } }