ls-pro-common 3.1.34 → 3.1.35

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.
@@ -4,6 +4,28 @@
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
6
 
7
+ /*!
8
+ Copyright (c) 2011, Yahoo! Inc. All rights reserved.
9
+ Code licensed under the BSD License:
10
+ http://developer.yahoo.com/yui/license.html
11
+ version: 2.9.0
12
+ */
13
+
14
+ /*! *****************************************************************************
15
+ Copyright (c) Microsoft Corporation. All rights reserved.
16
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
17
+ this file except in compliance with the License. You may obtain a copy of the
18
+ License at http://www.apache.org/licenses/LICENSE-2.0
19
+
20
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
22
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
23
+ MERCHANTABLITY OR NON-INFRINGEMENT.
24
+
25
+ See the Apache Version 2.0 License for specific language governing permissions
26
+ and limitations under the License.
27
+ ***************************************************************************** */
28
+
7
29
  /*! *****************************************************************************
8
30
  Copyright (c) Microsoft Corporation.
9
31
 
@@ -21,6 +43,15 @@ PERFORMANCE OF THIS SOFTWARE.
21
43
 
22
44
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
23
45
 
46
+ /**
47
+ * @fileOverview
48
+ * @name asn1-1.0.js
49
+ * @author Kenji Urushima kenji.urushima@gmail.com
50
+ * @version asn1 1.0.13 (2017-Jun-02)
51
+ * @since jsrsasign 2.1
52
+ * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
53
+ */
54
+
24
55
  /**
25
56
  * @license
26
57
  * Lodash <https://lodash.com/>
@@ -8,5 +8,7 @@ declare const ViewDocment: (props: {
8
8
  children?: React.ReactNode;
9
9
  trigger?: JSX.Element;
10
10
  url: string;
11
+ /** Name 集成方式 modal=弹框,urlOpen=直接通过浏览器新页签打开,iframe=直接集成在页面的iframe中,默认为modal */
12
+ mode?: 'modal' | 'urlOpen' | 'iframe';
11
13
  }) => JSX.Element;
12
14
  export default ViewDocment;
@@ -6,8 +6,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useState, useMemo } from 'react';
8
8
  import { EyeOutlined } from '@ant-design/icons';
9
- import { getCookie, getCache } from '../utils';
10
- // import { base64Encode } from 'ls-pro-tools';
9
+ import { getCookie, getCache, getUrlQuery } from '../utils';
10
+ import { base64Encode } from 'ls-pro-tools';
11
11
  var ViewDocment = function ViewDocment(props) {
12
12
  var _props$open = props.open,
13
13
  open = _props$open === void 0 ? false : _props$open,
@@ -20,20 +20,27 @@ var ViewDocment = function ViewDocment(props) {
20
20
  height = _props$height === void 0 ? '75vh' : _props$height,
21
21
  url = props.url,
22
22
  _props$trigger = props.trigger,
23
- trigger = _props$trigger === void 0 ? /*#__PURE__*/React.createElement(EyeOutlined, null) : _props$trigger;
23
+ trigger = _props$trigger === void 0 ? /*#__PURE__*/React.createElement(EyeOutlined, null) : _props$trigger,
24
+ _props$mode = props.mode,
25
+ mode = _props$mode === void 0 ? 'modal' : _props$mode;
24
26
  var _useState = useState(open),
25
27
  _useState2 = _slicedToArray(_useState, 2),
26
28
  visible = _useState2[0],
27
29
  setVisible = _useState2[1];
28
30
  var src = useMemo(function () {
29
31
  var token = getCookie('token');
30
- var doc = url + (url.includes('?') ? '&' : '?') + 'token=' + token;
32
+ var filename = getUrlQuery(url, 'fileName'); //文件名,上传的文件名为xxx?fileName=xxx.pdf
33
+ if (!filename) {
34
+ //外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
35
+ filename = url.split('/').pop() || Date.now().toString(32);
36
+ }
37
+ var doc = base64Encode(url + (url.includes('?') ? '&' : '?') + 'fullfilename=' + filename + '&token=' + token);
31
38
  // 如果是生产环境,走下载域名,其它环境走原来域名
32
39
  var domain = '';
33
40
  if (location.href.includes('.cloud/') && getCache('exportUrl')) {
34
41
  domain = getCache('exportUrl');
35
42
  }
36
- return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + encodeURIComponent(doc);
43
+ return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
37
44
  }, [url]);
38
45
  var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
39
46
  key: "trigger"
@@ -46,7 +53,11 @@ var ViewDocment = function ViewDocment(props) {
46
53
  case 0:
47
54
  setVisible(!visible);
48
55
  (_trigger$props = trigger.props) === null || _trigger$props === void 0 ? void 0 : (_trigger$props$onClic = _trigger$props.onClick) === null || _trigger$props$onClic === void 0 ? void 0 : _trigger$props$onClic.call(_trigger$props, e);
49
- case 2:
56
+ // 新页签打开
57
+ if (mode === 'urlOpen') {
58
+ window.open(src, '_blank');
59
+ }
60
+ case 3:
50
61
  case "end":
51
62
  return _context.stop();
52
63
  }
@@ -58,6 +69,19 @@ var ViewDocment = function ViewDocment(props) {
58
69
  return onClick;
59
70
  }()
60
71
  })));
