ls-pro-common 3.1.41 → 3.1.43

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.
@@ -29,12 +29,19 @@ var ViewDocment = function ViewDocment(props) {
29
29
  setVisible = _useState2[1];
30
30
  var src = useMemo(function () {
31
31
  var token = getCookie('token');
32
- var filename = getUrlQuery(url, 'fileName'); //文件名,上传的文件名为xxx?fileName=xxx.pdf
32
+ var filename = getUrlQuery('fileName', url); //文件名,上传的文件名为xxx?fileName=xxx.pdf
33
33
  if (!filename) {
34
34
  //外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
35
35
  filename = url.split('/').pop() || Date.now().toString(32);
36
36
  }
37
- var doc = base64Encode(url + (url.includes('?') ? '&' : '?') + 'fullfilename=' + filename + '&token=' + token);
37
+ var href = url;
38
+ if (!url.includes('token=')) {
39
+ href = href + (href.includes('?') ? '&' : '?') + 'token=' + token;
40
+ }
41
+ if (!href.includes('fullfilename=')) {
42
+ href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
43
+ }
44
+ var doc = base64Encode(href);
38
45
  // 如果是生产环境,走下载域名,其它环境走原来域名
39
46
  var domain = '';
40
47
  if (location.href.includes('.cloud/') && getCache('exportUrl')) {
package/es/http/index.js CHANGED
@@ -154,7 +154,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
154
154
  ifExpireWarn = true;
155
155
  setCache('expireWarnFlag', '1', true);
156
156
  case 18:
157
- if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
157
+ if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013' || retCode === '9009' && retMsg === '令牌不能为空') && !isMobile) {
158
158
  if (!getCookie('token')) {
159
159
  (window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
160
160
  } else {
@@ -223,7 +223,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
223
223
  setCache('expireWarnFlag', '1', true);
224
224
  case 44:
225
225
  if (_retCode && !status.includes(_retCode)) {
226
- if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
226
+ if ((_retCode === 'timeout' || _retCode === '4011' || _retCode === '9009' && _retMsg === '令牌不能为空') && !isMobile) {
227
227
  if (!getCookie('token')) {
228
228
  (window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
229
229
  } else {
@@ -267,27 +267,26 @@ function ajax(url) {
267
267
  _loading: ''
268
268
  }).replace('&_loading=', '').replace('_loading=', '');
269
269
  }
270
+ var finallyFn = function finallyFn() {
271
+ if (loadText) {
272
+ exitLoading();
273
+ }
274
+ };
270
275
  if (type === 'get') {
271
276
  return request.get(url, {
272
277
  params: params,
273
278
  timeout: timeout
274
- }).finally(function () {
275
- return exitLoading();
276
- });
279
+ }).finally(finallyFn);
277
280
  } else if (type === 'delete') {
278
281
  return request.delete(url, {
279
282
  data: params,
280
283
  timeout: timeout
281
- }).finally(function () {
282
- return exitLoading();
283
- });
284
+ }).finally(finallyFn);
284
285
  } else if (type === 'put') {
285
286
  return request.put(url, {
286
287
  data: params,
287
288
  timeout: timeout
288
- }).finally(function () {
289
- return exitLoading();
290
- });
289
+ }).finally(finallyFn);
291
290
  } else {
292
291
  // 如果sumProperties存在,则添加sumProperties参数到url中
293
292
  if (params.sumProperties && typeof params.sumProperties === 'string') {
@@ -295,15 +294,12 @@ function ajax(url) {
295
294
  sumProperties: params.sumProperties
296
295
  });
297
296
  }
297
+ var requestType = isJson ? 'json' : 'form';
298
298
  return request.post(url, {
299
299
  data: params,
300
300
  timeout: timeout,
301
- requestType: isJson ? 'json' : 'form'
302
- }).finally(function () {
303
- if (loadText) {
304
- exitLoading();
305
- }
306
- });
301
+ requestType: requestType
302
+ }).finally(finallyFn);
307
303
  }
308
304
  }
