permission.js
1 KB
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
/**
* 权限模块
* 模块功能
* 1.获取菜单权限
* 2.获取设备信息
* 3.获取websocket信息
* 4.初始化加载所需api
*/
import router from '../router'
import store from '../store'
import {faceapi} from './initApi'
import {pushws} from './socket'
router.beforeEach((to, from, next) => {
if (to.path === '/') {
next()
} else {
if (store.getters.permission_routers.length === 0) { //判断当前用户是否拉取了路由
store.dispatch('GetMenuRole').then(res => { //获取菜单
router.addRoutes(res);
pushws();
/**
* 初始化页面所需api
**/
faceapi.setBehaviorLocal();
faceapi.getCodeName();
faceapi.getSite();
faceapi.getOrg();
faceapi.getAddress();
faceapi.getFaceDbData();
faceapi.getProvince();
}).catch(() => {
})
} else {
}
// if (store.getters.dev_unid === ""){ //获取设备信息
// store.dispatch('GetDev')
// }
}
next()
});