|
|
@@ -58,61 +58,61 @@ function render(props = {}) {
|
|
|
* @param {[type]} (to, from, next [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
-router.beforeEach((to, from, next) => {
|
|
|
- let funtionAccessDtos = [];
|
|
|
- if (to.matched.some(function (item) {
|
|
|
-
|
|
|
- // 判断是否需要登录才可以访问
|
|
|
- if (item.meta.loginRequired) {
|
|
|
- if (item.meta.functionAccessArray != undefined || item.meta.functionAccessArray != null) {
|
|
|
- funtionAccessDtos = item.meta.functionAccessArray;
|
|
|
- }
|
|
|
- if (funtionAccessDtos != null) {
|
|
|
- funtionAccessDtos.forEach(funtionAccessDto => {
|
|
|
- if(typeof (funtionAccessDto.itemNo) === 'string'){
|
|
|
- funtionAccessDto.itemNo = [funtionAccessDto.itemNo];
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- return item.meta.loginRequired;
|
|
|
- })) {
|
|
|
- // 判断是否已登录
|
|
|
- var token = $.cookie('token');
|
|
|
- if (token == undefined || token.length == 0) {
|
|
|
- // 如果没有登录则直接返回
|
|
|
- next('/login');
|
|
|
- } else {
|
|
|
-
|
|
|
- console.log(funtionAccessDtos);
|
|
|
- // 判断该路由需要具备”xxx”功能-“x1”功能项,”xxx”功能-“x2“功能项,”yyy”功能-“y1”功能项访问权限的用户才可以访问
|
|
|
- $.ajax({
|
|
|
- url: Common.getApiURL(
|
|
|
- 'RoleResourceV3/canVisitFunctionAccess',
|
|
|
- ),
|
|
|
- type: 'post',
|
|
|
- dataType: 'json',
|
|
|
- contentType: 'application/json',
|
|
|
- data: JSON.stringify(funtionAccessDtos),
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- success: function (data) {
|
|
|
- if (data.errorCode === 0 && data.data === true) {
|
|
|
- next();
|
|
|
- } else {
|
|
|
- next('/desktop/no-role');
|
|
|
- }
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
- },
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
- } else {
|
|
|
- next();
|
|
|
- }
|
|
|
-});
|
|
|
+// router.beforeEach((to, from, next) => {
|
|
|
+// let funtionAccessDtos = [];
|
|
|
+// if (to.matched.some(function (item) {
|
|
|
+
|
|
|
+// // 判断是否需要登录才可以访问
|
|
|
+// if (item.meta.loginRequired) {
|
|
|
+// if (item.meta.functionAccessArray != undefined || item.meta.functionAccessArray != null) {
|
|
|
+// funtionAccessDtos = item.meta.functionAccessArray;
|
|
|
+// }
|
|
|
+// if (funtionAccessDtos != null) {
|
|
|
+// funtionAccessDtos.forEach(funtionAccessDto => {
|
|
|
+// if(typeof (funtionAccessDto.itemNo) === 'string'){
|
|
|
+// funtionAccessDto.itemNo = [funtionAccessDto.itemNo];
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return item.meta.loginRequired;
|
|
|
+// })) {
|
|
|
+// // 判断是否已登录
|
|
|
+// var token = $.cookie('token');
|
|
|
+// if (token == undefined || token.length == 0) {
|
|
|
+// // 如果没有登录则直接返回
|
|
|
+// next('/login');
|
|
|
+// } else {
|
|
|
+
|
|
|
+// console.log(funtionAccessDtos);
|
|
|
+// // 判断该路由需要具备”xxx”功能-“x1”功能项,”xxx”功能-“x2“功能项,”yyy”功能-“y1”功能项访问权限的用户才可以访问
|
|
|
+// $.ajax({
|
|
|
+// url: Common.getApiURL(
|
|
|
+// 'RoleResourceV3/canVisitFunctionAccess',
|
|
|
+// ),
|
|
|
+// type: 'post',
|
|
|
+// dataType: 'json',
|
|
|
+// contentType: 'application/json',
|
|
|
+// data: JSON.stringify(funtionAccessDtos),
|
|
|
+// beforeSend: function (request) {
|
|
|
+// Common.addTokenToRequest(request);
|
|
|
+// },
|
|
|
+// success: function (data) {
|
|
|
+// if (data.errorCode === 0 && data.data === true) {
|
|
|
+// next();
|
|
|
+// } else {
|
|
|
+// next('/desktop/no-role');
|
|
|
+// }
|
|
|
+// },
|
|
|
+// error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
+// Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
+// },
|
|
|
+// });
|
|
|
+
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// next();
|
|
|
+// }
|
|
|
+// });
|
|
|
|
|
|
render({});
|