diff --git a/src/router/index.js b/src/router/index.js index a86e3a1363317068ba5f0af980846cd3639948d6..60524517328ba89284f77498ee8545c49d8fb986 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -29,6 +29,7 @@ import nestedRouter from './modules/nested' icon: 'svg-name' the icon show in the sidebar noCache: true if true, the page will no be cached(default is false) breadcrumb: false if false, the item will hidden in breadcrumb(default is true) + affix: true if true, the tag will affix in the tags-view } **/ export const constantRouterMap = [ @@ -72,7 +73,7 @@ export const constantRouterMap = [ path: 'dashboard', component: () => import('@/views/dashboard/index'), name: 'Dashboard', - meta: { title: 'dashboard', icon: 'dashboard', noCache: true } + meta: { title: 'dashboard', icon: 'dashboard', noCache: true, affix: true } } ] }, @@ -85,7 +86,7 @@ export const constantRouterMap = [ path: 'index', component: () => import('@/views/documentation/index'), name: 'Documentation', - meta: { title: 'documentation', icon: 'documentation', noCache: true } + meta: { title: 'documentation', icon: 'documentation', affix: true } } ] }, diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index cbf9eeb7b5bbbba8e6d7937db72066a756a3c6e4..378cbcd3dae45e63625ebe5de8981c6ba1eb2be0 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -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 = [] diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue index c16827b6b784c1ed3cd5df612b563395c38bbef2..cfac9c7db1a86da09fc73bff2fba9a09f48cb269 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -12,14 +12,15 @@ @click.middle.native="closeSelectedTag(tag)" @contextmenu.prevent.native="openMenu(tag,$event)"> {{ generateTitle(tag.title) }} - + @@ -27,6 +28,7 @@