From 2079ba28f20bde46f7736699c97abf0e1564770d Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期一, 14 十月 2024 09:30:46 +0800 Subject: [PATCH] 最新版本 --- admin/src/store/index.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/admin/src/store/index.js b/admin/src/store/index.js index 3be2adb..c66e8e3 100644 --- a/admin/src/store/index.js +++ b/admin/src/store/index.js @@ -5,6 +5,7 @@ const state = { // 鐧诲綍鐢ㄦ埛淇℃伅 userInfo: null, + primaryColor: '#2080f7', // 棣栭〉 homePage: null, // 鑿滃崟 @@ -13,7 +14,11 @@ list: [], // 鏄惁鏀惰捣 collapse: false - } + }, + // tags鏁扮粍 + tags: [], + // tagsview鏍囩鏄剧ず闅愯棌 + isCollapse: false } const mutations = { @@ -28,8 +33,16 @@ }, // 璁剧疆宸茬櫥褰曠殑鐢ㄦ埛淇℃伅 setUserInfo: (state, data) => { - state.userInfo = data + state.userInfo = { + ...state.userInfo, + ...data + } }, + + clearUserInfo: (state) => { + state.userInfo = null + }, + // 璁剧疆棣栭〉璺敱淇℃伅 setHomePage (state, homePage) { state.homePage = homePage @@ -37,6 +50,37 @@ // 閲嶇疆鑿滃崟 resetMenus: (state) => { state.menuData.list = [] + }, + // tags + pushtags (state, val) { + // 濡傛灉绛変簬-1璇存槑tabs涓嶅瓨鍦ㄩ偅涔堟彃鍏ワ紝鍚﹀垯浠�涔堥兘涓嶅仛 + // findindex鎵捐鏍囷紝寰幆鍒ゆ柇涓�涓嬶紝濡傛灉绛変簬閭d箞灏变唬琛ㄦ湁鐩稿悓鐨勶紝灏变笉蹇呮坊鍔狅紝濡傛灉鎵句笉鍒伴偅灏辨槸-1.灏辨坊鍔� + const result = state.tags.findIndex(item => item.index === val.index) + if (result === -1) { + state.tags.push({ ...val, keepAlive: false }) + } else { + state.tags[result] = { ...val, keepAlive: true } + } + // result === -1 ? state.tags.push(val) : (state.tags[result]==val) + }, + // 鍏抽棴鏍囩 + closeTab (state, val) { + // 鍚屼笂锛屾壘瑙掓爣锛岀劧鍚庣敤瑙掓爣鐨勪綅缃搴斿垹闄や竴浣嶃�俿plice锛氳繖鏄暟缁勭殑鍒犻櫎鏂规硶 + const result = state.tags.findIndex(item => item.index === val.index) + state.tags.splice(result, 1) + }, + // 鍏抽棴鎵�鏈塼agsview鏍囩 + cleartagsview (state, val) { + // 娓呯┖鏁扮粍 + state.tags = [] + // 璺宠浆鍒伴椤�,val鎺ュ彈浼犺繃鏉ョ殑褰撳墠璺敱 + if (val !== '/index') { + router.push({ path: '/index' }) + } + }, + // 鏀瑰彉tagsview鏄剧ず闅愯棌 + changeisshow (state) { + state.isCollapse = !state.isCollapse } } const actions = {} -- Gitblit v1.9.3