From 5c7a9840a8be90bc6c0111de68211c705d06a1ae Mon Sep 17 00:00:00 2001 From: "lei.jiang" Date: Tue, 12 Dec 2017 09:48:45 +0800 Subject: [PATCH] add the menu by right-clicking the tags --- src/store/modules/tagsView.js | 31 +++ src/views/layout/components/TagsView.vue | 287 ++++++++++++++--------- 2 files changed, 207 insertions(+), 111 deletions(-) diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index eed8b694..1fccaf69 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -29,6 +29,25 @@ const tagsView = { break } } + }, + DEL_OTHER_VIEWS: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews = [].concat(state.visitedViews.slice(i, i + 1)) + break + } + } + for (const i of state.cachedViews) { + if (i === view.name) { + const index = state.cachedViews.indexOf(i) + state.cachedViews = [].concat(state.cachedViews.slice(index, i + 1)) + break + } + } + }, + DEL_ALL_VIEWS: (state) => { + state.visitedViews = [] + state.cachedViews = [] } }, actions: { @@ -40,6 +59,18 @@ const tagsView = { commit('DEL_VISITED_VIEWS', view) resolve([...state.visitedViews]) }) + }, + delOtherViews({ commit, state }, view) { + return new Promise((resolve) => { + commit('DEL_OTHER_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delAllViews({ commit, state }) { + return new Promise((resolve) => { + commit('DEL_ALL_VIEWS') + resolve([...state.visitedViews]) + }) } } } diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue index 7e730280..c06d5979 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -1,139 +1,204 @@