Skip to content

Commit

Permalink
优化:顶部标签栏缓存数组,删除元素函数
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeycf authored and monkeycf committed Oct 6, 2019
1 parent e3cbf4a commit 8365d9b
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/store/modules/tagsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ const mutations = {
}
},
DEL_CACHED_VIEW: (state, view) => {
for (const i of state.cachedViews) {
if (i === view.name) {
const index = state.cachedViews.indexOf(i)
state.cachedViews.splice(index, 1)
break
}
}
const index = state.cachedViews.indexOf(view.name)
index > -1 && state.cachedViews.splice(index, 1)
},

DEL_OTHERS_VISITED_VIEWS: (state, view) => {
Expand All @@ -43,13 +38,8 @@ const mutations = {
})
},
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
for (const i of state.cachedViews) {
if (i === view.name) {
const index = state.cachedViews.indexOf(i)
state.cachedViews = state.cachedViews.slice(index, index + 1)
break
}
}
const index = state.cachedViews.indexOf(view.name)
index > -1 && (state.cachedViews = state.cachedViews.slice(index, index + 1))
},

DEL_ALL_VISITED_VIEWS: state => {
Expand Down

0 comments on commit 8365d9b

Please sign in to comment.