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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
// import SecureLS from "secure-ls";
// var ls = new SecureLS({ isCompression: false });
import { SessionCrypto } from "@/utils";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
menus: [], // 菜单
token: "",
siteId: "", // 站点id
deptList: [], // 部门列表
sysName: "", // 系统名称
sysLogo: "", // 系统logo
path: "", // 门户跳转过来的路由
},
getters: {
token(state) {
return state.token;
},
siteId(state) {
return state.siteId;
},
deptList(state) {
return state.deptList;
},
path(state) {
return state.path;
},
},
mutations: {
SET_MENUS(state, menus) {
state.menus = menus;
},
SET_SITEID(state, siteId) {
state.siteId = siteId;
},
SET_deptList(state, deptList) {
state.deptList = deptList;
},
SET_sysName(state, sysName) {
state.sysName = sysName;
},
SET_sysLogo(state, sysLogo) {
state.sysLogo = sysLogo;
},
SET_token(state, token) {
state.token = token;
},
SET_path(state, path) {
state.path = path;
},
},
actions: {},
modules: {},
// 持久化插件
plugins: [
// createPersistedState({
// storage: window.sessionStorage,
// }),
createPersistedState({
key: "sample",
storage: {
getItem: (key) => SessionCrypto.getItem(key),
setItem: (key, value) => SessionCrypto.setItem(key, value),
removeItem: (key) => SessionCrypto.remove(key),
},
}),
],
});