ls-pro-common 3.1.33 → 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.
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +31 -0
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +31 -0
- package/es/components/ViewOffice.d.ts +2 -0
- package/es/components/ViewOffice.js +35 -6
- package/es/http/index.js +4 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/lib/components/ViewOffice.d.ts +2 -0
- package/lib/components/ViewOffice.js +35 -6
- package/lib/http/index.js +4 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/package.json +1 -1
|
@@ -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 } from '../utils';
|
|
10
|
-
|
|
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,15 +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
|
|
31
|
-
|
|
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);
|
|
38
|
+
// 如果是生产环境,走下载域名,其它环境走原来域名
|
|
39
|
+
var domain = '';
|
|
40
|
+
if (location.href.includes('.cloud/') && getCache('exportUrl')) {
|
|
41
|
+
domain = getCache('exportUrl');
|
|
42
|
+
}
|
|
43
|
+
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
32
44
|
}, [url]);
|
|
33
45
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
34
46
|
key: "trigger"
|
|
@@ -41,7 +53,11 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
41
53
|
case 0:
|
|
42
54
|
setVisible(!visible);
|
|
43
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);
|
|
44
|
-
|
|
56
|
+
// 新页签打开
|
|
57
|
+
if (mode === 'urlOpen') {
|
|
58
|
+
window.open(src, '_blank');
|
|
59
|
+
}
|
|
60
|
+
case 3:
|
|
45
61
|
case "end":
|
|
46
62
|
return _context.stop();
|
|
47
63
|
}
|
|
@@ -53,6 +69,19 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
53
69
|
return onClick;
|
|
54
70
|
}()
|
|
55
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
|
+
}
|
|
56
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerDom, props.children, /*#__PURE__*/React.createElement(_Modal, {
|
|
57
86
|
title: title,
|
|
58
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');
|
package/es/utils/index.d.ts
CHANGED
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 } from '../utils';
|
|
10
|
-
|
|
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,15 +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
|
|
31
|
-
|
|
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);
|
|
38
|
+
// 如果是生产环境,走下载域名,其它环境走原来域名
|
|
39
|
+
var domain = '';
|
|
40
|
+
if (location.href.includes('.cloud/') && getCache('exportUrl')) {
|
|
41
|
+
domain = getCache('exportUrl');
|
|
42
|
+
}
|
|
43
|
+
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
32
44
|
}, [url]);
|
|
33
45
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
34
46
|
key: "trigger"
|
|
@@ -41,7 +53,11 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
41
53
|
case 0:
|
|
42
54
|
setVisible(!visible);
|
|
43
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);
|
|
44
|
-
|
|
56
|
+
// 新页签打开
|
|
57
|
+
if (mode === 'urlOpen') {
|
|
58
|
+
window.open(src, '_blank');
|
|
59
|
+
}
|
|
60
|
+
case 3:
|
|
45
61
|
case "end":
|
|
46
62
|
return _context.stop();
|
|
47
63
|
}
|
|
@@ -53,6 +69,19 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
53
69
|
return onClick;
|
|
54
70
|
}()
|
|
55
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
|
+
}
|
|
56
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerDom, props.children, /*#__PURE__*/React.createElement(_Modal, {
|
|
57
86
|
title: title,
|
|
58
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');
|
package/lib/utils/index.d.ts
CHANGED
package/lib/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');
|