dlt-for-react 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
6
  exports.getRouterAfterLogin = exports.saveRouterAfterLogin = exports.tryAllConfigInfo = exports.tryLoginUserInfo = exports.getDifferDate = exports.refreshToken = exports.userLogout = exports.userLogin = undefined;
7
7
 
@@ -61,172 +61,172 @@ var querystring = require('querystring'); //将POST请求参数转换请求字
61
61
  var hashHistory = (0, _createHashHistory2.default)();
62
62
 
63
63
  var userLogin = exports.userLogin = function userLogin(allMenu, params, func) {
64
- var username = params.username;
65
-
66
- fetch('api/shiro/cache/' + username + '/delete', {
67
- method: "POST",
68
- credentials: "include",
69
- headers: {
70
- "Content-Type": "application/x-www-form-urlencoded",
71
- "X-Requested-With": "XMLHttpRequest"
72
- }
73
- }).then(function () {
74
- fetch("login", {
75
- method: "POST",
76
- credentials: "include",
77
- headers: {
78
- "Content-Type": "application/x-www-form-urlencoded",
79
- "X-Requested-With": "XMLHttpRequest",
80
- "logAppId": "ly-sm",
81
- "gatewayAppId": "ly-sm",
82
- "logServiceId": window.logServiceId
83
- },
84
- body: querystring.stringify(params)
85
- }).then(function (response) {
86
- return response.json();
87
- }).then(function (res) {
88
- //登录成功
89
- if (res.meta && res.meta.statusCode === 200) {
90
- //新网关
91
- if (window.gateway_version === '2') {
92
- var isIacpV3 = window.auth_version === '3';
93
- var authRoute = 'api/authc'; //2.0权限平台的网关路由
94
- if (isIacpV3) {
95
- authRoute = 'api/mssp-user';
96
- }
97
- fetch(authRoute + "/users/current/authority", {
98
- method: "GET",
99
- credentials: "include",
100
- headers: {
101
- "Content-Type": "application/x-www-form-urlencoded",
102
- "X-Requested-With": "XMLHttpRequest",
103
- "gatewayTest": process.env.NODE_ENV === 'development' ? 'true' : 'false'
104
- }
105
- }).then(function (response2) {
106
- return response2.json();
107
- }).then(function (res2) {
108
- if (res2.meta && res2.meta.success) {
109
- var authorization = {};
110
- res2.data.forEach(function (element) {
111
- authorization[element.authorityId] = "";
112
- });
113
- res.data.menus = handleMenus(allMenu, authorization);
114
- res.data.authorization = authorization;
115
- sessionStorage.setItem("userLogin", (0, _stringify2.default)(res.data));
116
- sessionStorage.setItem('access_token', res.data.accessToken);
117
- //刷新token,后续用来刷新token
118
- sessionStorage.setItem('refresh_token', res.data.refreshToken);
119
- //记录用户最后一次操作时间
120
- var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
121
- sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
122
- //跳转到第一个菜单
123
- var nextUrl = res.data.menus[0].url;
124
- if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
125
- nextUrl = res.data.menus[0].children[0].url;
126
- } else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
127
- nextUrl = res.data.menus[0].children[0].children[0].url;
128
- }
129
- var routerAfterLogin = getRouterAfterLogin();
130
- if (routerAfterLogin) {
131
- //如果系统设置了登录后的首页 跳转到该路由
132
- nextUrl = routerAfterLogin;
133
- }
134
- hashHistory.push({
135
- pathname: nextUrl
136
- });
137
- tryAllConfigInfo(function () {});
138
- } else {
139
- _message3.default.error('查询权限信息失败');
140
- }
141
- });
142
- } else {
143
- tryAllConfigInfo(function () {
144
- var authorization = res.data.authorization || {};
145
- res.data.menus = handleMenus(allMenu, authorization);
146
- sessionStorage.setItem("userLogin", (0, _stringify2.default)(res.data));
147
- sessionStorage.setItem('access_token', res.data.tokenId);
148
- //跳转到第一个菜单
149
- var nextUrl = res.data.menus[0].url;
150
- if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
151
- nextUrl = res.data.menus[0].children[0].url;
152
- } else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
153
- nextUrl = res.data.menus[0].children[0].children[0].url;
154
- }
155
- var routerAfterLogin = getRouterAfterLogin();
156
- if (routerAfterLogin) {
157
- //如果系统设置了登录后的首页 跳转到该路由
158
- nextUrl = routerAfterLogin;
159
- }
160
- hashHistory.push({
161
- pathname: nextUrl
162
- });
163
- });
164
- }
165
- } else if (res.meta && res.meta.statusCode === 302) {
166
- if (func) {
167
- func();
168
- }
169
- _message3.default.error("错误代码:302,用户登录状态失效或未登录。请刷新页面,重新登录!");
170
- } else if (res.meta && res.meta.statusCode === 401) {
171
- if (func) {
172
- func();
173
- }
174
- _message3.default.error("错误代码:401,用户没有访问权限。请授权后,重新登录!");
175
- } else if (res.meta && res.meta.statusCode === 500) {
176
- if (func) {
177
- func();
178
- }
179
- _message3.default.error(res.meta.message);
180
- } else {
181
- if (func) {
182
- func();
183
- }
184
- _message3.default.error(res.meta.message);
185
- }
186
- return res;
187
- }).catch(function (error) {
188
- if (func) {
189
- func();
190
- }
191
- // 网络请求失败返回执行该回调函数,得到错误信息
192
- _modal2.default.error({ title: '错误提示', content: '网络请求异常,请联系管理员' });
193
- return error;
194
- });
195
- });
196
- };
197
-
198
- var userLogout = exports.userLogout = function userLogout() {
199
- saveRouterAfterLogin("add");
200
- fetch("logout", {
201
- method: "GET",
202
- credentials: "include",
203
- headers: {
204
- "Content-Type": "application/x-www-form-urlencoded",
205
- "X-Requested-With": "XMLHttpRequest"
206
- }
64
+ var username = params.username;
65
+
66
+ fetch('api/shiro/cache/' + username + '/delete', {
67
+ method: 'POST',
68
+ credentials: 'include',
69
+ headers: {
70
+ 'Content-Type': 'application/x-www-form-urlencoded',
71
+ 'X-Requested-With': 'XMLHttpRequest'
72
+ }
73
+ }).then(function () {
74
+ fetch('login', {
75
+ method: 'POST',
76
+ credentials: 'include',
77
+ headers: {
78
+ 'Content-Type': 'application/x-www-form-urlencoded',
79
+ 'X-Requested-With': 'XMLHttpRequest',
80
+ logAppId: 'ly-sm',
81
+ gatewayAppId: 'ly-sm',
82
+ logServiceId: window.logServiceId
83
+ },
84
+ body: querystring.stringify(params)
207
85
  }).then(function (response) {
208
- return response.json();
86
+ return response.json();
209
87
  }).then(function (res) {
210
- if (res.meta && res.meta.statusCode === 200) {
211
- sessionStorage.removeItem("userLogin");
212
- sessionStorage.removeItem("access_token");
213
- fetch("bpm/rule?wf_num=R_S005_B003"); // 清除bpm cookie,避免切换用户时无法更新
214
- if (window.casStatus && window.casLogoutUrl && window.casLogoutUrl != '') {
215
- window.location = window.casLogoutUrl;
88
+ //登录成功
89
+ if (res.meta && res.meta.statusCode === 200) {
90
+ //新网关
91
+ if (window.gateway_version === '2') {
92
+ var isIacpV3 = window.auth_version === '3';
93
+ var authRoute = 'api/authc'; //2.0权限平台的网关路由
94
+ if (isIacpV3) {
95
+ authRoute = 'api/mssp-user';
96
+ }
97
+ fetch(authRoute + '/users/current/authority', {
98
+ method: 'GET',
99
+ credentials: 'include',
100
+ headers: {
101
+ 'Content-Type': 'application/x-www-form-urlencoded',
102
+ 'X-Requested-With': 'XMLHttpRequest',
103
+ gatewayTest: process.env.NODE_ENV === 'development' ? 'true' : 'false'
104
+ }
105
+ }).then(function (response2) {
106
+ return response2.json();
107
+ }).then(function (res2) {
108
+ if (res2.meta && res2.meta.success) {
109
+ var authorization = {};
110
+ res2.data.forEach(function (element) {
111
+ authorization[element.authorityId] = '';
112
+ });
113
+ res.data.menus = handleMenus(allMenu, authorization);
114
+ res.data.authorization = authorization;
115
+ sessionStorage.setItem('userLogin', (0, _stringify2.default)(res.data));
116
+ sessionStorage.setItem('access_token', res.data.accessToken);
117
+ //刷新token,后续用来刷新token
118
+ sessionStorage.setItem('refresh_token', res.data.refreshToken);
119
+ //记录用户最后一次操作时间
120
+ var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
121
+ sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
122
+ //跳转到第一个菜单
123
+ var nextUrl = res.data.menus[0].url;
124
+ if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
125
+ nextUrl = res.data.menus[0].children[0].url;
126
+ } else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
127
+ nextUrl = res.data.menus[0].children[0].children[0].url;
128
+ }
129
+ var routerAfterLogin = getRouterAfterLogin();
130
+ if (routerAfterLogin) {
131
+ //如果系统设置了登录后的首页 跳转到该路由
132
+ nextUrl = routerAfterLogin;
133
+ }
134
+ hashHistory.push({
135
+ pathname: nextUrl
136
+ });
137
+ tryAllConfigInfo(function () {});
216
138
  } else {
217
- hashHistory.push({
218
- pathname: '/login'
219
- });
139
+ _message3.default.error('查询权限信息失败');
220
140
  }
141
+ });
221
142
  } else {
222
- _message3.default.error("退出登陆失败,请稍后再试一次!");
143
+ tryAllConfigInfo(function () {
144
+ var authorization = res.data.authorization || {};
145
+ res.data.menus = handleMenus(allMenu, authorization);
146
+ sessionStorage.setItem('userLogin', (0, _stringify2.default)(res.data));
147
+ sessionStorage.setItem('access_token', res.data.tokenId);
148
+ //跳转到第一个菜单
149
+ var nextUrl = res.data.menus[0].url;
150
+ if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
151
+ nextUrl = res.data.menus[0].children[0].url;
152
+ } else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
153
+ nextUrl = res.data.menus[0].children[0].children[0].url;
154
+ }
155
+ var routerAfterLogin = getRouterAfterLogin();
156
+ if (routerAfterLogin) {
157
+ //如果系统设置了登录后的首页 跳转到该路由
158
+ nextUrl = routerAfterLogin;
159
+ }
160
+ hashHistory.push({
161
+ pathname: nextUrl
162
+ });
163
+ });
223
164
  }
224
- return res;
165
+ } else if (res.meta && res.meta.statusCode === 302) {
166
+ if (func) {
167
+ func();
168
+ }
169
+ _message3.default.error('错误代码:302,用户登录状态失效或未登录。请刷新页面,重新登录!');
170
+ } else if (res.meta && res.meta.statusCode === 401) {
171
+ if (func) {
172
+ func();
173
+ }
174
+ _message3.default.error('错误代码:401,用户没有访问权限。请授权后,重新登录!');
175
+ } else if (res.meta && res.meta.statusCode === 500) {
176
+ if (func) {
177
+ func();
178
+ }
179
+ _message3.default.error(res.meta.message);
180
+ } else {
181
+ if (func) {
182
+ func();
183
+ }
184
+ _message3.default.error(res.meta.message);
185
+ }
186
+ return res;
225
187
  }).catch(function (error) {
226
- // 网络请求失败返回执行该回调函数,得到错误信息
227
- _modal2.default.error({ title: '错误提示', content: '网络请求异常,请联系管理员' });
228
- return error;
188
+ if (func) {
189
+ func();
190
+ }
191
+ // 网络请求失败返回执行该回调函数,得到错误信息
192
+ _modal2.default.error({ title: '错误提示', content: '网络请求异常,请联系管理员' });
193
+ return error;
229
194
  });
195
+ });
196
+ };
197
+
198
+ var userLogout = exports.userLogout = function userLogout() {
199
+ saveRouterAfterLogin('add');
200
+ fetch('logout', {
201
+ method: 'GET',
202
+ credentials: 'include',
203
+ headers: {
204
+ 'Content-Type': 'application/x-www-form-urlencoded',
205
+ 'X-Requested-With': 'XMLHttpRequest'
206
+ }
207
+ }).then(function (response) {
208
+ return response.json();
209
+ }).then(function (res) {
210
+ if (res.meta && res.meta.statusCode === 200) {
211
+ sessionStorage.removeItem('userLogin');
212
+ sessionStorage.removeItem('access_token');
213
+ fetch('bpm/rule?wf_num=R_S005_B003'); // 清除bpm cookie,避免切换用户时无法更新
214
+ if (window.casStatus && window.casLogoutUrl && window.casLogoutUrl != '') {
215
+ window.location = window.casLogoutUrl;
216
+ } else {
217
+ hashHistory.push({
218
+ pathname: '/login'
219
+ });
220
+ }
221
+ } else {
222
+ _message3.default.error('退出登陆失败,请稍后再试一次!');
223
+ }
224
+ return res;
225
+ }).catch(function (error) {
226
+ // 网络请求失败返回执行该回调函数,得到错误信息
227
+ _modal2.default.error({ title: '错误提示', content: '网络请求异常,请联系管理员' });
228
+ return error;
229
+ });
230
230
  };
