From 91cb0ac5ca7a819f26eef1eb0ccf883bcfe76524 Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 23 Jun 2017 17:32:52 +0800 Subject: [PATCH] add view tabs --- src/store/getters.js | 1 + src/store/modules/app.js | 17 ++++++++++++++++- src/views/layout/Levelbar.vue | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/store/getters.js b/src/store/getters.js index 4677e6d..4497ba4 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,5 +1,6 @@ const getters = { sidebar: state => state.app.sidebar, + visitedViews: state => state.app.visitedViews, token: state => state.user.token, avatar: state => state.user.avatar, name: state => state.user.name, diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 83049ff..e30ae3b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -6,7 +6,8 @@ const app = { opened: !+Cookies.get('sidebarStatus') }, theme: 'default', - livenewsChannels: Cookies.get('livenewsChannels') || '[]' + livenewsChannels: Cookies.get('livenewsChannels') || '[]', + visitedViews: [] }, mutations: { TOGGLE_SIDEBAR: state => { @@ -16,11 +17,25 @@ const app = { Cookies.set('sidebarStatus', 0); } state.sidebar.opened = !state.sidebar.opened; + }, + ADD_VISITED_VIEWS: (state, view) => { + if (state.visitedViews.includes(view)) return + state.visitedViews.push(view) + }, + DEL_VISITED_VIEWS: (state, view) => { + const index = state.visitedViews.indexOf(view) + state.visitedViews.splice(index, 1) } }, actions: { ToggleSideBar: ({ commit }) => { commit('TOGGLE_SIDEBAR') + }, + addVisitedViews: ({ commit }, view) => { + commit('ADD_VISITED_VIEWS', view) + }, + delVisitedViews: ({ commit }, view) => { + commit('DEL_VISITED_VIEWS', view) } } }; diff --git a/src/views/layout/Levelbar.vue b/src/views/layout/Levelbar.vue index cb40084..af850ff 100644 --- a/src/views/layout/Levelbar.vue +++ b/src/views/layout/Levelbar.vue @@ -4,14 +4,25 @@ {{item.name}} {{item.name}} + + + {{tag.name}} + +