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
const UserContext={
namespaced: true,
state:{
userName:"",
userId:"",
ptyCode:"",
menu:[],
state:"LOGOUT",
token:"",
homeCellsSetting: {
defaultCells: [],
cellRows: 2,
cellCols: 2,
cellNames: [['QuickVisit', 'TaskStatistics'], ['CustomerAnalyse', 'NoticeAnnouncement']]
}
},
mutations:{
setLoginInfo(state,info){
state.userName = info.userName
state.userId = info.userId
state.ptyCode = info.ptyCode
state.menu = info.menu
state.state = "LOGIN"
state.token = info.token
window.sessionStorage.userId = info.userId
window.sessionStorage.userName = info.userName
window.sessionStorage.token = info.token
},
setLogout(state){
state.userName = ""
state.userId = ""
state.ptyCode = ""
state.menu = []
state.state = "LOGOUT"
state.token = ""
},
setMenu(state, menu) {
state.menu = menu;
},
setHomeCellsSetting(state, setting) {
state.homeCellsSetting.cellRows = setting.cellRows
state.homeCellsSetting.cellCols = setting.cellCols
state.homeCellsSetting.cellNames = setting.cellNames
localStorage.setItem(`cells-setting-${state.userId}`, JSON.stringify(setting));
},
setHomeDefaultCells(state, cells) {
state.homeCellsSetting.defaultCells = cells;
}
}
}
export default UserContext;