72
+ if (mode === 'urlOpen') {
73
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
74
+ } else if (mode === 'iframe') {
75
+ /*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
76
+ className: "view-office-modal",
77
+ style: {
78
+ width: width,
79
+ height: height
80
+ }
81
+ }, /*#__PURE__*/React.createElement("iframe", {
82
+ src: src
83
+ })));
84
+ }
61
85
  return /*#__PURE__*/React.createElement(React.Fragment, null, triggerDom, props.children, /*#__PURE__*/React.createElement(_Modal, {
62
86
  title: title,
63
87
  open: visible,
package/es/http/index.js CHANGED
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { extend } from 'umi-request';
7
- import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
7
+ import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk } from '../utils';
8
8
  //默认超时时间为1分钟
9
9
  var request = extend({
10
10
  timeout: 60000
@@ -89,6 +89,9 @@ request.interceptors.request.use(function (url, options) {
89
89
  }
90
90
 
91
91
  options.headers['terminal'] = 'PC';
92
+ if (isDingtalk) {
93
+ options.headers['terminal'] = 'APP';
94
+ }
92
95
  var expireWarnFlag = getCache('expireWarnFlag', true);
93
96
  options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
94
97
  var token = getCookie('token');
@@ -235,3 +235,4 @@ export declare const downloadFile: (url: string, fileName?: string | undefined,
235
235
  * @param props
236
236
  */
237
237
  export declare const setCurrentResCode: (props: any) => void;
238
+ export declare const isDingtalk: boolean;
package/es/utils/index.js CHANGED
@@ -526,4 +526,5 @@ export var setCurrentResCode = function setCurrentResCode(props) {
526
526
  window.__currentRight__ = getUrlQuery('right', parentParams);
527
527
  window.__currentResRight__ = getUrlQuery('resRight', parentParams);
528
528
  }
529
- };
529
+ };
530
+ export var isDingtalk = (window.navigator.userAgent || '').toLowerCase().includes('dingtalk');
@@ -8,5 +8,7 @@ declare const ViewDocment: (props: {
8
8
  children?: React.ReactNode;
9
9
  trigger?: JSX.Element;
10
10
  url: string;
11
+ /** Name 集成方式 modal=弹框,urlOpen=直接通过浏览器新页签打开,iframe=直接集成在页面的iframe中,默认为modal */
12
+ mode?: 'modal' | 'urlOpen' | 'iframe';
11
13
  }) => JSX.Element;
12
14
  export default ViewDocment;
@@ -6,8 +6,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useState, useMemo } from 'react';
8
8
  import { EyeOutlined } from '@ant-design/icons';
9
- import { getCookie, getCache } from '../utils';
10
- // import { base64Encode } from 'ls-pro-tools';
9
+ import { getCookie, getCache, getUrlQuery } from '../utils';
10
+ import { base64Encode } from 'ls-pro-tools';
11
11
  var ViewDocment = function ViewDocment(props) {
12
12
  var _props$open = props.open,
13
13
  open = _props$open === void 0 ? false : _props$open,
@@ -20,20 +20,27 @@ var ViewDocment = function ViewDocment(props) {
20
20
  height = _props$height === void 0 ? '75vh' : _props$height,
21
21
  url = props.url,
22
22
  _props$trigger = props.trigger,
23
- trigger = _props$trigger === void 0 ? /*#__PURE__*/React.createElement(EyeOutlined, null) : _props$trigger;
23
+ trigger = _props$trigger === void 0 ? /*#__PURE__*/React.createElement(EyeOutlined, null) : _props$trigger,
24
+ _props$mode = props.mode,
25
+ mode = _props$mode === void 0 ? 'modal' : _props$mode;
24
26
  var _useState = useState(open),
25
27
  _useState2 = _slicedToArray(_useState, 2),
26
28
  visible = _useState2[0],
27
29
  setVisible = _useState2[1];
28
30
  var src = useMemo(function () {
29
31
  var token = getCookie('token');
30
- var doc = url + (url.includes('?') ? '&' : '?') + 'token=' + token;
32
+ var filename = getUrlQuery(url, 'fileName'); //文件名,上传的文件名为xxx?fileName=xxx.pdf
33
+ if (!filename) {
34
+ //外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
35
+ filename = url.split('/').pop() || Date.now().toString(32);
36
+ }
37
+ var doc = base64Encode(url + (url.includes('?') ? '&' : '?') + 'fullfilename=' + filename + '&token=' + token);
31
38
  // 如果是生产环境,走下载域名,其它环境走原来域名
32
39
  var domain = '';
33
40
  if (location.href.includes('.cloud/') && getCache('exportUrl')) {
34
41
  domain = getCache('exportUrl');
35
42
  }
36
- return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + encodeURIComponent(doc);
43
+ return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
37
44
  }, [url]);
38
45
  var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
39
46
  key: "trigger"
@@ -46,7 +53,11 @@ var ViewDocment = function ViewDocment(props) {
46
53
  case 0:
47
54
  setVisible(!visible);
48
55
  (_trigger$props = trigger.props) === null || _trigger$props === void 0 ? void 0 : (_trigger$props$onClic = _trigger$props.onClick) === null || _trigger$props$onClic === void 0 ? void 0 : _trigger$props$onClic.call(_trigger$props, e);
49
- case 2:
56
+ // 新页签打开
57
+ if (mode === 'urlOpen') {
58
+ window.open(src, '_blank');
59
+ }
60
+ case 3:
50
61
  case "end":
51
62
  return _context.stop();
52
63
  }
@@ -58,6 +69,19 @@ var ViewDocment = function ViewDocment(props) {
58
69
  return onClick;
59
70
  }()
60
71
  })));
72
+ if (mode === 'urlOpen') {
73
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
74
+ } else if (mode === 'iframe') {
75
+ /*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
76
+ className: "view-office-modal",
77
+ style: {
78
+ width: width,
79
+ height: height
80
+ }
81
+ }, /*#__PURE__*/React.createElement("iframe", {
82
+ src: src
83
+ })));
84
+ }
61
85
  return /*#__PURE__*/React.createElement(React.Fragment, null, triggerDom, props.children, /*#__PURE__*/React.createElement(_Modal, {
62
86
  title: title,
63
87
  open: visible,
package/lib/http/index.js CHANGED
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { extend } from 'umi-request';
7
- import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
7
+ import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk } from '../utils';
8
8
  //默认超时时间为1分钟
9
9
  var request = extend({
10
10
  timeout: 60000
@@ -89,6 +89,9 @@ request.interceptors.request.use(function (url, options) {
89
89
  }
90
90
 
91
91
  options.headers['terminal'] = 'PC';
92
+ if (isDingtalk) {
93
+ options.headers['terminal'] = 'APP';
94
+ }
92
95
  var expireWarnFlag = getCache('expireWarnFlag', true);
93
96
  options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
94
97
  var token = getCookie('token');
@@ -235,3 +235,4 @@ export declare const downloadFile: (url: string, fileName?: string | undefined,
235
235
  * @param props
236
236
  */
237
237
  export declare const setCurrentResCode: (props: any) => void;
238
+ export declare const isDingtalk: boolean;
@@ -526,4 +526,5 @@ export var setCurrentResCode = function setCurrentResCode(props) {
526
526
  window.__currentRight__ = getUrlQuery('right', parentParams);
527
527
  window.__currentResRight__ = getUrlQuery('resRight', parentParams);
528
528
  }
529
- };
529
+ };
530
+ export var isDingtalk = (window.navigator.userAgent || '').toLowerCase().includes('dingtalk');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.1.34",
3
+ "version": "3.1.35",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [