dingxin 6 年之前
父節點
當前提交
037f527fe0
共有 19 個檔案被更改,包括 236 行新增114 行删除
  1. 5
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToUserMapper.java
  2. 31
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java
  3. 6
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/vo/ToUserVO.java
  4. 24
    0
      CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml
  5. 0
    13
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/UserController.java
  6. 7
    1
      CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/UserMapper.java
  7. 0
    9
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IUserService.java
  8. 22
    10
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/UserServiceImpl.java
  9. 6
    1
      CODE/smart-community/property-api/src/main/java/com/community/huiju/vo/UserVO.java
  10. 12
    1
      CODE/smart-community/property-api/src/main/resources/mapper/UserMapper.xml
  11. 33
    3
      VUECODE/smart-operate-manage/src/permission.js
  12. 23
    29
      VUECODE/smart-operate-manage/src/router/index.js
  13. 3
    0
      VUECODE/smart-operate-manage/src/store/modules/app.js
  14. 1
    1
      VUECODE/smart-operate-manage/src/views/layout/components/Sidebar/index.vue
  15. 35
    3
      VUECODE/smart-property-manage/src/permission.js
  16. 22
    28
      VUECODE/smart-property-manage/src/router/index.js
  17. 5
    1
      VUECODE/smart-property-manage/src/store/modules/app.js
  18. 0
    11
      VUECODE/smart-property-manage/src/views/layout/components/AppMain.vue
  19. 1
    1
      VUECODE/smart-property-manage/src/views/layout/components/Sidebar/index.vue

+ 5
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToUserMapper.java 查看文件

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Map;
9 10
 
10 11
 @Mapper
11 12
 public interface ToUserMapper {
@@ -39,5 +40,8 @@ public interface ToUserMapper {
39 40
      * @return
40 41
      */
41 42
     List<ToUser>  selectRole(@Param("id") Integer id);
42
-
43
+	
44
+	List<Map<String, Object>> getPermission(@Param("userId") Integer userId);
45
+    
46
+    List<Map<String, Object>> selectByPermissionList(@Param("array") List<String> parentIdList);
43 47
 }

+ 31
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java 查看文件

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
4 4
 import com.alibaba.fastjson.JSONObject;
5 5
 import com.beust.jcommander.internal.Maps;
6 6
 import com.community.commom.mode.ResponseBean;
7
+import com.community.commom.session.UserElement;
7 8
 import com.community.commom.utils.AccountValidatorUtil;
8 9
 import com.community.huiju.common.code.cache.AppkeyCache;
9 10
 import com.community.huiju.dao.ToSysRoleMapper;
@@ -88,11 +89,40 @@ public class ToUserServerImpl implements IToUserService {
88 89
 
89 90
         List<ToSysRole> sysRoleList = toSysRoleMapper.selectRoleByUserId(userId);
90 91
         toUserVO.setRoles(sysRoleList);
91
-
92
+        // 菜单权限
93
+        toUserVO.setPermissionList(getPermission(userId));
92 94
         response.addSuccess(toUserVO);
93 95
 
94 96
         return response;
95 97
     }
98
+    
99
+    /**
100
+     * 获取当前用户的权限列表
101
+     *
102
+     * @param userId
103
+     * @return
104
+     */
105
+    public List<Map<String, Object>> getPermission(Integer userId) {
106
+        List<Map<String,Object>> permissionList = new ArrayList<>();
107
+        permissionList = toUserMapper.getPermission(userId);
108
+        //构造id集合
109
+        List<String> parentIdList = new ArrayList<>();
110
+        permissionList.forEach(e -> {
111
+            parentIdList.add(e.get("parent_id").toString());
112
+        });
113
+        List<Map<String,Object>> parentPermissionList = toUserMapper.selectByPermissionList(parentIdList);
114
+        //构造权限
115
+        List<Map<String,Object>> allList = new ArrayList<>();
116
+        permissionList.stream().forEach(e -> {
117
+            allList.add(e);
118
+            parentPermissionList.stream().forEach(m -> {
119
+                if (!e.get("id").equals(m.get("id"))){
120
+                    allList.add(m);
121
+                }
122
+            });
123
+        });
124
+        return permissionList;
125
+    }
96 126
 
97 127
     @Override
98 128
     public ResponseBean userList(String parameter) {

+ 6
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/vo/ToUserVO.java 查看文件

@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
7 7
 
8 8
 import java.util.Date;
9 9
 import java.util.List;
10
+import java.util.Map;
10 11
 
11 12
 /**
12 13
  * @author weiximei
@@ -56,5 +57,10 @@ public class ToUserVO {
56 57
 
57 58
     /** 角色 **/
58 59
     private List<ToSysRole> roles;
60
+    
61
+    /**
62
+     * 权限相关
63
+     */
64
+    private List<Map<String,Object>> permissionList;
59 65
 
60 66
 }

+ 24
- 0
CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml 查看文件

@@ -256,4 +256,28 @@
256 256
       LEFT JOIN to_sys_role sr ON to_sys_user_role.role_id = sr.id
257 257
       WHERE tu.id=#{id,jdbcType=INTEGER}
258 258
   </select>
259
+
260
+  <select id="getPermission" resultType="java.util.Map">
261
+        SELECT
262
+            r.id,
263
+            r.menu_name AS menuName,
264
+            r.menu_url AS menuUrl,
265
+            r.parent_id
266
+        FROM
267
+            to_sys_user_role t
268
+            LEFT JOIN to_sys_role_menu m ON t.role_id = m.role_id
269
+            LEFT JOIN to_sys_menu r ON m.menu_id = r.id
270
+            AND r.STATUS = 0
271
+        WHERE
272
+            t.user_id = #{userId}
273
+        GROUP BY
274
+            r.id
275
+    </select>
276
+
277
+  <select id="selectByPermissionList" resultType="java.util.Map">
278
+    SELECT id,menu_name as menuName,menu_url as menuUrl,parent_id FROM to_sys_menu WHERE id in
279
+    <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
280
+      #{item}
281
+    </foreach>
282
+  </select>
259 283
 </mapper>

+ 0
- 13
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/UserController.java 查看文件

@@ -154,19 +154,6 @@ public class UserController extends BaseController {
154 154
 		return responseBean;
155 155
 	}
156 156
 
157
-	@ApiOperation(value = "获取用户权限列表", notes = "获取用户权限列表")
158
-	@ApiImplicitParams({
159
-			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token"),
160
-			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "Login-Type", value = "值为 web"),
161
-	})
162
-	@RequestMapping(value = "/user/permission", method = RequestMethod.GET)
163
-	public ResponseBean getPermission(HttpSession session){
164
-		ResponseBean responseBean = new ResponseBean();
165
-		UserElement userElement = getUserElement(session);
166
-		responseBean = userService.getPermission(userElement);
167
-		return responseBean;
168
-	}
169
-
170 157
 	@ApiOperation(value = "查看所有角色", notes = "查看所有角色")
