fearure[TagsView]: add affix option (#1577)

This commit is contained in:
花裤衩
2019-02-15 15:26:48 +08:00
committed by GitHub
parent 4e0559833f
commit 48e47e86f1
3 changed files with 69 additions and 25 deletions

View File

@@ -38,12 +38,9 @@ const tagsView = {
},
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.visitedViews.entries()) {
if (v.path === view.path) {
state.visitedViews = state.visitedViews.slice(i, i + 1)
break
}
}
state.visitedViews = state.visitedViews.filter(v => {
return v.meta.affix || v.path === view.path
})
},
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
for (const i of state.cachedViews) {
@@ -56,7 +53,9 @@ const tagsView = {
},
DEL_ALL_VISITED_VIEWS: state => {
state.visitedViews = []
// keep affix tags
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
state.visitedViews = affixTags
},
DEL_ALL_CACHED_VIEWS: state => {
state.cachedViews = []