309
305
  /**
@@ -29,12 +29,19 @@ var ViewDocment = function ViewDocment(props) {
29
29
  setVisible = _useState2[1];
30
30
  var src = useMemo(function () {
31
31
  var token = getCookie('token');
32
- var filename = getUrlQuery(url, 'fileName'); //文件名,上传的文件名为xxx?fileName=xxx.pdf
32
+ var filename = getUrlQuery('fileName', url); //文件名,上传的文件名为xxx?fileName=xxx.pdf
33
33
  if (!filename) {
34
34
  //外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
35
35
  filename = url.split('/').pop() || Date.now().toString(32);
36
36
  }
37
- var doc = base64Encode(url + (url.includes('?') ? '&' : '?') + 'fullfilename=' + filename + '&token=' + token);
37
+ var href = url;
38
+ if (!url.includes('token=')) {
39
+ href = href + (href.includes('?') ? '&' : '?') + 'token=' + token;
40
+ }
41
+ if (!href.includes('fullfilename=')) {
42
+ href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
43
+ }
44
+ var doc = base64Encode(href);
38
45
  // 如果是生产环境,走下载域名,其它环境走原来域名
39
46
  var domain = '';
40
47
  if (location.href.includes('.cloud/') && getCache('exportUrl')) {
package/lib/http/index.js CHANGED
@@ -154,7 +154,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
154
154
  ifExpireWarn = true;
155
155
  setCache('expireWarnFlag', '1', true);
156
156
  case 18:
157
- if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
157
+ if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013' || retCode === '9009' && retMsg === '令牌不能为空') && !isMobile) {
158
158
  if (!getCookie('token')) {
159
159
  (window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
160
160
  } else {
@@ -223,7 +223,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
223
223
  setCache('expireWarnFlag', '1', true);
224
224
  case 44:
225
225
  if (_retCode && !status.includes(_retCode)) {
226
- if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
226
+ if ((_retCode === 'timeout' || _retCode === '4011' || _retCode === '9009' && _retMsg === '令牌不能为空') && !isMobile) {
227
227
  if (!getCookie('token')) {
228
228
  (window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
229
229
  } else {
@@ -267,27 +267,26 @@ function ajax(url) {
267
267
  _loading: ''
268
268
  }).replace('&_loading=', '').replace('_loading=', '');
269
269
  }
270
+ var finallyFn = function finallyFn() {
271
+ if (loadText) {
272
+ exitLoading();
273
+ }
274
+ };
270
275
  if (type === 'get') {
271
276
  return request.get(url, {
272
277
  params: params,
273
278
  timeout: timeout
274
- }).finally(function () {
275
- return exitLoading();
276
- });
279
+ }).finally(finallyFn);
277
280
  } else if (type === 'delete') {
278
281
  return request.delete(url, {
279
282
  data: params,
280
283
  timeout: timeout
281
- }).finally(function () {
282
- return exitLoading();
283
- });
284
+ }).finally(finallyFn);
284
285
  } else if (type === 'put') {
285
286
  return request.put(url, {
286
287
  data: params,
287
288
  timeout: timeout
288
- }).finally(function () {
289
- return exitLoading();
290
- });
289
+ }).finally(finallyFn);
291
290
  } else {
292
291
  // 如果sumProperties存在,则添加sumProperties参数到url中
293
292
  if (params.sumProperties && typeof params.sumProperties === 'string') {
@@ -295,15 +294,12 @@ function ajax(url) {
295
294
  sumProperties: params.sumProperties
296
295
  });
297
296
  }
297
+ var requestType = isJson ? 'json' : 'form';
298
298
  return request.post(url, {
299
299
  data: params,
300
300
  timeout: timeout,
301
- requestType: isJson ? 'json' : 'form'
302
- }).finally(function () {
303
- if (loadText) {
304
- exitLoading();
305
- }
306
- });
301
+ requestType: requestType
302
+ }).finally(finallyFn);
307
303
  }
308
304
  }
309
305
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.1.41",
3
+ "version": "3.1.43",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [