-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathstore.js
120 lines (117 loc) · 3.84 KB
/
store.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import Vue from "vue";
import Vuex from "vuex";
import moment from "moment"
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
serverInfo: {},
userInfo: null,
menus: [
{
path: '/',
title: "概览",
icon: 'dashboard',
roles: ['管理员'],
}, {
path: "/devices",
icon: "video-camera",
title: "国标设备",
roles: ['管理员','操作员','观众'],
}, {
path: '/screen',
icon: 'th-large',
title: "分屏展示",
// roles: ['管理员','操作员','观众'],
}, {
path: "/cloudrecord",
icon: "cloud",
title: "云端录像",
versionType: "旗舰版",
roles: ['管理员','操作员','观众'],
}, {
path: "/alarms",
icon: "bell",
title: "报警查询",
roles: ['管理员','操作员'],
}, {
path: "/cascade",
icon: "cloud-upload",
title: "国标级联",
versionType: "旗舰版",
roles: ['管理员'],
}, {
path: "/user",
icon: "users",
title: "用户管理",
roles: ['管理员'],
}, {
path: "/logs",
icon: "file",
title: "操作日志",
roles: ['管理员'],
}, {
path: "/config",
icon: "cogs",
title: "基础配置",
roles: ['管理员'],
}, {
path: "/about",
icon: "support",
title: "版本信息",
roles: ['管理员'],
}
]
},
mutations: {
updateUserInfo(state, userInfo) {
state.userInfo = userInfo;
},
updateServerInfo(state, serverInfo) {
state.serverInfo = serverInfo;
}
},
actions: {
getUserInfo({ commit, state }) {
return new Promise((resolve, reject) => {
$.get("/api/v1/userinfo").then(msg => {
var userInfo = msg;
commit('updateUserInfo', userInfo);
resolve(userInfo);
}).fail(() => {
resolve(null);
})
})
},
logout({ commit, state }) {
return new Promise((resolve, reject) => {
$.get("/api/v1/logout").then(data => {
commit('updateUserInfo', null);
resolve(null);
}).fail(() => {
resolve(null);
})
})
},
getServerInfo({ commit }) {
return new Promise((resolve, reject) => {
$.get("/api/v1/getserverinfo").then(serverInfo => {
try {
if (serverInfo.ServerTime) {
var stime = moment(serverInfo.ServerTime, "YYYY-MM-DD HH:mm:ss");
serverInfo.DiffDuration = moment.duration(stime.diff(moment()))
}
commit('updateServerInfo', serverInfo);
resolve(serverInfo)
return
} catch (error) {
console.log(error)
}
resolve({});
}).fail(() => {
resolve({});
})
})
}
}
})
export default store;