1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| import Vue from 'vue'
| import Vuex from 'vuex'
| Vue.use(Vuex)
|
| const store = new Vuex.Store({
| state: {
| menus: localStorage.getItem('menuList') ? JSON.parse(localStorage.getItem('menuList')) : [],
| keepAliveList: localStorage.getItem('keepAliveList') ? JSON.parse(localStorage.getItem('keepAliveList')) : [],//缓存页面
| tagList: localStorage.getItem('tagList') ? JSON.parse(localStorage.getItem('tagList')) : [],//标签列表
| isFold: false,//是否折叠
| },
| mutations: {
| SET_MENUS(state, data) {
| state.menus = data;
| },
| SET_KEEPALIVELIST(state, data) {
| state.keepAliveList = data;
| localStorage.setItem('keepAliveList', JSON.stringify(data));
| },
| SET_TAGLIST(state, data) {
| state.tagList = data;
| localStorage.setItem('tagList', JSON.stringify(data));
| },
| SET_ISFOLD(state, data) {
| state.isFold = data;
| },
| },
| actions: {
| setMenus({ commit }, data) {
| commit('SET_MENUS', data);
| },
| setKeepAliveList({ commit }, data) {
| commit('SET_KEEPALIVELIST', data);
| },
| setTagList({ commit }, data) {
| commit('SET_TAGLIST', data);
| },
| setIsFold({ commit }, data) {
| commit('SET_ISFOLD', data);
| }
| }
| })
|
| export default store
|
|