From a2485a5a46831e12ab6e0504b638743dba93c3c9 Mon Sep 17 00:00:00 2001 From: xieyuhang <xieyuhang@qq.com> Date: Wed, 3 Jun 2020 15:45:58 +0800 Subject: [PATCH] fix: Not allowed to close tags --- src/store/modules/tagsView.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index b8bb520f..4b90c289 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -72,12 +72,15 @@ const mutations = { if (index === -1) { return } - const arr = state.visitedViews.splice(index + 1) - arr.forEach(item => { - const index = state.cachedViews.indexOf(item.name) - if (index > -1) { - state.cachedViews.splice(index, 1) + state.visitedViews = state.visitedViews.filter((item, idx) => { + if (idx <= index || (item.meta && item.meta.affix)) { + return true } + const i = state.cachedViews.indexOf(item.name) + if (i > -1) { + state.cachedViews.splice(i, 1) + } + return false }) } }