231
231
 
232
232
  /**
@@ -235,41 +235,41 @@ var userLogout = exports.userLogout = function userLogout() {
235
235
  * @param callback 回调方法
236
236
  */
237
237
  var refreshToken = exports.refreshToken = function refreshToken(_refreshToken, callback) {
238
- fetch('api/refreshToken?refreshToken=' + _refreshToken, {
239
- method: "GET",
240
- credentials: "include",
241
- headers: {
242
- "Content-Type": "application/x-www-form-urlencoded",
243
- "X-Requested-With": "XMLHttpRequest",
244
- "appId": "ly-zhxg"
245
- }
246
- }).then(function (response) {
247
- return response.json();
248
- }).then(function (res) {
249
- if (res.meta && res.meta.statusCode === 200) {
250
- if (callback && typeof callback === 'function') {
251
- callback(res.data);
252
- }
253
- } else {
254
- //刷新token失败,跳转到登录页面重新登录
255
- userLogout();
256
- }
257
- return res;
258
- }).catch(function (error) {
259
- //刷新token失败,跳转到登录页面重新登录
260
- userLogout();
261
- });
238
+ fetch('api/refreshToken?refreshToken=' + _refreshToken, {
239
+ method: 'GET',
240
+ credentials: 'include',
241
+ headers: {
242
+ 'Content-Type': 'application/x-www-form-urlencoded',
243
+ 'X-Requested-With': 'XMLHttpRequest',
244
+ appId: 'ly-hq'
245
+ }
246
+ }).then(function (response) {
247
+ return response.json();
248
+ }).then(function (res) {
249
+ if (res.meta && res.meta.statusCode === 200) {
250
+ if (callback && typeof callback === 'function') {
251
+ callback(res.data);
252
+ }
253
+ } else {
254
+ //刷新token失败,跳转到登录页面重新登录
255
+ userLogout();
256
+ }
257
+ return res;
258
+ }).catch(function (error) {
259
+ //刷新token失败,跳转到登录页面重新登录
260
+ userLogout();
261
+ });
262
262
  };
