| 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
45
46
47
48
49
 | | const state = { |  |   dict: new Array() |  | } |  | const mutations = { |  |   SET_DICT: (state, { key, value }) => { |  |     if (key !== null && key !== "") { |  |       state.dict.push({ |  |         key: key, |  |         value: value |  |       }) |  |     } |  |   }, |  |   REMOVE_DICT: (state, key) => { |  |     try { |  |       for (let i = 0; i < state.dict.length; i++) { |  |         if (state.dict[i].key == key) { |  |           state.dict.splice(i, i) |  |           return true |  |         } |  |       } |  |     } catch (e) { |  |     } |  |   }, |  |   CLEAN_DICT: (state) => { |  |     state.dict = new Array() |  |   } |  | } |  |   |  | const actions = { |  |   // 设置字典 |  |   setDict({ commit }, data) { |  |     commit('SET_DICT', data) |  |   }, |  |   // 删除字典 |  |   removeDict({ commit }, key) { |  |     commit('REMOVE_DICT', key) |  |   }, |  |   // 清空字典 |  |   cleanDict({ commit }) { |  |     commit('CLEAN_DICT') |  |   } |  | } |  |   |  | export default { |  |   namespaced: true, |  |   state, |  |   mutations, |  |   actions |  | } | 
 |