171 158
 	@ApiImplicitParams({
172 159
 			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )

+ 7
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/UserMapper.java 查看文件

@@ -53,5 +53,11 @@ public interface UserMapper extends BaseMapper<User> {
53 53
      * @return
54 54
      */
55 55
 	List<Map<String, Object>> getPermission(@Param("userId") Integer userId,@Param("communityId") Integer communityId);
56
-
56
+    
57
+    /**
58
+     * 获取父权限
59
+     * @param permissionList
60
+     * @return
61
+     */
62
+    List<Map<String, Object>> selectByPermissionList(@Param("array") List<String> permissionList);
57 63
 }

+ 0
- 9
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IUserService.java 查看文件

@@ -77,15 +77,6 @@ public interface IUserService extends IService<User> {
77 77
      */
78 78
     ResponseBean upDateStatus(String parameter,Integer userID);
79 79
 
80
-    
81
-    /**
82
-     * 获取当前用户的权限列表
83
-     * @param userElement
84
-     * @return
85
-     */
86
-	ResponseBean getPermission(UserElement userElement);
87
-
88
-
89 80
     /**
90 81
      * 获取所有角色
91 82
      * @param parameter

+ 22
- 10
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/UserServiceImpl.java 查看文件

@@ -10,17 +10,12 @@ import com.community.commom.mode.ResponseBean;
10 10
 import com.community.commom.session.UserElement;
11 11
 import com.community.commom.utils.BeanTools;
12 12
 import com.community.huiju.dao.*;
13
-import com.community.huiju.dao.TaUserMapper;
14 13
 import com.community.huiju.dao.UserMapper;
15 14
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
16 15
 import com.community.commom.utils.AccountValidatorUtil;
17 16
 import com.community.huiju.common.code.cache.AppkeyCache;
18 17
 import com.community.huiju.model.*;
19 18
 import com.community.huiju.exception.WisdomException;
20
-import com.community.huiju.model.*;
21
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
22
-import com.community.commom.utils.AccountValidatorUtil;
23
-import com.community.huiju.common.code.cache.AppkeyCache;
24 19
 import com.community.huiju.service.IUserService;
25 20
 import com.community.huiju.vo.UserVO;
26 21
 import com.google.common.collect.Lists;
@@ -125,6 +120,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
125 120
         // 查询该用户的权限
126 121
         // 获取用户权限
127 122
         getUserRole(user,userVO);
123
+        
124
+        // 菜单权限
125
+        userVO.setPermissionList(getPermission(userElement));
128 126
 
129 127
         responseBean.addSuccess(userVO);
130 128
 
@@ -364,13 +362,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
364 362
      * @param userElement
365 363
      * @return
366 364
      */
367
-    @Override
368
-    public ResponseBean getPermission(UserElement userElement) {
369
-        ResponseBean responseBean = new ResponseBean();
365
+    public List<Map<String, Object>> getPermission(UserElement userElement) {
370 366
         List<Map<String,Object>> permissionList = new ArrayList<>();
371 367
         permissionList = userMapper.getPermission(userElement.getId(),userElement.getCommunityId());
372
-        responseBean.addSuccess(permissionList);
373
-        return responseBean;
368
+        //构造id集合
369
+        List<String> parentIdList = new ArrayList<>();
370
+        permissionList.forEach(e -> {
371
+            parentIdList.add(e.get("parent_id").toString());
372
+        });
373
+        List<Map<String,Object>> parentPermissionList = userMapper.selectByPermissionList(parentIdList);
374
+        //构造权限
375
+        List<Map<String,Object>> allList = new ArrayList<>();
376
+        permissionList.stream().forEach(e -> {
377
+            allList.add(e);
378
+            parentPermissionList.stream().forEach(m -> {
379
+                if (!e.get("id").equals(m.get("id"))){
380
+                    allList.add(m);
381
+                }
382
+            });
383
+        });
384
+        
385
+        return permissionList;
374 386
     }
375 387
     
376 388
 

+ 6
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/vo/UserVO.java 查看文件

@@ -6,6 +6,7 @@ import lombok.Data;
6 6
 
7 7
 
8 8
 import java.util.List;
9
+import java.util.Map;
9 10
 
10 11
 @Data
11 12
 public class UserVO extends User {
@@ -38,5 +39,9 @@ public class UserVO extends User {
38 39
      * 角色ID
39 40
      */
40 41
     private String roleId;
41
-
42
+    
43
+    /**
44
+     * 权限相关
45
+     */
46
+    private List<Map<String,Object>> permissionList;
42 47
 }

+ 12
- 1
CODE/smart-community/property-api/src/main/resources/mapper/UserMapper.xml 查看文件

@@ -111,7 +111,10 @@
111 111
 
112 112
     <select id="getPermission" resultType="java.util.Map">
113 113
         SELECT
114
-            t.id,r.menu_name,r.menu_url
114
+            r.id,
115
+            r.menu_name as menuName,
116
+            r.menu_url as menuUrl,
117
+            r.parent_id
115 118
         FROM
116 119
             tp_sys_user_role t
117 120
             LEFT JOIN tp_sys_role_menu m ON t.role_id = m.role_id AND m.community_id = #{communityId}
@@ -119,5 +122,13 @@
119 122
         WHERE
120 123
             t.user_id = #{userId}
121 124
             AND t.community_id = #{communityId}
125
+        GROUP BY r.id
126
+    </select>
127
+
128
+    <select id="selectByPermissionList" resultType="java.util.Map">
129
+        SELECT id,menu_name as menuName,menu_url as menuUrl,parent_id FROM tp_sys_menu WHERE id in
130
+        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
131
+        #{item}
132
+        </foreach>
122 133
     </select>
123 134
 </mapper>

+ 33
- 3
VUECODE/smart-operate-manage/src/permission.js 查看文件

@@ -1,4 +1,4 @@
1
-import router from './router'
1
+import router, { constantRouterMap, currentRouterMap } from './router'
2 2
 import store from './store'
3 3
 import NProgress from 'nprogress' // Progress 进度条
4 4
 import 'nprogress/nprogress.css'// Progress 进度条样式
@@ -16,7 +16,38 @@ router.beforeEach((to, from, next) => {
16 16
     } else {
17 17
       if (store.getters.roles.length === 0) {
18 18
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
19
-          next()
19
+          const rounterMap = []
20
+          const permissionMap = res.data.permissionList
21
+          // 构造父路由
22
+          constantRouterMap.forEach(router => {
23
+            permissionMap.forEach(permission => {
24
+              if (router.name === permission['menuUrl']) {
25
+                rounterMap.push(router)
26
+              }
27
+            })
28
+          })
29
+
30
+          // 构造子路由
31
+          rounterMap.forEach(router => {
32
+            const childMap = []
33
+            router.children.forEach(child => {
34
+              if (child.hidden) {
35
+                childMap.push(child)
36
+              }
37
+              permissionMap.forEach(permission => {
38
+                if (child.name === permission['menuUrl']) {
39
+                  childMap.push(child)
40
+                }
41
+              })
42
+            })
43
+            router.children = childMap
44
+          })
45
+
46
+          router.addRoutes(rounterMap)
47
+
48
+          store.commit('AddRoutes', currentRouterMap.concat(rounterMap))
49
+
50
+          next({ ...to, replace: true })
20 51
         }).catch((err) => {
21 52
           store.dispatch('FedLogOut').then(() => {
22 53
             Message.error(err || 'Verification failed, please login again')
@@ -39,7 +70,6 @@ router.beforeEach((to, from, next) => {
39 70
       NProgress.done()
40 71
     }
41 72
   }
42
-  next()
43 73
 })
44 74
 
45 75
 router.afterEach(() => {

+ 23
- 29
VUECODE/smart-operate-manage/src/router/index.js 查看文件

@@ -22,38 +22,11 @@ import Layout from '../views/layout/Layout'
22 22
   }
23 23
 **/
24 24
 export const constantRouterMap = [
25
-  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
26
-  { path: '/404', component: () => import('@/views/404'), hidden: true },
27
-  {
28
-    path: '/dashboard',
29
-    component: Layout,
30
-    redirect: '/dashboard',
31
-    name: 'Dashboard',
32
-    hidden: true,
33
-    children: [{
34
-      path: 'dashboard',
35
-      component: () => import('@/views/dashboard/index')
36
-    }]
37
-  },
38
-
39
-  {
40
-    path: '/',
41
-    component: Layout,
42
-    redirect: '/index',
43
-    children: [
44
-      {
45
-        path: '',
46
-        component: () => import('@/views/index/index'),
47
-        name: 'index',
48
-        meta: { title: '首页', icon: 'index' }
49
-      }
50
-    ]
51
-  },
52
-
53 25
   {
54 26
     path: '/community',
55 27
     component: Layout,
56 28
     redirect: '/conmmunity/download',
29
+    name: 'community-parent',
57 30
     alwaysShow: true,
58 31
     meta: { title: '社区数据', icon: 'zip' },
59 32
     children: [
@@ -70,6 +43,7 @@ export const constantRouterMap = [
70 43
     path: '/banner',
71 44
     component: Layout,
72 45
     redirect: '/banner/index',
46
+    name: 'banner',
73 47
     alwaysShow: true,
74 48
     meta: { title: '运营数据', icon: 'zip' },
75 49
     children: [
@@ -106,6 +80,7 @@ export const constantRouterMap = [
106 80
     path: '/account',
107 81
     component: Layout,
108 82
     redirect: '/account/index',
83
+    name: 'account',
109 84
     alwaysShow: true,
110 85
     meta: { title: '账号管理', icon: 'zip' },
111 86
     children: [
@@ -157,12 +132,31 @@ export const constantRouterMap = [
157 132
         meta: { title: '添加成员', icon: 'table' }
158 133
       }
159 134
     ]
135
+  }
136
+]
137
+
138
+export const currentRouterMap = [
139
+  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
140
+  { path: '/404', component: () => import('@/views/404'), hidden: true },
141
+  {
142
+    path: '/',
143
+    component: Layout,
144
+    redirect: '/index',
145
+    children: [
146
+      {
147
+        path: '',
148
+        component: () => import('@/views/index/index'),
149
+        name: 'index',
150
+        meta: { title: '首页', icon: 'index' }
151
+      }
152
+    ]
160 153
   },
154
+
161 155
   { path: '*', redirect: '/404', hidden: true }
162 156
 ]
163 157
 
164 158
 export default new Router({
165 159
   // mode: 'history', //后端支持可开
166 160
   scrollBehavior: () => ({ y: 0 }),
167
-  routes: constantRouterMap
161
+  routes: currentRouterMap
168 162
 })

+ 3
- 0
VUECODE/smart-operate-manage/src/store/modules/app.js 查看文件

@@ -9,6 +9,9 @@ const app = {
9 9
     device: 'desktop'
10 10
   },
11 11
   mutations: {
12
+    AddRoutes(state, payload) {
13
+      state.routes = payload
14
+    },
12 15
     TOGGLE_SIDEBAR: state => {
13 16
       if (state.sidebar.opened) {
14 17
         Cookies.set('sidebarStatus', 1)

+ 1
- 1
VUECODE/smart-operate-manage/src/views/layout/components/Sidebar/index.vue 查看文件

@@ -25,7 +25,7 @@ export default {
25 25
       'sidebar'
26 26
     ]),
27 27
     routes() {
28
-      return this.$router.options.routes
28
+      return this.$store.state.app.routes
29 29
     },
30 30
     isCollapse() {
31 31
       return !this.sidebar.opened

+ 35
- 3
VUECODE/smart-property-manage/src/permission.js 查看文件

@@ -1,4 +1,4 @@
1
-import router from './router'
1
+import router, { constantRouterMap, currentRouterMap } from './router'
2 2
 import store from './store'
3 3
 import NProgress from 'nprogress' // Progress 进度条
4 4
 import 'nprogress/nprogress.css'// Progress 进度条样式
@@ -16,7 +16,38 @@ router.beforeEach((to, from, next) => {
16 16
     } else {
17 17
       if (store.getters.roles.length === 0) {
18 18
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
19
-          next()
19
+          const rounterMap = []
20
+          const permissionMap = res.data.permissionList
21
+          // 构造父路由
22
+          constantRouterMap.forEach(router => {
23
+            permissionMap.forEach(permission => {
24
+              if (router.name === permission['menuUrl']) {
25
+                rounterMap.push(router)
26
+              }
27
+            })
28
+          })
29
+
30
+          // 构造子路由
31
+          rounterMap.forEach(router => {
32
+            const childMap = []
33
+            router.children.forEach(child => {
34
+              if (child.hidden) {
35
+                childMap.push(child)
36
+              }
37
+              permissionMap.forEach(permission => {
38
+                if (child.name === permission['menuUrl']) {
39
+                  childMap.push(child)
40
+                }
41
+              })
42
+            })
43
+            router.children = childMap
44
+          })
45
+
46
+          router.addRoutes(rounterMap)
47
+
48
+          store.commit('AddRoutes', currentRouterMap.concat(rounterMap))
49
+
50
+          next({ ...to, replace: true })
20 51
         }).catch((err) => {
21 52
           store.dispatch('FedLogOut').then(() => {
22 53
             Message.error(err || 'Verification failed, please login again')
@@ -35,11 +66,12 @@ router.beforeEach((to, from, next) => {
35 66
     if (whiteList.indexOf(to.path) !== -1) {
36 67
       next()
37 68
     } else {
69
+      console.log('tologin')
70
+
38 71
       next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页
39 72
       NProgress.done()
40 73
     }
41 74
   }
42
-  next()
43 75
 })
44 76
 
45 77
 router.afterEach(() => {

+ 22
- 28
VUECODE/smart-property-manage/src/router/index.js 查看文件

@@ -22,37 +22,11 @@ import Layout from '../views/layout/Layout'
22 22
   }
23 23
 **/
24 24
 export const constantRouterMap = [
25
-  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
26
-  { path: '/404', component: () => import('@/views/404'), hidden: true },
27
-  {
28
-    path: '/dashboard',
29
-    component: Layout,
30
-    redirect: '/dashboard',
31
-    name: 'Dashboard',
32
-    hidden: true,
33
-    children: [{
34
-      path: 'dashboard',
35
-      component: () => import('@/views/dashboard/index')
36
-    }]
37
-  },
38
-
39
-  {
40
-    path: '/',
41
-    component: Layout,
42
-    redirect: '/index',
43
-    children: [
44
-      {
45
-        path: '',
46
-        component: () => import('@/views/index/index'),
47
-        name: 'index',
48
-        meta: { title: '首页', icon: 'index' }
49
-      }
50
-    ]
51
-  },
52 25
   {
53 26
     path: '/building',
54 27
     component: Layout,
55 28
     redirect: '/building/index',
29
+    name: 'building',
56 30
     alwaysShow: true,
57 31
     meta: { title: '业主/楼栋', icon: 'zip' },
58 32
     children: [
@@ -95,6 +69,7 @@ export const constantRouterMap = [
95 69
     path: '/social',
96 70
     component: Layout,
97 71
     redirect: '/social/index',
72
+    name: 'social',
98 73
     alwaysShow: true,
99 74
     meta: { title: '论坛内容', icon: 'zip' },
100 75
     children: [
@@ -178,6 +153,7 @@ export const constantRouterMap = [
178 153
     path: '/account',
179 154
     component: Layout,
180 155
     redirect: '/account/index',
156
+    name: 'account',
181 157
     alwaysShow: true,
182 158
     meta: { title: '账号管理', icon: 'zip' },
183 159
     children: [
@@ -229,6 +205,24 @@ export const constantRouterMap = [
229 205
         meta: { title: '编辑成员', icon: 'table' }
230 206
       }
231 207
     ]
208
+  }
209
+]
210
+
211
+export const currentRouterMap = [
212
+  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
213
+  { path: '/404', component: () => import('@/views/404'), hidden: true },
214
+  {
215
+    path: '/',
216
+    component: Layout,
217
+    redirect: '/index',
218
+    children: [
219
+      {
220
+        path: '',
221
+        component: () => import('@/views/index/index'),
222
+        name: 'index',
223
+        meta: { title: '首页', icon: 'index' }
224
+      }
225
+    ]
232 226
   },
233 227
 
234 228
   { path: '*', redirect: '/404', hidden: true }
@@ -237,5 +231,5 @@ export const constantRouterMap = [
237 231
 export default new Router({
238 232
   // mode: 'history', //后端支持可开
239 233
   scrollBehavior: () => ({ y: 0 }),
240
-  routes: constantRouterMap
234
+  routes: currentRouterMap
241 235
 })

+ 5
- 1
VUECODE/smart-property-manage/src/store/modules/app.js 查看文件

@@ -6,9 +6,13 @@ const app = {
6 6
       opened: !+Cookies.get('sidebarStatus'),
7 7
       withoutAnimation: false
8 8
     },
9
-    device: 'desktop'
9
+    device: 'desktop',
10
+    routes: [],
10 11
   },
11 12
   mutations: {
13
+    AddRoutes(state, payload) {
14
+      state.routes = payload
15
+    },
12 16
     TOGGLE_SIDEBAR: state => {
13 17
       if (state.sidebar.opened) {
14 18
         Cookies.set('sidebarStatus', 1)

+ 0
- 11
VUECODE/smart-property-manage/src/views/layout/components/AppMain.vue 查看文件

@@ -15,17 +15,6 @@ export default {
15 15
     // key() {
16 16
     //   return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
17 17
     // }
18
-  },
19
-  created() {
20
-    this.$store.dispatch('GetPermission').then((res) => {
21
-      if (res.code === '0') {
22
-        alert(1)
23
-      } else {
24
-        this.$message.error(res.message)
25
-      }
26
-    }).catch(() => {
27
-        this.$message.error(res.message)
28
-    })
29 18
   }
30 19
 }
31 20
 </script>

+ 1
- 1
VUECODE/smart-property-manage/src/views/layout/components/Sidebar/index.vue 查看文件

@@ -25,7 +25,7 @@ export default {
25 25
       'sidebar'
26 26
     ]),
27 27
     routes() {
28
-      return this.$router.options.routes
28
+      return this.$store.state.app.routes
29 29
     },
30 30
     isCollapse() {
31 31
       return !this.sidebar.opened