From b6d97f1806cd1501ea78a69063470341d49cc254 Mon Sep 17 00:00:00 2001 From: leij1ang Date: Wed, 13 Dec 2017 17:43:03 +0800 Subject: [PATCH] feat[tags-view]: tags-view add contextmenu (#343) * add the menu by right-clicking the tags * bug fixed * refine --- src/store/modules/tagsView.js | 31 +++ src/views/layout/components/TagsView.vue | 278 ++++++++++++++--------- 2 files changed, 200 insertions(+), 109 deletions(-) diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index eed8b69..1fccaf6 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 7e73028..018e8d4 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -1,139 +1,199 @@ -- GitLab