ls-pro-common 3.1.57 → 3.1.58
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.css +3887 -2605
- package/dist/common.js +1 -1
- package/dist/common.min.css +3887 -2605
- package/dist/common.min.js +1 -1
- package/es/components/ImageSelector.js +3 -2
- package/es/utils/pasteUpload.d.ts +13 -13
- package/es/utils/pasteUpload.js +31 -29
- package/lib/components/ImageSelector.js +3 -2
- package/lib/utils/pasteUpload.d.ts +13 -13
- package/lib/utils/pasteUpload.js +31 -29
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ import { useMemo, useState, useEffect, useContext, useRef } from 'react';
|
|
|
23
23
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
24
24
|
import { PlusOutlined, UploadOutlined, SearchOutlined, CloseOutlined } from '@ant-design/icons';
|
|
25
25
|
import { httpGet } from '../http';
|
|
26
|
-
import { getCache, showError, showWarn, showSuccess } from '../utils';
|
|
26
|
+
import { getCache, showError, showWarn, showSuccess, urlDownloadDomain } from '../utils';
|
|
27
27
|
var fileCenter = getCache('ossPath') || '/petrel/petrel-file-center-api/lesoon/oss/file/';
|
|
28
28
|
function ImageSelector(prop) {
|
|
29
29
|
var _rest$fieldProps3;
|
|
@@ -79,7 +79,8 @@ function ImageSelector(prop) {
|
|
|
79
79
|
rest = _objectWithoutProperties(prop, _excluded);
|
|
80
80
|
// 上传地址
|
|
81
81
|
var uploadImgApi = useMemo(function () {
|
|
82
|
-
|
|
82
|
+
var url = fileCenter + 'upload/' + code + '?catalogName=' + type;
|
|
83
|
+
return urlDownloadDomain(url);
|
|
83
84
|
}, [code, type]);
|
|
84
85
|
// 分页加载列表地址
|
|
85
86
|
var pageImgApi = useMemo(function () {
|
|
@@ -4,19 +4,19 @@ import { UploadProgressCallback } from '../http';
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```tsx // 在 TextArea 组件中使用
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
7
|
+
* const handlePaste = async (event: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
8
|
+
* event.preventDefault(); // 阻止默认粘贴行为
|
|
9
|
+
* try {
|
|
10
|
+
* const result = await pasteUpload(event, { userId: '123' }, 'imgs');
|
|
11
|
+
* // 处理上传结果
|
|
12
|
+
* console.log('图片URL:', result.rows?.[0]?.shareUrl);
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* message.error('图片上传失败');
|
|
15
|
+
* }
|
|
16
|
+
* };
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* <Input.TextArea onPaste={handlePaste} />
|
|
19
|
+
* ```;
|
|
20
20
|
*
|
|
21
21
|
* @param event 粘贴事件对象
|
|
22
22
|
* @param params 附加其它参数 {key:value}
|
|
@@ -24,4 +24,4 @@ import { UploadProgressCallback } from '../http';
|
|
|
24
24
|
* @param onProgress 上传进度回调函数,参数为 0-100 的进度百分比
|
|
25
25
|
* @returns 返回上传结果的 Promise,resolve 时返回上传成功的数据,reject 时返回错误信息
|
|
26
26
|
*/
|
|
27
|
-
export declare const pasteUpload: (event: React.ClipboardEvent<any> | ClipboardEvent, params?: Record<string, any>, catalogName?: string, onProgress?: UploadProgressCallback | undefined) => Promise<any>;
|
|
27
|
+
export declare const pasteUpload: (event: React.ClipboardEvent<any> | ClipboardEvent, params?: Record<string, any>, catalogName?: string, onProgress?: UploadProgressCallback | undefined, ifDownloadDomain?: boolean | undefined) => Promise<any>;
|
package/es/utils/pasteUpload.js
CHANGED
|
@@ -6,19 +6,19 @@ import { httpUpload } from '../http';
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx // 在 TextArea 组件中使用
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
9
|
+
* const handlePaste = async (event: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
10
|
+
* event.preventDefault(); // 阻止默认粘贴行为
|
|
11
|
+
* try {
|
|
12
|
+
* const result = await pasteUpload(event, { userId: '123' }, 'imgs');
|
|
13
|
+
* // 处理上传结果
|
|
14
|
+
* console.log('图片URL:', result.rows?.[0]?.shareUrl);
|
|
15
|
+
* } catch (error) {
|
|
16
|
+
* message.error('图片上传失败');
|
|
17
|
+
* }
|
|
18
|
+
* };
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* <Input.TextArea onPaste={handlePaste} />
|
|
21
|
+
* ```;
|
|
22
22
|
*
|
|
23
23
|
* @param event 粘贴事件对象
|
|
24
24
|
* @param params 附加其它参数 {key:value}
|
|
@@ -31,6 +31,7 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
31
31
|
var params,
|
|
32
32
|
catalogName,
|
|
33
33
|
onProgress,
|
|
34
|
+
ifDownloadDomain,
|
|
34
35
|
clipboardData,
|
|
35
36
|
file,
|
|
36
37
|
items,
|
|
@@ -47,41 +48,42 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
47
48
|
params = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
48
49
|
catalogName = _args.length > 2 && _args[2] !== undefined ? _args[2] : 'imgs';
|
|
49
50
|
onProgress = _args.length > 3 ? _args[3] : undefined;
|
|
51
|
+
ifDownloadDomain = _args.length > 4 ? _args[4] : undefined;
|
|
50
52
|
clipboardData = event.clipboardData;
|
|
51
53
|
if (clipboardData) {
|
|
52
|
-
_context.next =
|
|
54
|
+
_context.next = 7;
|
|
53
55
|
break;
|
|
54
56
|
}
|
|
55
57
|
return _context.abrupt("return");
|
|
56
|
-
case
|
|
58
|
+
case 7:
|
|
57
59
|
file = null; // 优先从剪贴板 items 中获取文件
|
|
58
60
|
items = clipboardData.items;
|
|
59
61
|
if (!items) {
|
|
60
|
-
_context.next =
|
|
62
|
+
_context.next = 20;
|
|
61
63
|
break;
|
|
62
64
|
}
|
|
63
65
|
i = 0;
|
|
64
|
-
case
|
|
66
|
+
case 11:
|
|
65
67
|
if (!(i < items.length)) {
|
|
66
|
-
_context.next =
|
|
68
|
+
_context.next = 20;
|
|
67
69
|
break;
|
|
68
70
|
}
|
|
69
71
|
item = items[i]; // 检查是否为图片类型
|
|
70
72
|
if (!(item.kind === 'file' && item.type.startsWith('image/'))) {
|
|
71
|
-
_context.next =
|
|
73
|
+
_context.next = 17;
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
file = item.getAsFile();
|
|
75
77
|
if (!file) {
|
|
76
|
-
_context.next =
|
|
78
|
+
_context.next = 17;
|
|
77
79
|
break;
|
|
78
80
|
}
|
|
79
|
-
return _context.abrupt("break",
|
|
80
|
-
case
|
|
81
|
+
return _context.abrupt("break", 20);
|
|
82
|
+
case 17:
|
|
81
83
|
i++;
|
|
82
|
-
_context.next =
|
|
84
|
+
_context.next = 11;
|
|
83
85
|
break;
|
|
84
|
-
case
|
|
86
|
+
case 20:
|
|
85
87
|
// 如果 items 中没有找到,尝试从 files 属性获取
|
|
86
88
|
if (!file && clipboardData.files && clipboardData.files.length > 0) {
|
|
87
89
|
files = Array.from(clipboardData.files); // 查找第一个图片文件
|
|
@@ -90,22 +92,22 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
90
92
|
}) || null;
|
|
91
93
|
}
|
|
92
94
|
if (file) {
|
|
93
|
-
_context.next =
|
|
95
|
+
_context.next = 23;
|
|
94
96
|
break;
|
|
95
97
|
}
|
|
96
98
|
return _context.abrupt("return");
|
|
97
|
-
case
|
|
99
|
+
case 23:
|
|
98
100
|
if (file.type.startsWith('image/')) {
|
|
99
|
-
_context.next =
|
|
101
|
+
_context.next = 25;
|
|
100
102
|
break;
|
|
101
103
|
}
|
|
102
104
|
return _context.abrupt("return");
|
|
103
|
-
case
|
|
105
|
+
case 25:
|
|
104
106
|
// 构建上传 URL
|
|
105
107
|
uploadUrl = "/petrel/petrel-file-center-api/lesoon/oss/file/upload/RETAIL-PUBLIC?catalogName=".concat(catalogName); // 调用上传接口
|
|
106
|
-
_httpUpload = httpUpload(uploadUrl, file, params, 'file', false, onProgress), promise = _httpUpload.promise;
|
|
108
|
+
_httpUpload = httpUpload(uploadUrl, file, params, 'file', false, onProgress, ifDownloadDomain), promise = _httpUpload.promise;
|
|
107
109
|
return _context.abrupt("return", promise);
|
|
108
|
-
case
|
|
110
|
+
case 28:
|
|
109
111
|
case "end":
|
|
110
112
|
return _context.stop();
|
|
111
113
|
}
|
|
@@ -23,7 +23,7 @@ import { useMemo, useState, useEffect, useContext, useRef } from 'react';
|
|
|
23
23
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
24
24
|
import { PlusOutlined, UploadOutlined, SearchOutlined, CloseOutlined } from '@ant-design/icons';
|
|
25
25
|
import { httpGet } from '../http';
|
|
26
|
-
import { getCache, showError, showWarn, showSuccess } from '../utils';
|
|
26
|
+
import { getCache, showError, showWarn, showSuccess, urlDownloadDomain } from '../utils';
|
|
27
27
|
var fileCenter = getCache('ossPath') || '/petrel/petrel-file-center-api/lesoon/oss/file/';
|
|
28
28
|
function ImageSelector(prop) {
|
|
29
29
|
var _rest$fieldProps3;
|
|
@@ -79,7 +79,8 @@ function ImageSelector(prop) {
|
|
|
79
79
|
rest = _objectWithoutProperties(prop, _excluded);
|
|
80
80
|
// 上传地址
|
|
81
81
|
var uploadImgApi = useMemo(function () {
|
|
82
|
-
|
|
82
|
+
var url = fileCenter + 'upload/' + code + '?catalogName=' + type;
|
|
83
|
+
return urlDownloadDomain(url);
|
|
83
84
|
}, [code, type]);
|
|
84
85
|
// 分页加载列表地址
|
|
85
86
|
var pageImgApi = useMemo(function () {
|
|
@@ -4,19 +4,19 @@ import { UploadProgressCallback } from '../http';
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```tsx // 在 TextArea 组件中使用
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
7
|
+
* const handlePaste = async (event: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
8
|
+
* event.preventDefault(); // 阻止默认粘贴行为
|
|
9
|
+
* try {
|
|
10
|
+
* const result = await pasteUpload(event, { userId: '123' }, 'imgs');
|
|
11
|
+
* // 处理上传结果
|
|
12
|
+
* console.log('图片URL:', result.rows?.[0]?.shareUrl);
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* message.error('图片上传失败');
|
|
15
|
+
* }
|
|
16
|
+
* };
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* <Input.TextArea onPaste={handlePaste} />
|
|
19
|
+
* ```;
|
|
20
20
|
*
|
|
21
21
|
* @param event 粘贴事件对象
|
|
22
22
|
* @param params 附加其它参数 {key:value}
|
|
@@ -24,4 +24,4 @@ import { UploadProgressCallback } from '../http';
|
|
|
24
24
|
* @param onProgress 上传进度回调函数,参数为 0-100 的进度百分比
|
|
25
25
|
* @returns 返回上传结果的 Promise,resolve 时返回上传成功的数据,reject 时返回错误信息
|
|
26
26
|
*/
|
|
27
|
-
export declare const pasteUpload: (event: React.ClipboardEvent<any> | ClipboardEvent, params?: Record<string, any>, catalogName?: string, onProgress?: UploadProgressCallback | undefined) => Promise<any>;
|
|
27
|
+
export declare const pasteUpload: (event: React.ClipboardEvent<any> | ClipboardEvent, params?: Record<string, any>, catalogName?: string, onProgress?: UploadProgressCallback | undefined, ifDownloadDomain?: boolean | undefined) => Promise<any>;
|
package/lib/utils/pasteUpload.js
CHANGED
|
@@ -6,19 +6,19 @@ import { httpUpload } from '../http';
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx // 在 TextArea 组件中使用
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
9
|
+
* const handlePaste = async (event: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
10
|
+
* event.preventDefault(); // 阻止默认粘贴行为
|
|
11
|
+
* try {
|
|
12
|
+
* const result = await pasteUpload(event, { userId: '123' }, 'imgs');
|
|
13
|
+
* // 处理上传结果
|
|
14
|
+
* console.log('图片URL:', result.rows?.[0]?.shareUrl);
|
|
15
|
+
* } catch (error) {
|
|
16
|
+
* message.error('图片上传失败');
|
|
17
|
+
* }
|
|
18
|
+
* };
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* <Input.TextArea onPaste={handlePaste} />
|
|
21
|
+
* ```;
|
|
22
22
|
*
|
|
23
23
|
* @param event 粘贴事件对象
|
|
24
24
|
* @param params 附加其它参数 {key:value}
|
|
@@ -31,6 +31,7 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
31
31
|
var params,
|
|
32
32
|
catalogName,
|
|
33
33
|
onProgress,
|
|
34
|
+
ifDownloadDomain,
|
|
34
35
|
clipboardData,
|
|
35
36
|
file,
|
|
36
37
|
items,
|
|
@@ -47,41 +48,42 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
47
48
|
params = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
48
49
|
catalogName = _args.length > 2 && _args[2] !== undefined ? _args[2] : 'imgs';
|
|
49
50
|
onProgress = _args.length > 3 ? _args[3] : undefined;
|
|
51
|
+
ifDownloadDomain = _args.length > 4 ? _args[4] : undefined;
|
|
50
52
|
clipboardData = event.clipboardData;
|
|
51
53
|
if (clipboardData) {
|
|
52
|
-
_context.next =
|
|
54
|
+
_context.next = 7;
|
|
53
55
|
break;
|
|
54
56
|
}
|
|
55
57
|
return _context.abrupt("return");
|
|
56
|
-
case
|
|
58
|
+
case 7:
|
|
57
59
|
file = null; // 优先从剪贴板 items 中获取文件
|
|
58
60
|
items = clipboardData.items;
|
|
59
61
|
if (!items) {
|
|
60
|
-
_context.next =
|
|
62
|
+
_context.next = 20;
|
|
61
63
|
break;
|
|
62
64
|
}
|
|
63
65
|
i = 0;
|
|
64
|
-
case
|
|
66
|
+
case 11:
|
|
65
67
|
if (!(i < items.length)) {
|
|
66
|
-
_context.next =
|
|
68
|
+
_context.next = 20;
|
|
67
69
|
break;
|
|
68
70
|
}
|
|
69
71
|
item = items[i]; // 检查是否为图片类型
|
|
70
72
|
if (!(item.kind === 'file' && item.type.startsWith('image/'))) {
|
|
71
|
-
_context.next =
|
|
73
|
+
_context.next = 17;
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
file = item.getAsFile();
|
|
75
77
|
if (!file) {
|
|
76
|
-
_context.next =
|
|
78
|
+
_context.next = 17;
|
|
77
79
|
break;
|
|
78
80
|
}
|
|
79
|
-
return _context.abrupt("break",
|
|
80
|
-
case
|
|
81
|
+
return _context.abrupt("break", 20);
|
|
82
|
+
case 17:
|
|
81
83
|
i++;
|
|
82
|
-
_context.next =
|
|
84
|
+
_context.next = 11;
|
|
83
85
|
break;
|
|
84
|
-
case
|
|
86
|
+
case 20:
|
|
85
87
|
// 如果 items 中没有找到,尝试从 files 属性获取
|
|
86
88
|
if (!file && clipboardData.files && clipboardData.files.length > 0) {
|
|
87
89
|
files = Array.from(clipboardData.files); // 查找第一个图片文件
|
|
@@ -90,22 +92,22 @@ export var pasteUpload = /*#__PURE__*/function () {
|
|
|
90
92
|
}) || null;
|
|
91
93
|
}
|
|
92
94
|
if (file) {
|
|
93
|
-
_context.next =
|
|
95
|
+
_context.next = 23;
|
|
94
96
|
break;
|
|
95
97
|
}
|
|
96
98
|
return _context.abrupt("return");
|
|
97
|
-
case
|
|
99
|
+
case 23:
|
|
98
100
|
if (file.type.startsWith('image/')) {
|
|
99
|
-
_context.next =
|
|
101
|
+
_context.next = 25;
|
|
100
102
|
break;
|
|
101
103
|
}
|
|
102
104
|
return _context.abrupt("return");
|
|
103
|
-
case
|
|
105
|
+
case 25:
|
|
104
106
|
// 构建上传 URL
|
|
105
107
|
uploadUrl = "/petrel/petrel-file-center-api/lesoon/oss/file/upload/RETAIL-PUBLIC?catalogName=".concat(catalogName); // 调用上传接口
|
|
106
|
-
_httpUpload = httpUpload(uploadUrl, file, params, 'file', false, onProgress), promise = _httpUpload.promise;
|
|
108
|
+
_httpUpload = httpUpload(uploadUrl, file, params, 'file', false, onProgress, ifDownloadDomain), promise = _httpUpload.promise;
|
|
107
109
|
return _context.abrupt("return", promise);
|
|
108
|
-
case
|
|
110
|
+
case 28:
|
|
109
111
|
case "end":
|
|
110
112
|
return _context.stop();
|
|
111
113
|
}
|