263
263
 
264
264
  //获取两个日期的相差秒数
265
265
  var getDifferDate = exports.getDifferDate = function getDifferDate(firstDate, secondDate) {
266
- //1) 将两个日期字符串转化为日期对象
267
- var startDate = new Date(firstDate);
268
- var endDate = new Date(secondDate);
269
- //2) 计算两个日期相差的毫秒数
270
- var msecNum = endDate.getTime() - startDate.getTime();
271
- //3) 计算两个日期相差的天数
272
- return Math.floor(msecNum / parseFloat(1000));
266
+ //1) 将两个日期字符串转化为日期对象
267
+ var startDate = new Date(firstDate);
268
+ var endDate = new Date(secondDate);
269
+ //2) 计算两个日期相差的毫秒数
270
+ var msecNum = endDate.getTime() - startDate.getTime();
271
+ //3) 计算两个日期相差的天数
272
+ return Math.floor(msecNum / parseFloat(1000));
273
273
  };
274
274
 
275
275
  /**
@@ -277,102 +277,101 @@ var getDifferDate = exports.getDifferDate = function getDifferDate(firstDate, se
277
277
  * @param func
278
278
  */
279
279
  var tryLoginUserInfo = exports.tryLoginUserInfo = function tryLoginUserInfo(allMenu, fullPageUrl, func, Authorization) {
280
- //第一步,清空缓存
281
- ////console.info("tryLoginUserInfo执行1");
282
- if (window.gateway_version === '2') {//新网关
283
-
284
- } else {
285
- sessionStorage.removeItem("userLogin");
286
- sessionStorage.removeItem("access_token");
287
- }
288
- sessionStorage.removeItem("fullPageUrl");
289
- sessionStorage.setItem("fullPageUrl", (0, _stringify2.default)(fullPageUrl ? fullPageUrl : []));
290
- sessionStorage.removeItem("statusCode"); // 根据tryLoginUserInfo接口返回的状态码判断是403、404还是500页面
291
- fetch("tryLoginUserInfo", {
292
- method: window.gateway_version === '2' ? "GET" : "POST",
293
- credentials: "include",
294
- headers: {
295
- "Content-Type": "application/x-www-form-urlencoded",
296
- "X-Requested-With": "XMLHttpRequest",
297
- "Authorization": Authorization || '',
298
- "logAppId": "ly-sm",
299
- "gatewayAppId": "ly-sm",
300
- "logServiceId": window.logServiceId
301
- },
302
- redirect: 'manual'
303
- }).then(function (response) {
304
- return response.json();
305
- }).then(function (res) {
306
- ////console.info("tryLoginUserInfo执行5");
307
- if (window.gateway_version === '2') {
308
- if (res.meta && res.meta.statusCode === 200) {
309
- if (res.data) {
310
- var authRoute = 'api/authc'; //2.0权限平台的网关路由
311
- var isIacpV3 = window.auth_version === '3';
312
- if (isIacpV3) {
313
- authRoute = 'api/mssp-user';
314
- }
315
- fetch(authRoute + "/users/current/authority", {
316
- method: "GET",
317
- credentials: "include",
318
- headers: {
319
- "Content-Type": "application/x-www-form-urlencoded",
320
- "X-Requested-With": "XMLHttpRequest",
321
- "gatewayTest": process.env.NODE_ENV === 'development' ? 'true' : 'false'
322
- }
323
- }).then(function (response2) {
324
- return response2.json();
325
- }).then(function (res2) {
326
- if (res2.meta && res2.meta.success) {
327
- var authorization = {};
328
- res2.data.forEach(function (element) {
329
- authorization[element.authorityId] = "";
330
- });
331
- res.data.menus = handleMenus(allMenu, authorization);
332
- res.data.authorization = authorization;
333
- sessionStorage.setItem("userLogin", (0, _stringify2.default)(res.data));
334
- sessionStorage.setItem('access_token', res.data.accessToken);
335
- //刷新token,后续用来刷新token
336
- sessionStorage.setItem('refresh_token', res.data.refreshToken);
337
- //记录用户最后一次操作时间
338
- var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
339
- sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
340
- } else {
341
- _message3.default.error('查询权限信息失败');
342
- }
343
- sso(func, allMenu);
344
- return res;
345
- });
346
- }
347
- } else {
348
- sso(func, allMenu);
349
- sessionStorage.setItem("statusCode", res.meta.statusCode);
350
- return res;
280
+ //第一步,清空缓存
281
+ ////console.info("tryLoginUserInfo执行1");
282
+ if (window.gateway_version === '2') {
283
+ //新网关
284
+ } else {
285
+ sessionStorage.removeItem('userLogin');
286
+ sessionStorage.removeItem('access_token');
287
+ }
288
+ sessionStorage.removeItem('fullPageUrl');
289
+ sessionStorage.setItem('fullPageUrl', (0, _stringify2.default)(fullPageUrl ? fullPageUrl : []));
290
+ sessionStorage.removeItem('statusCode'); // 根据tryLoginUserInfo接口返回的状态码判断是403、404还是500页面
291
+ fetch('tryLoginUserInfo', {
292
+ method: window.gateway_version === '2' ? 'GET' : 'POST',
293
+ credentials: 'include',
294
+ headers: {
295
+ 'Content-Type': 'application/x-www-form-urlencoded',
296
+ 'X-Requested-With': 'XMLHttpRequest',
297
+ Authorization: Authorization || '',
298
+ logAppId: 'ly-sm',
299
+ gatewayAppId: 'ly-sm',
300
+ logServiceId: window.logServiceId
301
+ },
302
+ redirect: 'manual'
303
+ }).then(function (response) {
304
+ return response.json();
305
+ }).then(function (res) {
306
+ ////console.info("tryLoginUserInfo执行5");
307
+ if (window.gateway_version === '2') {
308
+ if (res.meta && res.meta.statusCode === 200) {
309
+ if (res.data) {
310
+ var authRoute = 'api/authc'; //2.0权限平台的网关路由
311
+ var isIacpV3 = window.auth_version === '3';
312
+ if (isIacpV3) {
313
+ authRoute = 'api/mssp-user';
314
+ }
315
+ fetch(authRoute + '/users/current/authority', {
316
+ method: 'GET',
317
+ credentials: 'include',
318
+ headers: {
319
+ 'Content-Type': 'application/x-www-form-urlencoded',
320
+ 'X-Requested-With': 'XMLHttpRequest',
321
+ gatewayTest: process.env.NODE_ENV === 'development' ? 'true' : 'false'
351
322
  }
352
- } else {
353
- ////console.info("tryLoginUserInfo执行5");
354
- if (res.meta && res.meta.statusCode === 200) {
355
- //console.info("tryLoginUserInfo执行3");
356
- if (res.data) {
357
- //console.info("tryLoginUserInfo执行2");
358
- res.data.menus = handleMenus(allMenu, res.data.authorization || {});
359
- sessionStorage.setItem("userLogin", (0, _stringify2.default)(res.data));
360
- sessionStorage.setItem('access_token', Authorization ? Authorization : res.data.tokenId);
361
- }
323
+ }).then(function (response2) {
324
+ return response2.json();
325
+ }).then(function (res2) {
326
+ if (res2.meta && res2.meta.success) {
327
+ var authorization = {};
328
+ res2.data.forEach(function (element) {
329
+ authorization[element.authorityId] = '';
330
+ });
331
+ res.data.menus = handleMenus(allMenu, authorization);
332
+ res.data.authorization = authorization;
333
+ sessionStorage.setItem('userLogin', (0, _stringify2.default)(res.data));
334
+ sessionStorage.setItem('access_token', res.data.accessToken);
335
+ //刷新token,后续用来刷新token
336
+ sessionStorage.setItem('refresh_token', res.data.refreshToken);
337
+ //记录用户最后一次操作时间
338
+ var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
339
+ sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
362
340
  } else {
363
- sessionStorage.setItem("statusCode", res.meta.statusCode);
341
+ _message3.default.error('查询权限信息失败');
364
342
  }
365
- //console.info("tryLoginUserInfo执行4");
366
- sso(func);
343
+ sso(func, allMenu);
367
344
  return res;
345
+ });
368
346
  }
369
- }).catch(function (error) {
370
-
347
+ } else {
371
348
  sso(func, allMenu);
372
- // 网络请求失败返回执行该回调函数,得到错误信息
373
- //Modal.error({ title: '错误提示', content: '网络请求异常,请联系管理员'});
374
- return error;
375
- });
349
+ sessionStorage.setItem('statusCode', res.meta.statusCode);
350
+ return res;
351
+ }
352
+ } else {
353
+ ////console.info("tryLoginUserInfo执行5");
354
+ if (res.meta && res.meta.statusCode === 200) {
355
+ //console.info("tryLoginUserInfo执行3");
356
+ if (res.data) {
357
+ //console.info("tryLoginUserInfo执行2");
358
+ res.data.menus = handleMenus(allMenu, res.data.authorization || {});
359
+ sessionStorage.setItem('userLogin', (0, _stringify2.default)(res.data));
360
+ sessionStorage.setItem('access_token', Authorization ? Authorization : res.data.tokenId);
361
+ }
362
+ } else {
363
+ sessionStorage.setItem('statusCode', res.meta.statusCode);
364
+ }
365
+ //console.info("tryLoginUserInfo执行4");
366
+ sso(func);
367
+ return res;
368
+ }
369
+ }).catch(function (error) {
370
+ sso(func, allMenu);
371
+ // 网络请求失败返回执行该回调函数,得到错误信息
372
+ //Modal.error({ title: '错误提示', content: '网络请求异常,请联系管理员'});
373
+ return error;
374
+ });
376
375
  };
377
376
 
378
377
  /**
@@ -380,306 +379,305 @@ var tryLoginUserInfo = exports.tryLoginUserInfo = function tryLoginUserInfo(allM
380
379
  * @param func
381
380
  */
382
381
  var tryAllConfigInfo = exports.tryAllConfigInfo = function tryAllConfigInfo(func) {
383
- //第一步,清空缓存
384
- sessionStorage.removeItem("nhParams");
385
- //console.info("tryAllConfigInfo执行1");
386
- var tokenId = sessionStorage.getItem('access_token');
387
-
388
- fetch(window.baseUrl + "/proData/queryAllConfig", {
389
- method: "GET",
390
- credentials: "include",
391
- headers: {
392
- "Content-Type": "application/x-www-form-urlencoded",
393
- "X-Requested-With": "XMLHttpRequest",
394
- "Authorization": tokenId || undefined
395
- }
396
- }).then(function (response) {
397
- if (response && response.status === 302) {
398
- if (window.gateway_version === '2') {
399
- //新网关
400
- //网关超时
401
- var _userLogin = sessionStorage.getItem('userLogin') ? JSON.parse(sessionStorage.getItem('userLogin')) : {};
402
- var token = sessionStorage.getItem('refresh_token');
403
- var userLastOperationTime = sessionStorage.getItem('user_last_operation_time');
404
- var expiresIn = _userLogin.expiresIn || 1800;
405
- var userLastOperationTimeStr = userLastOperationTime.replace("/-/g", "/");
406
- //用户最后一次操作时间
407
- var userLastOperationTimeDate = new Date(userLastOperationTimeStr);
408
- //当前时间
409
- var nowDate = new Date();
410
-
411
- //在token超时阈值范围内用户没有任何操作,则直接退出登录,重新登录
412
- var differDate = getDifferDate(userLastOperationTimeDate, nowDate);
413
- if (differDate >= expiresIn) {
414
- userLogout();
415
- } else {
416
- //在token超时阈值范围内用户有操作,则重新生成accessToken
417
- refreshToken(token, function (newAccessToken) {
418
- sessionStorage.removeItem("access_token");
419
- sessionStorage.setItem("access_token", newAccessToken);
420
- //记录用户最后一次操作时间
421
- var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
422
- sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
423
- if (func) {
424
- func();
425
- }
426
- });
427
- }
428
- }
429
- }
430
- return response.json();
431
- }).then(function (res) {
432
- if (res && res.code === 200) {
433
- sessionStorage.setItem("nhParams", (0, _stringify2.default)(res.data));
434
- if (func) {
435
- func();
436
- }
437
- } else if (res && res.meta && res.meta.statusCode === 401) {
438
- // 没有权限时的返回信息格式
382
+ //第一步,清空缓存
383
+ sessionStorage.removeItem('nhParams');
384
+ //console.info("tryAllConfigInfo执行1");
385
+ var tokenId = sessionStorage.getItem('access_token');
386
+
387
+ fetch(window.baseUrl + '/proData/queryAllConfig', {
388
+ method: 'GET',
389
+ credentials: 'include',
390
+ headers: {
391
+ 'Content-Type': 'application/x-www-form-urlencoded',
392
+ 'X-Requested-With': 'XMLHttpRequest',
393
+ Authorization: tokenId || undefined
394
+ }
395
+ }).then(function (response) {
396
+ if (response && response.status === 302) {
397
+ if (window.gateway_version === '2') {
398
+ //新网关
399
+ //网关超时
400
+ var _userLogin = sessionStorage.getItem('userLogin') ? JSON.parse(sessionStorage.getItem('userLogin')) : {};
401
+ var token = sessionStorage.getItem('refresh_token');
402
+ var userLastOperationTime = sessionStorage.getItem('user_last_operation_time');
403
+ var expiresIn = _userLogin.expiresIn || 1800;
404
+ var userLastOperationTimeStr = userLastOperationTime.replace('/-/g', '/');
405
+ //用户最后一次操作时间
406
+ var userLastOperationTimeDate = new Date(userLastOperationTimeStr);
407
+ //当前时间
408
+ var nowDate = new Date();
409
+
410
+ //在token超时阈值范围内用户没有任何操作,则直接退出登录,重新登录
411
+ var differDate = getDifferDate(userLastOperationTimeDate, nowDate);
412
+ if (differDate >= expiresIn) {
413
+ userLogout();
414
+ } else {
415
+ //在token超时阈值范围内用户有操作,则重新生成accessToken
416
+ refreshToken(token, function (newAccessToken) {
417
+ sessionStorage.removeItem('access_token');
418
+ sessionStorage.setItem('access_token', newAccessToken);
419
+ //记录用户最后一次操作时间
420
+ var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
421
+ sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
439
422
  if (func) {
440
- func();
423
+ func();
441
424
  }
442
- _message3.default.error('您没有权限访问该系统');
425
+ });
443
426
  }
444
- return res;
445
- }).catch(function (error) {
446
- // 网络请求失败返回执行该回调函数,得到错误信息
447
- sso(func);
448
- //Modal.error({ title: '错误提示', content: '网络请求异常,请联系管理员'});
449
- return error;
450
- });
427
+ }
428
+ }
429
+ return response.json();
430
+ }).then(function (res) {
431
+ if (res && res.code === 200) {
432
+ sessionStorage.setItem('nhParams', (0, _stringify2.default)(res.data));
433
+ if (func) {
434
+ func();
435
+ }
436
+ } else if (res && res.meta && res.meta.statusCode === 401) {
437
+ // 没有权限时的返回信息格式
438
+ if (func) {
439
+ func();
440
+ }
441
+ _message3.default.error('您没有权限访问该系统');
442
+ }
443
+ return res;
444
+ }).catch(function (error) {
445
+ // 网络请求失败返回执行该回调函数,得到错误信息
446
+ sso(func);
447
+ //Modal.error({ title: '错误提示', content: '网络请求异常,请联系管理员'});
448
+ return error;
449
+ });
451
450
  };
452
451
 
453
452
  //单点登录验证
454
453
  var sso = function sso(func, allMenu) {
455
- //console.info("sso执行1");
456
- var userLogin = sessionStorage.getItem("userLogin");
457
-
458
- if (userLogin) {
459
- //如果已经登录,此时需要获取配置信息
460
- //console.info("sso执行2");
461
- tryAllConfigInfo(function () {
462
- if (func) {
463
- func();
454
+ //console.info("sso执行1");
455
+ var userLogin = sessionStorage.getItem('userLogin');
456
+
457
+ if (userLogin) {
458
+ //如果已经登录,此时需要获取配置信息
459
+ //console.info("sso执行2");
460
+ tryAllConfigInfo(function () {
461
+ if (func) {
462
+ func();
463
+ }
464
+ });
465
+ } else {
466
+ //是否启用单点登录
467
+ if (window.casStatus) {
468
+ var urlencode = require('urlencode');
469
+ //跳转至单点登录验证页面
470
+
471
+ var hasTicket = window.location.hash.indexOf('ticket') != -1;
472
+ var isGatewayV2 = window.gateway_version === '2';
473
+ var isIacpV3 = window.auth_version === '3';
474
+ if (isGatewayV2 && !hasTicket) {
475
+ //新网关
476
+ var service = encodeURIComponent(window.location.origin + window.location.pathname + '#/index');
477
+ var casPreHashUrl = window.location.hash.substr(1); // 缓存单点前的hash路由
478
+ sessionStorage.setItem('casPreHashUrl', casPreHashUrl); // 缓存单点前的hash路由
479
+ window.location.href = window.casLoginUrl + '?service=' + service;
480
+ } else if (isGatewayV2 && hasTicket) {
481
+ var ticket = getHashParam('ticket');
482
+ var originServiceUrl = window.location.origin + window.location.pathname + '#/index';
483
+ var _service = encodeURIComponent(originServiceUrl);
484
+ (0, _NHFetch3.default)('cas/login', 'GET', {
485
+ ticket: ticket,
486
+ serviceUrl: _service
487
+ }).then(function (res) {
488
+ // 登录成功,缓存数据跳转到首页
489
+ if (res.meta && res.meta.statusCode === 200) {
490
+ var authRoute = 'api/authc'; //2.0权限平台的网关路由
491
+ if (isIacpV3) {
492
+ authRoute = 'api/mssp-user';
464
493
  }
465
- });
466
- } else {
467
- //是否启用单点登录
468
- if (window.casStatus) {
469
- var urlencode = require('urlencode');
470
- //跳转至单点登录验证页面
471
-
472
- var hasTicket = window.location.hash.indexOf("ticket") != -1;
473
- var isGatewayV2 = window.gateway_version === '2';
474
- var isIacpV3 = window.auth_version === '3';
475
- if (isGatewayV2 && !hasTicket) {
476
- //新网关
477
- var service = encodeURIComponent(window.location.origin + window.location.pathname + "#/index");
478
- var casPreHashUrl = window.location.hash.substr(1); // 缓存单点前的hash路由
479
- sessionStorage.setItem('casPreHashUrl', casPreHashUrl); // 缓存单点前的hash路由
480
- window.location.href = window.casLoginUrl + "?service=" + service;
481
- } else if (isGatewayV2 && hasTicket) {
482
- var ticket = getHashParam("ticket");
483
- var originServiceUrl = window.location.origin + window.location.pathname + "#/index";
484
- var _service = encodeURIComponent(originServiceUrl);
485
- (0, _NHFetch3.default)("cas/login", 'GET', {
486
- ticket: ticket,
487
- serviceUrl: _service
488
- }).then(function (res) {
489
- // 登录成功,缓存数据跳转到首页
490
- if (res.meta && res.meta.statusCode === 200) {
491
- var authRoute = 'api/authc'; //2.0权限平台的网关路由
492
- if (isIacpV3) {
493
- authRoute = 'api/mssp-user';
494
- }
495
- fetch(authRoute + "/users/current/authority", {
496
- method: "GET",
497
- credentials: "include",
498
- headers: {
499
- "Content-Type": "application/x-www-form-urlencoded",
500
- "X-Requested-With": "XMLHttpRequest",
501
- "gatewayTest": process.env.NODE_ENV === 'development' ? 'true' : 'false'
502
- }
503
- }).then(function (response2) {
504
- return response2.json();
505
- }).then(function (res2) {
506
- if (res2.meta && res2.meta.success) {
507
- var authorization = {};
508
- res2.data.forEach(function (element) {
509
- authorization[element.authorityId] = "";
510
- });
511
- res.data.menus = handleMenus(allMenu, authorization);
512
- res.data.authorization = authorization;
513
- sessionStorage.setItem("userLogin", (0, _stringify2.default)(res.data));
514
- sessionStorage.setItem('access_token', res.data.accessToken);
515
- //刷新token,后续用来刷新token
516
- sessionStorage.setItem('refresh_token', res.data.refreshToken);
517
- //记录用户最后一次操作时间
518
- var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
519
- sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
520
- var _casPreHashUrl = sessionStorage.getItem('casPreHashUrl');
521
- tryAllConfigInfo(function () {
522
- //先查询配置信息
523
- if (_casPreHashUrl) {
524
- // 存在缓存的路由
525
- hashHistory.push({
526
- pathname: _casPreHashUrl
527
- });
528
- sessionStorage.removeItem('casPreHashUrl');
529
- } else {
530
-
531
- var nextUrl = res.data.menus[0].url;
532
- if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
533
- nextUrl = res.data.menus[0].children[0].url;
534
- } else if (res.data.menus[0].children && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
535
- nextUrl = res.data.menus[0].children[0].children[0].url;
536
- }
537
- var routerAfterLogin = getRouterAfterLogin();
538
- if (routerAfterLogin) {
539
- //如果系统设置了登录后的首页 跳转到该路由
540
- nextUrl = routerAfterLogin;
541
- }
542
- hashHistory.push({
543
- pathname: nextUrl
544
- });
545
- }
546
- if (func) {
547
- func();
548
- }
549
- });
550
- } else {
551
- _message3.default.error('查询权限信息失败');
552
- }
553
- });
554
- } else {
555
- // 登录失败,退出认证登录
556
- window.location.href = window.casLogoutUrl + "?service=" + _service;
494
+ fetch(authRoute + '/users/current/authority', {
495
+ method: 'GET',
496
+ credentials: 'include',
497
+ headers: {
498
+ 'Content-Type': 'application/x-www-form-urlencoded',
499
+ 'X-Requested-With': 'XMLHttpRequest',
500
+ gatewayTest: process.env.NODE_ENV === 'development' ? 'true' : 'false'
501
+ }
502
+ }).then(function (response2) {
503
+ return response2.json();
504
+ }).then(function (res2) {
505
+ if (res2.meta && res2.meta.success) {
506
+ var authorization = {};
507
+ res2.data.forEach(function (element) {
508
+ authorization[element.authorityId] = '';
509
+ });
510
+ res.data.menus = handleMenus(allMenu, authorization);
511
+ res.data.authorization = authorization;
512
+ sessionStorage.setItem('userLogin', (0, _stringify2.default)(res.data));
513
+ sessionStorage.setItem('access_token', res.data.accessToken);
514
+ //刷新token,后续用来刷新token
515
+ sessionStorage.setItem('refresh_token', res.data.refreshToken);
516
+ //记录用户最后一次操作时间
517
+ var userLastOperationTime = (0, _moment2.default)().format('YYYY-MM-DD HH:mm:ss');
518
+ sessionStorage.setItem('user_last_operation_time', userLastOperationTime);
519
+ var _casPreHashUrl = sessionStorage.getItem('casPreHashUrl');
520
+ tryAllConfigInfo(function () {
521
+ //先查询配置信息
522
+ if (_casPreHashUrl) {
523
+ // 存在缓存的路由
524
+ hashHistory.push({
525
+ pathname: _casPreHashUrl
526
+ });
527
+ sessionStorage.removeItem('casPreHashUrl');
528
+ } else {
529
+ var nextUrl = res.data.menus[0].url;
530
+ if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && !res.data.menus[0].children[0].children) {
531
+ nextUrl = res.data.menus[0].children[0].url;
532
+ } else if (res.data.menus[0].children && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
533
+ nextUrl = res.data.menus[0].children[0].children[0].url;
557
534
  }
535
+ var routerAfterLogin = getRouterAfterLogin();
536
+ if (routerAfterLogin) {
537
+ //如果系统设置了登录后的首页 跳转到该路由
538
+ nextUrl = routerAfterLogin;
539
+ }
540
+ hashHistory.push({
541
+ pathname: nextUrl
542
+ });
543
+ }
544
+ if (func) {
545
+ func();
546
+ }
558
547
  });
559
- } else {
560
- window.location = window.location.origin + window.location.pathname + 'auth?service=' + urlencode(window.location.origin + window.location.pathname);
561
- }
562
- } else {
563
- if (func) {
564
- func();
565
- }
566
- }
548
+ } else {
549
+ _message3.default.error('查询权限信息失败');
550
+ }
551
+ });
552
+ } else {
553
+ // 登录失败,退出认证登录
554
+ window.location.href = window.casLogoutUrl + '?service=' + _service;
555
+ }
556
+ });
557
+ } else {
558
+ window.location = window.location.origin + window.location.pathname + 'auth?service=' + urlencode(window.location.origin + window.location.pathname);
559
+ }
560
+ } else {
561
+ if (func) {
562
+ func();
563
+ }
567
564
  }
565
+ }
568
566
  };
569
567
 
570
568
  var handleMenus = function handleMenus(allMenu, auths) {
571
- //过滤掉没有权限的菜单
572
- var leftMenu = filterAuthMenus(deepCopy(allMenu), auths);
573
- //过滤掉没有子项的菜单
574
- leftMenu = filteChildrenMenus(leftMenu);
575
- //一个菜单都没有,说明该用户没有访问这个服务的权限
576
- if (leftMenu.length <= 0) {
577
- leftMenu.push({
578
- name: '首页',
579
- key: '403',
580
- url: '/403',
581
- icon: 'home'
582
- });
583
- }
584
- return leftMenu;
569
+ //过滤掉没有权限的菜单
570
+ var leftMenu = filterAuthMenus(deepCopy(allMenu), auths);
571
+ //过滤掉没有子项的菜单
572
+ leftMenu = filteChildrenMenus(leftMenu);
573
+ //一个菜单都没有,说明该用户没有访问这个服务的权限
574
+ if (leftMenu.length <= 0) {
575
+ leftMenu.push({
576
+ name: '首页',
577
+ key: '403',
578
+ url: '/403',
579
+ icon: 'home'
580
+ });
581
+ }
582
+ return leftMenu;
585
583
  };
586
584
 
587
585
  var filteChildrenMenus = function filteChildrenMenus(menus) {
588
- var fitlerMenus = [];
589
- menus.map(function (item, index) {
590
- if (item.children) {
591
- //存在子菜单,只需要处理子菜单即可
592
- item.children = filteChildrenMenus(item.children);
593
- if (item.children.length > 0) {
594
- fitlerMenus.push(item);
595
- }
596
- } else {
597
- fitlerMenus.push(item);
598
- }
599
- return item;
600
- });
601
- return fitlerMenus;
586
+ var fitlerMenus = [];
587
+ menus.map(function (item, index) {
588
+ if (item.children) {
589
+ //存在子菜单,只需要处理子菜单即可
590
+ item.children = filteChildrenMenus(item.children);
591
+ if (item.children.length > 0) {
592
+ fitlerMenus.push(item);
593
+ }
594
+ } else {
595
+ fitlerMenus.push(item);
596
+ }
597
+ return item;
598
+ });
599
+ return fitlerMenus;
602
600
  };
603
601
 
604
602
  var filterAuthMenus = function filterAuthMenus(menus, auths) {
605
- var fitlerMenus = [];
606
- menus.map(function (item) {
607
- item.key = (0, _createUuid3.default)();
608
- if (item.children) {
609
- //存在子菜单,只需要处理子菜单即可
610
- item.children = filterAuthMenus(item.children, auths);
611
- fitlerMenus.push(item);
612
- } else if (item.auth) {
613
- //存在权限判断,此时需要判断用户是否有该权限
614
- if (auths[item.auth] !== undefined) {
615
- fitlerMenus.push(item);
616
- }
617
- } else {
618
- fitlerMenus.push(item);
619
- }
620
- return item;
621
- });
622
- return fitlerMenus;
603
+ var fitlerMenus = [];
604
+ menus.map(function (item) {
605
+ item.key = (0, _createUuid3.default)();
606
+ if (item.children) {
607
+ //存在子菜单,只需要处理子菜单即可
608
+ item.children = filterAuthMenus(item.children, auths);
609
+ fitlerMenus.push(item);
610
+ } else if (item.auth) {
611
+ //存在权限判断,此时需要判断用户是否有该权限
612
+ if (auths[item.auth] !== undefined) {
613
+ fitlerMenus.push(item);
614
+ }
615
+ } else {
616
+ fitlerMenus.push(item);
617
+ }
618
+ return item;
619
+ });
620
+ return fitlerMenus;
623
621
  };
624
622
 
625
623
  // 保存登录后要跳转的页面(userid+页面地址,未登录前只取页面地址)
626
624
  var saveRouterAfterLogin = exports.saveRouterAfterLogin = function saveRouterAfterLogin(action, value) {
627
- var userId = (0, _getLoginUser3.default)().userId;
628
- var projectName = window.location.host + window.location.pathname; // 区分同源项目
629
- projectName = userId ? escape(userId + '-' + projectName) : escape(projectName); // 区分同项目不同用户
630
- var oldData = sessionStorage.getItem('routerAfterLogin') ? JSON.parse(sessionStorage.getItem('routerAfterLogin')) : {};
631
- var currentUrl = value || location.hash.split("#")[1];
632
- var routerAfterLogin = (0, _extends4.default)({}, oldData);
633
- if (action === "add") {
634
- routerAfterLogin = (0, _extends4.default)({}, routerAfterLogin, (0, _defineProperty3.default)({}, projectName, escape(currentUrl)));
635
- } else if (action === "remove") {
636
- delete routerAfterLogin[projectName];
637
- }
638
- sessionStorage.setItem('routerAfterLogin', (0, _stringify2.default)(routerAfterLogin));
625
+ var userId = (0, _getLoginUser3.default)().userId;
626
+ var projectName = window.location.host + window.location.pathname; // 区分同源项目
627
+ projectName = userId ? escape(userId + '-' + projectName) : escape(projectName); // 区分同项目不同用户
628
+ var oldData = sessionStorage.getItem('routerAfterLogin') ? JSON.parse(sessionStorage.getItem('routerAfterLogin')) : {};
629
+ var currentUrl = value || location.hash.split('#')[1];
630
+ var routerAfterLogin = (0, _extends4.default)({}, oldData);
631
+ if (action === 'add') {
632
+ routerAfterLogin = (0, _extends4.default)({}, routerAfterLogin, (0, _defineProperty3.default)({}, projectName, escape(currentUrl)));
633
+ } else if (action === 'remove') {
634
+ delete routerAfterLogin[projectName];
635
+ }
636
+ sessionStorage.setItem('routerAfterLogin', (0, _stringify2.default)(routerAfterLogin));
639
637
  };
640
638
  // 获取登录后要跳转的页面
641
639
  var getRouterAfterLogin = exports.getRouterAfterLogin = function getRouterAfterLogin(field) {
642
- var userId = (0, _getLoginUser3.default)().userId;
643
- var projectName = window.location.host + window.location.pathname;
644
- var name = userId ? escape(userId + '-' + projectName) : escape(projectName);
645
- var routerAfterLogin = sessionStorage.getItem('routerAfterLogin') ? JSON.parse(sessionStorage.getItem('routerAfterLogin')) : {};
646
- var url = field ? routerAfterLogin[field] : routerAfterLogin[name] || routerAfterLogin[escape(projectName)];
647
- url = url ? unescape(url) : url;
648
- return url;
640
+ var userId = (0, _getLoginUser3.default)().userId;
641
+ var projectName = window.location.host + window.location.pathname;
642
+ var name = userId ? escape(userId + '-' + projectName) : escape(projectName);
643
+ var routerAfterLogin = sessionStorage.getItem('routerAfterLogin') ? JSON.parse(sessionStorage.getItem('routerAfterLogin')) : {};
644
+ var url = field ? routerAfterLogin[field] : routerAfterLogin[name] || routerAfterLogin[escape(projectName)];
645
+ url = url ? unescape(url) : url;
646
+ return url;
649
647
  };
650
648
 
651
649
  var deepCopy = function deepCopy(obj) {
652
- if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
653
- return obj;
650
+ if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
651
+ return obj;
652
+ }
653
+
654
+ if (isArrayFn(obj)) {
655
+ var newobj = [];
656
+ for (var i = 0; i < obj.length; i++) {
657
+ newobj.push(deepCopy(obj[i]));
654
658
  }
655
-
656
- if (isArrayFn(obj)) {
657
- var newobj = [];
658
- for (var i = 0; i < obj.length; i++) {
659
- newobj.push(deepCopy(obj[i]));
660
- }
661
- return newobj;
662
- } else {
663
- var _newobj = {};
664
- for (var attr in obj) {
665
- _newobj[attr] = deepCopy(obj[attr]);
666
- }
667
- return _newobj;
659
+ return newobj;
660
+ } else {
661
+ var _newobj = {};
662
+ for (var attr in obj) {
663
+ _newobj[attr] = deepCopy(obj[attr]);
668
664
  }
665
+ return _newobj;
666
+ }
669
667
  };
670
668
 
671
669
  var isArrayFn = function isArrayFn(value) {
672
- if (typeof value === "function") {
673
- return Array.isArray(value);
674
- } else {
675
- return Object.prototype.toString.call(value) === "[object Array]";
676
- }
670
+ if (typeof value === 'function') {
671
+ return Array.isArray(value);
672
+ } else {
673
+ return Object.prototype.toString.call(value) === '[object Array]';
674
+ }
677
675
  };
678
676
 
679
677
  // 获取url参数
680
678
  var getHashParam = function getHashParam(name) {
681
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"),
682
- queryString = window.location.hash.split('?')[1] || '',
683
- result = queryString.match(reg);
684
- return result ? decodeURIComponent(result[2]) : null;
679
+ var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'),
680
+ queryString = window.location.hash.split('?')[1] || '',
681
+ result = queryString.match(reg);
682
+ return result ? decodeURIComponent(result[2]) : null;
685
683
  };