Browse Source

Merge branch 'master' of http://10.1.235.20:3000/asiainfo/ebc

wangchao 4 years ago
parent
commit
fc1350beaa

+ 1 - 1
monitor-manage-service/src/main/java/com/ai/bss/monitorManage/model/FaceResultDto.java

@ -11,6 +11,6 @@ public class FaceResultDto {
11 11
12 12
    private int isMatch;
13 13
14
    private int[] faceBox;
14
    private int[] box;
15 15
16 16
}

+ 1 - 1
monitor-manage-service/src/main/java/com/ai/bss/monitorManage/model/IdenResultDto.java

@ -8,6 +8,6 @@ public class IdenResultDto {
8 8
    private String alarmType;
9 9
    private String alarmMemo;
10 10
    private String alarmEmployeeRoleId;
11
    private int[] alarmBox;
11
    private int[] box;
12 12
13 13
}

+ 34 - 8
monitor-manage-service/src/main/java/com/ai/bss/monitorManage/service/impl/KafkaProcessImpl.java

@ -1,6 +1,7 @@
1 1
package com.ai.bss.monitorManage.service.impl;
2 2
3 3
import java.io.File;
4
import java.math.BigDecimal;
4 5
import java.util.ArrayList;
5 6
import java.util.HashMap;
6 7
import java.util.List;
@ -409,17 +410,17 @@ public class KafkaProcessImpl implements KafkaProcess {
409 410
			JSONObject jsonObject = JSONObject.parseObject(aiResponseData);
410 411
			log.info("AI人脸识别结果: " + aiResponseData);
411 412
412
			if (!"OK".equals(jsonObject.getString("Des")) || !"OK".equals(jsonObject.getString("Status"))) {
413
			if (!"OK".equals(jsonObject.getString("Des")) || !"Ok".equals(jsonObject.getString("Status"))) {
413 414
				log.info("人脸识别返回错误,不推送KAFKA消息");
414 415
				return aiIdenLogDto;
415 416
			}
416 417
417
			if (jsonObject.get("result")==null){
418
			if (jsonObject.get("Result")==null){
418 419
				log.info("人脸识别没有识别到人,不推送KAFKA消息");
419 420
				return aiIdenLogDto;
420 421
			}
421 422
422
			List<Map> resultList = JSONArray.parseArray(jsonObject.getString("result"),Map.class);
423
			List<Map> resultList = JSONArray.parseArray(jsonObject.getString("Result"),Map.class);
423 424
			FaceResultDto resultDto=null;
424 425
425 426
			for (Map resultMap:resultList) {
@ -428,16 +429,33 @@ public class KafkaProcessImpl implements KafkaProcess {
428 429
429 430
				if ("null".equals(faceId)||"Unknow".equals(faceId)){
430 431
					resultDto.setUserId(MonitorManageConsts.alarmEmployeeRoleId);
431
					resultDto.setSimi((float)resultMap.get("score"));
432
433
					BigDecimal score=(BigDecimal)resultMap.get("score");
434
					resultDto.setSimi(score.setScale(4,BigDecimal.ROUND_HALF_UP).floatValue());
432 435
					resultDto.setIsMatch(0);
433
					resultDto.setFaceBox((int[]) resultMap.get("box"));
436
437
					JSONArray boxJSONArray = (JSONArray) resultMap.get("box");
438
					int[] boxIntArr=new int[boxJSONArray.size()];
439
					for(int i = 0;i<boxJSONArray.size();i++){
440
						BigDecimal boxValue=(BigDecimal) boxJSONArray.get(i);
441
						boxIntArr[i] =boxValue.intValue();
442
					}
443
					resultDto.setBox(boxIntArr);
434 444
435 445
					aiIdenLogDto.setIdenResultType(MonitorManageConsts.AI_IDENTIFY_RESULT);
436 446
				}else {
437 447
					resultDto.setUserId(faceId);
438
					resultDto.setSimi((float)resultMap.get("score"));
448
					BigDecimal score=(BigDecimal)resultMap.get("score");
449
					resultDto.setSimi(score.setScale(4,BigDecimal.ROUND_HALF_UP).floatValue());
439 450
					resultDto.setIsMatch(1);
440
					resultDto.setFaceBox((int[]) resultMap.get("box"));
451
452
					JSONArray boxJSONArray = (JSONArray) resultMap.get("box");
453
					int[] boxIntArr=new int[boxJSONArray.size()];
454
					for(int i = 0;i<boxJSONArray.size();i++){
455
						BigDecimal boxValue=(BigDecimal) boxJSONArray.get(i);
456
						boxIntArr[i] =boxValue.intValue();
457
					}
458
					resultDto.setBox(boxIntArr);
441 459
442 460
					aiIdenLogDto.setRelateEmployeeRoleId(faceId);
443 461
					aiIdenLogDto.setIdenResultType(MonitorManageConsts.AI_IDENTIFY_RESULT_ATTENDANCE);
@ -493,7 +511,15 @@ public class KafkaProcessImpl implements KafkaProcess {
493 511
					idenResultDto.setAlarmEmployeeRoleId(MonitorManageConsts.alarmEmployeeRoleId);
494 512
					idenResultDto.setAlarmType(MonitorManageConsts.AI_ALARM_TYPE_STA);
495 513
					idenResultDto.setAlarmMemo("陌生人");
496
					idenResultDto.setAlarmBox((int[]) resultMap.get("box"));
514
515
					JSONArray boxJSONArray = (JSONArray) resultMap.get("box");
516
					int[] boxIntArr=new int[boxJSONArray.size()];
517
					for(int i = 0;i<boxJSONArray.size();i++){
518
						BigDecimal boxValue=(BigDecimal) boxJSONArray.get(i);
519
						boxIntArr[i] =boxValue.intValue();
520
					}
521
					idenResultDto.setBox(boxIntArr);
522
497 523
					idenResultDtoList.add(idenResultDto);
498 524
				}
499 525
			}

+ 18 - 6
security-protection-platform/.aid/aid.js

@ -1,15 +1,15 @@
1 1
const { join } = require('path')
2 2
const { name } = require('../package.json')
3 3
4
function resolve(dir) {
4
function resolve (dir) {
5 5
  return join(__dirname, dir)
6 6
}
7 7
8 8
const subappURL = 'http://localhost:5000/'
9 9
10
function rules(config) {
10
function rules (config) {
11 11
  let rules = config.module.rules.map(v => {
12
    if(v.test.toString() === '/\\.css/') {
12
    if (v.test.toString() === '/\\.css/') {
13 13
      return {
14 14
        test: /\.css/,
15 15
        use: [require.resolve('style-loader'), require.resolve('css-loader')]
@ -42,10 +42,10 @@ module.exports = {
42 42
  cssExt: ".scss", //入口css文件后缀名
43 43
  autocheck: ['aid-elements-desktop', 'aid-font', 'aid-desktop'],
44 44
  strict: false,
45
  beforeDev(config) {
45
  beforeDev (config) {
46 46
    return rules(config)
47 47
  },
48
  beforeBuild(config) {
48
  beforeBuild (config) {
49 49
    let result = rules(config)
50 50
    result.output = {
51 51
      publicPath: '/'
@ -55,5 +55,17 @@ module.exports = {
55 55
  //hmrPath: subappURL, // 作为子应用必须启用
56 56
  //imagePrefix: url => `${subappURL}/asset/image/${url}`, // 作为子应用必须启用
57 57
  //fontPrefix: url => `${subappURL}/asset/font/${url}`, // 作为子应用必须启用
58
  outputPrefix: '/' // 构建后index.html中资源路径的前缀
58
  outputPrefix: '/',// 构建后index.html中资源路径的前缀
59
  proxy: [
60
    {
61
      url: '/sp',
62
      options: {
63
        target: 'http://10.19.90.34:8018',
64
        changeOrigin: true,
65
        pathRewrite: {
66
          '^/sp': '/'
67
        }
68
      }
69
    },
70
  ]
59 71
}

+ 6 - 0
security-protection-platform/src/api/login/index.js

@ -8,6 +8,12 @@ const api = {
8 8
    return $default.post('/sp/login/login', data).then(resp => {
9 9
      return resp.data
10 10
    })
11
  },
12
  // 获取用户菜单权限
13
  findMenus (data) {
14
    return $default.post('/sp/login/findMenus', data).then(resp => {
15
      return resp.data
16
    })
11 17
  }
12 18
}
13 19
export default api

+ 2 - 2
security-protection-platform/src/conf/axios.config.js

@ -39,9 +39,9 @@ const conf = {
39 39
  },
40 40
  root: {
41 41
    default: {
42
      baseURL: 'http://10.19.90.34:8018'
42
      // baseURL: 'http://10.19.90.34:8018'
43 43
      // baseURL: 'http://localhost:8018'
44
      // baseURL: '/'
44
      baseURL: '/sp'
45 45
    },
46 46
    picurl: {
47 47
      baseURL: 'http://10.19.90.34:19000/tool-image/'

+ 0 - 1
security-protection-platform/src/http.js

@ -17,7 +17,6 @@ import { TMessage, GLoading } from 'aid-desktop'
17 17
import config from './conf/axios.config.js'
18 18
/* eslint no-useless-escape: "off" */
19 19
/* eslint no-prototype-builtins: "off" */
20
21 20
/**
22 21
 * 深度合并多个对象,返回合并后的新对象
23 22
 * @private

+ 3 - 0
security-protection-platform/src/main.js

@ -26,6 +26,9 @@ Vue.use(VideoPlayer)
26 26
// const hls = require('videojs-contrib-hls')
27 27
// Vue.use(hls)
28 28
29
import axios from 'axios'
30
axios.defaults.withCredentials = true
31
29 32
// 安装组件库插件
30 33
Vue.use(aid, {
31 34
  local: i18nManager.language,

+ 59 - 36
security-protection-platform/src/modules/login/index.vue

@ -8,28 +8,20 @@
8 8
        <h3 class="welcome">欢迎登录 <span class="system-name">AISI安防一体化管理平台</span></h3>
9 9
        <t-form ref="loginForm" :model="loginForm" :rules="loginFormRules">
10 10
          <t-form-item prop="userName">
11
            <t-input v-model="loginForm.userName" placeholder="admin" icon="user-outline" >
11
            <t-input v-model="loginForm.userName" placeholder="admin" icon="user-outline">
12 12
            </t-input>
13 13
          </t-form-item>
14 14
          <t-form-item prop="password">
15
            <t-input v-model="loginForm.password" placeholder="Abc@1234" type="password" icon="lock-outline" >
15
            <t-input v-model="loginForm.password" placeholder="Abc@1234" type="password" icon="lock-outline">
16 16
            </t-input>
17 17
          </t-form-item>
18 18
          <t-form-item prop="verifyCode">
19
            <t-input v-model="loginForm.verifyCode"
20
                     placeholder="请输入验证码" >
21
              <img slot="append"
22
                   :src="verifiyCode"
23
                   title="点击以刷新验证码"
24
                   style="height:30px; margin: 0 -12px;cursor:pointer"
25
                   @click="onVerifiyCodeClick"/>
19
            <t-input v-model="loginForm.verifyCode" placeholder="请输入验证码">
20
              <img slot="append" :src="verifiyCode" title="点击以刷新验证码" style="height:30px; margin: 0 -12px;cursor:pointer" @click="onVerifiyCodeClick" />
26 21
            </t-input>
27 22
          </t-form-item>
28 23
          <t-form-item class="mb-0">
29
            <t-button :loading="loging"
30
                      color="primary"
31
                      block
32
                      @click="onLoginButtonClick">
24
            <t-button :loading="loging" color="primary" block @click="onLoginButtonClick">
33 25
              <span v-if="!loging">登录</span>
34 26
              <span v-else>正在登录...</span>
35 27
            </t-button>
@ -44,13 +36,14 @@
44 36
import loginbg from '@/assets/images/loginbg.png'
45 37
import verifiyCode from '@/assets/images/verifiyCode.jpg'
46 38
import loginapi from '@/api/login'
39
import store from '@/store'
47 40
48 41
export default {
49 42
  filters: {
50 43
  },
51 44
  components: {
52 45
  },
53
  data() {
46
  data () {
54 47
    return {
55 48
      loginbg: loginbg,
56 49
      loging: false,
@ -77,9 +70,14 @@ export default {
77 70
  computed: {
78 71
  },
79 72
  mounted () {
73
    let userName = localStorage.getItem('userName')
74
    if (userName) {
75
      this.loginForm.userName = userName
76
      this.rememberMe = true
77
    }
80 78
  },
81 79
  methods: {
82
    onVerifiyCodeClick() {
80
    onVerifiyCodeClick () {
83 81
    },
84 82
    onLoginButtonClick () {
85 83
      if (this.loging) {
@ -88,13 +86,38 @@ export default {
88 86
      this.loging = true
89 87
      this.$refs.loginForm.validate((valid) => {
90 88
        if (valid) {
91
          loginapi.doLogin({userCode: this.loginForm.userName, passWord: this.loginForm.password}).then((data) => {
89
          loginapi.doLogin({ userCode: this.loginForm.userName, passWord: this.loginForm.password }).then(async (data) => {
92 90
            this.$store.commit('setLogged', true)
93 91
            if (this.rememberMe) {
94
              localStorage.setItem('userName', data.userName)
92
              localStorage.setItem('userName', data.RESULT.CODE)
95 93
            } else {
96 94
              localStorage.removeItem('userName')
97 95
            }
96
            const res = await loginapi.findMenus({ userCode: data.RESULT.CODE })
97
            var map = new Map()
98
            res.RESULT.forEach(e => {
99
              if (e.ROOT_MENU) {
100
                map.set(e.ROOT_MENU[0].VIEWNAME, e.ROOT_MENU[0].ID)
101
              }
102
              // 第六个考勤报表没有 menu_list
103
              if (e.menu_list) {
104
                map.set(e.menu_list[0].VIEWNAME, e.ID)
105
              }
106
              if (e.child_list) {
107
                const str = e.child_list[0].menu_list[0].VIEWNAME
108
                map.set(str.substr(0, str.indexOf('/', 1)), parseInt(Math.random() * 1000000))
109
                e.child_list.forEach(m => {
110
                  map.set(m.menu_list[0].VIEWNAME, m.ID)
111
                  if (m.child_list) {
112
                    m.child_list.forEach(mn => {
113
                      map.set(mn.menu_list[0].VIEWNAME, mn.ID)
114
                    })
115
                  }
116
                })
117
              }
118
            })
119
            localStorage.setItem('menus', JSON.stringify(map))
120
            sessionStorage.setItem('isLogged', true)
98 121
            this.$router.push({ name: 'dashboard' })
99 122
          }).catch((e) => {
100 123
            this.loging = false
@ -111,42 +134,42 @@ export default {
111 134
</script>
112 135
113 136
<style lang="scss">
114
.index{
115
  height:100vh;
116
  -moz-background-size:100% 100%;
117
  background-size:100% 100%;
118
  .user-form-box{
137
.index {
138
  height: 100vh;
139
  -moz-background-size: 100% 100%;
140
  background-size: 100% 100%;
141
  .user-form-box {
119 142
    padding: 20px 40px 20px 40px;
120 143
    background-color: #003561;
121
    position:fixed;
122
    left:70%;
123
    top:20%;
144
    position: fixed;
145
    left: 70%;
146
    top: 20%;
124 147
    width: 25%;
125 148
    height: 65%;
126
    .from{
149
    .from {
127 150
      width: 100%;
128 151
      height: 100%;
129 152
      .hello {
130
        height:36px;
131
        font-size:26px;
132
        font-weight:500;
153
        height: 36px;
154
        font-size: 26px;
155
        font-weight: 500;
133 156
        color: white;
134
        line-height:36px;
157
        line-height: 36px;
135 158
        margin-bottom: 4px;
136 159
      }
137 160
      .welcome {
138
        height:36px;
139
        font-size:14px;
140
        font-weight:500;
141
        color:rgba(0,0,0,1);
142
        line-height:36px;
161
        height: 36px;
162
        font-size: 14px;
163
        font-weight: 500;
164
        color: rgba(0, 0, 0, 1);
165
        line-height: 36px;
143 166
        margin-bottom: 24px;
144 167
        color: white;
145 168
      }
146 169
      .system-name {
147 170
        font-size: 14px;
148 171
        font-weight: 500;
149
        color: #0079BE;
172
        color: #0079be;
150 173
      }
151 174
    }
152 175
  }

+ 27 - 1
security-protection-platform/src/router.js

@ -27,7 +27,33 @@ export default () => {
27 27
  router.beforeEach(async (to, from, next) => {
28 28
    // TGlobalLoading.start()
29 29
    // const accessRoutes = await store.dispatch('permission/generateRoutes', 'user')
30
    next()
30
    /*
31
     * 在每次视图切换时检查当前用户是否处于登
32
     * 录状态,如果没有登录则跳转到登录视图
33
     * 注意此时是调用getter中的isLogged获
34
     * 取客户端缓存的登录状态。
35
     * 真实登录状态仅在应用初始化和每次服务
36
     * 调用时检查即可,在视图(路由)切换时,
37
     * 为了提升视图切换性能(少请求一次服务),
38
     * 只需要调用getter中的isLogged进行简
39
     * 单客户端判断。
40
     * 参见src/frame.vue和src/store.js文件中的逻辑。
41
     */
42
    let isLogged = router.app.$options.store.getters.getLogged || sessionStorage.getItem('isLogged')
43
    console.log(isLogged)
44
    if (to.meta.ignoreAuth === true) {
45
      if (isLogged === true && to.path === '/login') {
46
        router.replace({ name: 'dashboard' })
47
      } else {
48
        next()
49
      }
50
    } else {
51
      if (isLogged === false) {
52
        router.replace({ name: 'login' })
53
      } else {
54
        next()
55
      }
56
    }
31 57
  })
32 58
33 59
  router.afterEach(() => {

+ 32 - 21
security-protection-platform/src/routes.js

@ -21,7 +21,7 @@ export const constantRoutes = [
21 21
    name: 'login',
22 22
    path: '/login',
23 23
    component: () => import('./modules/login'),
24
    meta: { title: '登录页', icon: 'home', ignoreAuth: true},
24
    meta: { title: '登录页', icon: 'home', ignoreAuth: true },
25 25
    hidden: true
26 26
  },
27 27
  {
@ -37,7 +37,16 @@ export const constantRoutes = [
37 37
        meta: { title: '首页', icon: 'home' }
38 38
      }
39 39
    ]
40
  },
40
  }
41
]
42
43
/**
44
 * asyncRoutes
45
 * the routes that need to be dynamically loaded based on user roles
46
 */
47
// 异步挂载的路由
48
// 动态需要根据权限加载的路由表
49
export const asyncRoutes = [
41 50
  {
42 51
    path: '/videoSurveillance',
43 52
    component: Layout,
@ -60,7 +69,7 @@ export const constantRoutes = [
60 69
  {
61 70
    path: '/access',
62 71
    component: Layout,
63
    meta: { icon: 'file-solution-outline' },
72
    meta: { title: '识别记录', icon: 'file-solution-outline' },
64 73
    children: [
65 74
      {
66 75
        name: 'access',
@ -73,7 +82,7 @@ export const constantRoutes = [
73 82
  {
74 83
    path: '/alarm',
75 84
    component: Layout,
76
    meta: { icon: 'bell' },
85
    meta: { title: '智能报警', icon: 'bell' },
77 86
    children: [
78 87
      {
79 88
        name: 'ai_alarm',
@ -85,7 +94,7 @@ export const constantRoutes = [
85 94
  }, {
86 95
    path: '/workorder',
87 96
    component: Layout,
88
    meta: { icon: 'calendar-outline' },
97
    meta: { title: '假勤管理', icon: 'calendar-outline' },
89 98
    children: [
90 99
      {
91 100
        name: 'workorder',
@ -103,17 +112,18 @@ export const constantRoutes = [
103 112
    children: [
104 113
      {
105 114
        name: 'report',
106
        path: 'report',
115
        path: '/attendance/report',
107 116
        component: () => import(/* webpackChunkName: "report" */ './modules/attendance/report'),
108 117
        meta: { title: '考勤报表' }
109 118
      }, {
110 119
        name: 'abnormal',
111
        path: 'abnormal',
120
        path: '/attendance/abnormal',
112 121
        component: () => import(/* webpackChunkName: "abnormal" */ './modules/attendance/abnormal'),
113 122
        meta: { title: '异常考勤' }
114 123
      }
115 124
    ]
116
  }, {
125
  },
126
  {
117 127
    path: '/system',
118 128
    component: Layout,
119 129
    meta: { title: '系统管理', icon: 'setting' },
@ -122,33 +132,40 @@ export const constantRoutes = [
122 132
    children: [
123 133
      {
124 134
        name: 'sys_devicemana',
125
        path: 'devicemana',
135
        path: '/system/devicemana',
126 136
        component: () => import(/* webpackChunkName: "sys_devicemana" */ './modules/system/devicemana'),
127 137
        meta: { title: '设备管理' }
128 138
      },
129 139
      {
130 140
        name: 'sys_task',
131
        path: 'assignment',
141
        path: '/system/assignment',
132 142
        component: () => import(/* webpackChunkName: "sys__task" */ './modules/system/assignment'),
133 143
        meta: { title: '任务管理' }
134 144
      },
135 145
      {
136 146
        name: 'sys_monitor',
137
        path: 'monitor',
147
        path: '/system/monitor',
138 148
        component: () => import(/* webpackChunkName: "sys_monitor" */ './modules/system/monitor'),
139 149
        meta: { title: '监控布局' }
140 150
      },
141 151
      {
142 152
        name: 'sys_attendance',
143
        path: 'attendance',
153
        path: '/system/attendance',
144 154
        component: () => import(/* webpackChunkName: "sys_attendance" */ './modules/system/attendance'),
145 155
        meta: { title: '考勤配置' }
146
      },
156
      }
157
    ]
158
  },
159
  {
160
    path: '/usermana',
161
    component: Layout,
162
    meta: { title: '用户管理', icon: 'user-outline' },
163
    children: [
147 164
      {
148 165
        name: 'usermana',
149
        path: 'usermana',
166
        path: '/usermana',
150 167
        component: () => import(/* webpackChunkName: "user_rights" */ './modules/usermana'),
151
        meta: { title: '用户管理'}
168
        meta: { title: '用户管理', icon: 'user-outline' }
152 169
      }
153 170
    ]
154 171
  },
@ -161,10 +178,4 @@ export const constantRoutes = [
161 178
  }
162 179
]
163 180
164
/**
165
 * asyncRoutes
166
 * the routes that need to be dynamically loaded based on user roles
167
 */
168
export const asyncRoutes = []
169
170 181
export default constantRoutes.concat(asyncRoutes)

+ 2 - 1
security-protection-platform/src/store/index.js

@ -35,8 +35,9 @@ export default () => {
35 35
      isLogged: false
36 36
    },
37 37
    mutations: {
38
      setLogged(state, token) {
38
      setLogged (state, token) {
39 39
        state.isLogged = token
40
        console.log(token)
40 41
      }
41 42
    }
42 43
  })

+ 54 - 26
security-protection-platform/src/store/modules/permission.js

@ -1,16 +1,22 @@
1 1
import { asyncRoutes, constantRoutes } from '@/routes'
2
3 2
/*
4 3
 * Use meta.role to determine if the current user has permission
5 4
 * @param roles
6 5
 * @param route
7 6
 */
8
function hasPermission(roles, route) {
9
  if (route.meta && route.meta.roles) {
10
    return roles.some(role => route.meta.roles.includes(role))
11
  } else {
12
    return true
13
  }
7
function hasPermission (permission, route) {
8
  // if (route.meta && route.meta.roles) {
9
  //   return roles.some(role => route.meta.roles.includes(role))
10
  // } else {
11
  //   return true
12
  // }
13
  var x = false
14
  permission.forEach(e => {
15
    if (e[0] === route.path) {
16
      x = true
17
    }
18
  })
19
  return x
14 20
}
15 21
16 22
/**
@ -18,20 +24,33 @@ function hasPermission(roles, route) {
18 24
 * @param routes asyncRoutes
19 25
 * @param roles
20 26
 */
21
export function filterAsyncRoutes(routes, roles) {
22
  const res = []
27
// export function filterAsyncRoutes (routes, roles) {
28
//   const res = []
23 29
24
  routes.forEach(route => {
25
    const tmp = { ...route }
26
    if (hasPermission(roles, tmp)) {
27
      if (tmp.children) {
28
        tmp.children = filterAsyncRoutes(tmp.children, roles)
30
//   routes.forEach(route => {
31
//     const tmp = { ...route }
32
//     if (hasPermission(roles, tmp)) {
33
//       if (tmp.children) {
34
//         tmp.children = filterAsyncRoutes(tmp.children, roles)
35
//       }
36
//       res.push(tmp)
37
//     }
38
//   })
39
40
//   return res
41
// }
42
function filterAsyncRoutes (routerMap, roles, map) {
43
  const accessedRouters = routerMap.filter(route => {
44
    // if (hasPermission(roles.permissionList, route) && map[route.path] || route.path === '/') {
45
    if (hasPermission(map, route) || route.path === '/') {
46
      if (route.children && route.children.length) {
47
        route.children = filterAsyncRoutes(route.children, roles, map)
29 48
      }
30
      res.push(tmp)
49
      return true
31 50
    }
51
    return false
32 52
  })
33
34
  return res
53
  return accessedRouters
35 54
}
36 55
37 56
const state = {
@ -47,16 +66,25 @@ const mutations = {
47 66
}
48 67
49 68
const actions = {
50
  generateRoutes({ commit }, roles) {
69
  // generateRoutes ({ commit }, roles) {
70
  //   return new Promise(resolve => {
71
  //     let accessedRoutes
72
  //     if (roles.includes('admin')) {
73
  //       accessedRoutes = asyncRoutes || []
74
  //     } else {
75
  //       accessedRoutes = filterAsyncRoutes(asyncRoutes, roles,menus)
76
  //     }
77
  //     commit('SET_ROUTES', accessedRoutes)
78
  //     resolve(accessedRoutes)
79
  //   })
80
  // }
81
  generateRoutes ({ commit }, roles) {
82
    var menus = JSON.parse(localStorage.getItem('menus'))
51 83
    return new Promise(resolve => {
52
      let accessedRoutes
53
      if (roles.includes('admin')) {
54
        accessedRoutes = asyncRoutes || []
55
      } else {
56
        accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
57
      }
58
      commit('SET_ROUTES', accessedRoutes)
59
      resolve(accessedRoutes)
84
      let accessedRouters
85
      accessedRouters = filterAsyncRoutes(asyncRoutes, roles, menus)
86
      commit('SET_ROUTES', accessedRouters)
87
      resolve()
60 88
    })
61 89
  }
62 90
}