From eacc01337f4296280932974aa4d0092566e98435 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 2 Jun 2020 17:13:53 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=B0=E5=BC=80?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8tab=E5=90=8E=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dict.js | 2 +- src/store/modules/tags.js | 16 +++++++----- src/store/modules/user.js | 53 +++++++++++++++++++++------------------ 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/store/modules/dict.js b/src/store/modules/dict.js index 7359a04..6824a25 100644 --- a/src/store/modules/dict.js +++ b/src/store/modules/dict.js @@ -27,7 +27,7 @@ const dict = { routeValue: item.remark, }; }); - setStore({name: 'flowRoutes', content: state.flowRoutes, type: 'session'}) + setStore({name: 'flowRoutes', content: state.flowRoutes}) }, } diff --git a/src/store/modules/tags.js b/src/store/modules/tags.js index 2c076a5..5e0cb94 100644 --- a/src/store/modules/tags.js +++ b/src/store/modules/tags.js @@ -15,7 +15,7 @@ const tagObj = { //处理首个标签 function setFistTag(list) { - if (list.length == 1) { + if (list.length === 1) { list[0].close = false; } else { list.forEach(ele => { @@ -39,22 +39,22 @@ const navs = { mutations: { ADD_TAG: (state, action) => { state.tag = action; - setStore({name: 'tag', content: state.tag, type: 'session'}) + setStore({name: 'tag', content: state.tag}) if (state.tagList.some(ele => diff(ele, action))) return state.tagList.push(action) setFistTag(state.tagList); - setStore({name: 'tagList', content: state.tagList, type: 'session'}) + setStore({name: 'tagList', content: state.tagList}) }, DEL_TAG: (state, action) => { state.tagList = state.tagList.filter(item => { return !diff(item, action); }) setFistTag(state.tagList); - setStore({name: 'tagList', content: state.tagList, type: 'session'}) + setStore({name: 'tagList', content: state.tagList}) }, DEL_ALL_TAG: (state) => { state.tagList = [state.tagWel]; - setStore({name: 'tagList', content: state.tagList, type: 'session'}) + setStore({name: 'tagList', content: state.tagList}) }, DEL_TAG_OTHER: (state) => { state.tagList = state.tagList.filter(item => { @@ -65,8 +65,12 @@ const navs = { } }) setFistTag(state.tagList); - setStore({name: 'tagList', content: state.tagList, type: 'session'}) + setStore({name: 'tagList', content: state.tagList}) }, + SET_TAG_LIST(state, tagList) { + state.tagList = tagList; + setStore({name: 'tagList', content: state.tagList}) + } } } export default navs diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 93e746b..431ff96 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -137,6 +137,7 @@ const user = { commit('SET_MENU_ID', {}); commit('SET_MENU_ALL', []); commit('SET_ROLES', []); + commit('SET_TAG_LIST', []); commit('DEL_ALL_TAG'); commit('CLEAR_LOCK'); removeToken(); @@ -155,6 +156,7 @@ const user = { commit('SET_MENU_ALL', []); commit('SET_MENU', []); commit('SET_ROLES', []); + commit('SET_TAG_LIST', []); commit('DEL_ALL_TAG'); commit('CLEAR_LOCK'); removeToken(); @@ -180,6 +182,7 @@ const user = { menu.forEach(ele => { addPath(ele, true); }); + commit('SET_MENU_ALL', menu) commit('SET_MENU', menu) dispatch('GetButtons'); resolve(menu) @@ -201,35 +204,19 @@ const user = { SET_TOKEN: (state, token) => { setToken(token); state.token = token; - setStore({name: 'token', content: state.token, type: 'session'}) + setStore({name: 'token', content: state.token}) }, SET_MENU_ID(state, menuId) { state.menuId = menuId; - setStore({name: 'menuId', content: state.menuId, type: 'session'}) + setStore({name: 'menuId', content: state.menuId}) }, SET_MENU_ALL: (state, menuAll) => { state.menuAll = menuAll - setStore({name: 'menuAll', content: state.menuAll, type: 'session'}) - }, - SET_REFRESH_TOKEN: (state, refreshToken) => { - setRefreshToken(refreshToken) - state.refreshToken = refreshToken; - setStore({name: 'refreshToken', content: state.refreshToken, type: 'session'}) - }, - SET_TENANT_ID: (state, tenantId) => { - state.tenantId = tenantId; - setStore({name: 'tenantId', content: state.tenantId, type: 'session'}) - }, - SET_USER_INFO: (state, userInfo) => { - if (validatenull(userInfo.avatar)) { - userInfo.avatar = "/img/bg/img-logo.png"; - } - state.userInfo = userInfo; - setStore({name: 'userInfo', content: state.userInfo}) + setStore({name: 'menuAll', content: state.menuAll}) }, SET_MENU: (state, menu) => { state.menu = menu - setStore({name: 'menu', content: state.menu, type: 'session'}) + setStore({name: 'menu', content: state.menu}) if (validatenull(menu)) return; //合并动态路由去重 let menuAll = state.menuAll; @@ -238,14 +225,32 @@ const user = { for (let item1 of menuAll) { let flag = true; for (let item2 of newMenu) { - if (item1.label === item2.label || item1.path === item2.path) { + if (item1.name === item2.name || item1.path === item2.path) { flag = false; } } - if (flag) newMenu.push(item1); + if (flag) { + newMenu.push(item1); + } } state.menuAll = newMenu; - setStore({name: 'menuAll', content: state.menuAll, type: 'session'}) + setStore({name: 'menuAll', content: state.menuAll}) + }, + SET_REFRESH_TOKEN: (state, refreshToken) => { + setRefreshToken(refreshToken) + state.refreshToken = refreshToken; + setStore({name: 'refreshToken', content: state.refreshToken}) + }, + SET_TENANT_ID: (state, tenantId) => { + state.tenantId = tenantId; + setStore({name: 'tenantId', content: state.tenantId}) + }, + SET_USER_INFO: (state, userInfo) => { + if (validatenull(userInfo.avatar)) { + userInfo.avatar = "/img/bg/img-logo.png"; + } + state.userInfo = userInfo; + setStore({name: 'userInfo', content: state.userInfo}) }, SET_ROLES: (state, roles) => { state.roles = roles; @@ -272,7 +277,7 @@ const user = { result.forEach(ele => { state.permission[ele] = true; }); - setStore({name: 'permission', content: state.permission, type: 'session'}) + setStore({name: 'permission', content: state.permission}) } }