diff --git a/src/icons/svg/affix.svg b/src/icons/svg/affix.svg
new file mode 100644
index 00000000..34979fd8
--- /dev/null
+++ b/src/icons/svg/affix.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/router/index.js b/src/router/index.js
index f42046ee..d03d7336 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', noCache: true, affix: true }
}
]
},
diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js
index cbf9eeb7..378cbcd3 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 c16827b6..b9b986f3 100644
--- a/src/views/layout/components/TagsView.vue
+++ b/src/views/layout/components/TagsView.vue
@@ -12,14 +12,16 @@
@click.middle.native="closeSelectedTag(tag)"
@contextmenu.prevent.native="openMenu(tag,$event)">
{{ generateTitle(tag.title) }}
-
+
+