@ai-group/chat-sdk 3.6.3 → 3.6.5
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/cjs/components/FileGallery/index.d.ts +0 -30
- package/dist/cjs/components/FileGallery/index.js +287 -209
- package/dist/cjs/components/FileGallery/index.js.map +2 -2
- package/dist/cjs/components/FileGallery/styles.d.ts +5 -0
- package/dist/cjs/components/FileGallery/styles.js +106 -0
- package/dist/cjs/components/FileGallery/styles.js.map +2 -2
- package/dist/cjs/components/XAdkProvider/compound/Sender.js +3 -2
- package/dist/cjs/components/XAdkProvider/compound/Sender.js.map +2 -2
- package/dist/cjs/components/XAdkSender/index.js +1 -0
- package/dist/cjs/components/XAdkSender/index.js.map +2 -2
- package/dist/cjs/hooks/useADKChat.js +392 -157
- package/dist/cjs/hooks/useADKChat.js.map +3 -3
- package/dist/cjs/types/FileGallery.d.ts +41 -0
- package/dist/cjs/types/FileGallery.js.map +1 -1
- package/dist/cjs/types/XAdkProvider.d.ts +4 -0
- package/dist/cjs/types/XAdkProvider.js.map +1 -1
- package/dist/esm/components/FileGallery/index.d.ts +0 -30
- package/dist/esm/components/FileGallery/index.js +362 -364
- package/dist/esm/components/FileGallery/index.js.map +1 -1
- package/dist/esm/components/FileGallery/styles.d.ts +5 -0
- package/dist/esm/components/FileGallery/styles.js +10 -2
- package/dist/esm/components/FileGallery/styles.js.map +1 -1
- package/dist/esm/components/XAdkProvider/compound/Sender.js +5 -3
- package/dist/esm/components/XAdkProvider/compound/Sender.js.map +1 -1
- package/dist/esm/components/XAdkSender/index.js +1 -0
- package/dist/esm/components/XAdkSender/index.js.map +1 -1
- package/dist/esm/hooks/useADKChat.js +347 -130
- package/dist/esm/hooks/useADKChat.js.map +1 -1
- package/dist/esm/types/FileGallery.d.ts +41 -0
- package/dist/esm/types/FileGallery.js.map +1 -1
- package/dist/esm/types/XAdkProvider.d.ts +4 -0
- package/dist/esm/types/XAdkProvider.js.map +1 -1
- package/dist/umd/chat-sdk.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,247 +1,229 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import React, { useState, useEffect } from "react";
|
|
3
|
+
import React, { useState, useEffect, useMemo } from "react";
|
|
4
4
|
import { Image, Tooltip, Progress } from "antd";
|
|
5
|
-
import { FileOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileImageOutlined, CloseOutlined, AudioOutlined, FileZipOutlined, VideoCameraOutlined, FileMarkdownOutlined } from "@ant-design/icons";
|
|
5
|
+
import { FileOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileImageOutlined, CloseOutlined, AudioOutlined, FileZipOutlined, VideoCameraOutlined, FileMarkdownOutlined, PictureOutlined } from "@ant-design/icons";
|
|
6
6
|
import { useStyles } from "./styles";
|
|
7
7
|
|
|
8
8
|
// ==================== 工具函数 ====================
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 获取文件名
|
|
12
|
-
*/
|
|
13
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
11
|
var getFileName = function getFileName(file) {
|
|
16
12
|
return file.displayName || file.name || "";
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 获取文件大小
|
|
21
|
-
*/
|
|
22
14
|
var getFileSize = function getFileSize(file) {
|
|
23
15
|
return file.size || 0;
|
|
24
16
|
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 获取文件 MIME 类型
|
|
28
|
-
*/
|
|
29
17
|
var getMimeType = function getMimeType(file) {
|
|
30
18
|
return file.mimeType || file.type || "";
|
|
31
19
|
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 获取文件 URL
|
|
35
|
-
*/
|
|
36
20
|
var getFileUrl = function getFileUrl(file) {
|
|
37
21
|
var _file$response, _file$response2;
|
|
38
22
|
return file.fileUri || ((_file$response = file.response) === null || _file$response === void 0 ? void 0 : _file$response.fileUrl) || ((_file$response2 = file.response) === null || _file$response2 === void 0 ? void 0 : _file$response2.tempUrl) || file.tempUrl || "";
|
|
39
23
|
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 获取文件唯一标识
|
|
43
|
-
*/
|
|
44
24
|
var getFileId = function getFileId(file) {
|
|
45
25
|
return file.id || file.uid || "";
|
|
46
26
|
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 判断是否是图片文件
|
|
50
|
-
*/
|
|
51
|
-
var isImageFile = function isImageFile(file) {
|
|
52
|
-
var mimeType = getMimeType(file);
|
|
53
|
-
if (mimeType && mimeType.startsWith("image/")) return true;
|
|
54
|
-
var fileName = getFileName(file);
|
|
55
|
-
if (fileName && fileName.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i)) return true;
|
|
56
|
-
var url = getFileUrl(file);
|
|
57
|
-
if (url && url.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?.*)?$/i)) return true;
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 判断是否是音频文件
|
|
63
|
-
*/
|
|
64
|
-
var isAudioFile = function isAudioFile(file) {
|
|
65
|
-
var mimeType = getMimeType(file);
|
|
66
|
-
if (mimeType && mimeType.startsWith("audio/")) return true;
|
|
67
|
-
var fileName = getFileName(file);
|
|
68
|
-
return !!(fileName !== null && fileName !== void 0 && fileName.match(/\.(mp3|wav|m4a|aac|ogg|flac)$/i));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 判断是否是视频文件
|
|
73
|
-
*/
|
|
74
|
-
var isVideoFile = function isVideoFile(file) {
|
|
75
|
-
var mimeType = getMimeType(file);
|
|
76
|
-
if (mimeType && mimeType.startsWith("video/")) return true;
|
|
77
|
-
var fileName = getFileName(file);
|
|
78
|
-
return !!(fileName !== null && fileName !== void 0 && fileName.match(/\.(mp4|mov|webm|mkv|avi)$/i));
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 判断是否是压缩包文件
|
|
83
|
-
*/
|
|
84
|
-
var isZipFile = function isZipFile(file) {
|
|
85
|
-
var fileName = getFileName(file);
|
|
86
|
-
return !!(fileName !== null && fileName !== void 0 && fileName.match(/\.(zip|rar|7z|tar|gz|bz2|xz|tgz)$/i));
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 判断是否是 Markdown 文件
|
|
91
|
-
*/
|
|
92
|
-
var isMarkdownFile = function isMarkdownFile(file) {
|
|
93
|
-
var fileName = getFileName(file);
|
|
94
|
-
return !!(fileName !== null && fileName !== void 0 && fileName.match(/\.(md|markdown)$/i));
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 获取文件扩展名
|
|
99
|
-
*/
|
|
100
27
|
var getFileExtension = function getFileExtension(filename) {
|
|
101
28
|
var ext = filename.split(".").pop();
|
|
102
29
|
return ext ? ext.toLowerCase() : "";
|
|
103
30
|
};
|
|
31
|
+
var IMAGE_EXTS = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg"];
|
|
32
|
+
var AUDIO_EXTS = ["mp3", "wav", "m4a", "aac", "ogg", "flac"];
|
|
33
|
+
var VIDEO_EXTS = ["mp4", "mov", "webm", "mkv", "avi"];
|
|
104
34
|
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
35
|
+
/** 自动推断文件卡片类型 */
|
|
36
|
+
var inferFileType = function inferFileType(file) {
|
|
37
|
+
var mimeType = getMimeType(file);
|
|
38
|
+
if (mimeType.startsWith("image/")) return "image";
|
|
39
|
+
if (mimeType.startsWith("audio/")) return "audio";
|
|
40
|
+
if (mimeType.startsWith("video/")) return "video";
|
|
109
41
|
var ext = getFileExtension(getFileName(file));
|
|
42
|
+
if (IMAGE_EXTS.includes(ext)) return "image";
|
|
43
|
+
if (AUDIO_EXTS.includes(ext)) return "audio";
|
|
44
|
+
if (VIDEO_EXTS.includes(ext)) return "video";
|
|
110
45
|
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// Word
|
|
120
|
-
if (["doc", "docx"].includes(ext)) {
|
|
121
|
-
return {
|
|
122
|
-
icon: /*#__PURE__*/_jsx(FileWordOutlined, {}),
|
|
123
|
-
color: "#1677ff"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Excel
|
|
128
|
-
if (["xls", "xlsx", "csv"].includes(ext)) {
|
|
129
|
-
return {
|
|
130
|
-
icon: /*#__PURE__*/_jsx(FileExcelOutlined, {}),
|
|
131
|
-
color: "#22b35e"
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// PPT
|
|
136
|
-
if (["ppt", "pptx"].includes(ext)) {
|
|
137
|
-
return {
|
|
138
|
-
icon: /*#__PURE__*/_jsx(FilePptOutlined, {}),
|
|
139
|
-
color: "#ff6e31"
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Audio
|
|
144
|
-
if (["mp3", "wav", "m4a", "aac", "ogg", "flac"].includes(ext)) {
|
|
145
|
-
return {
|
|
146
|
-
icon: /*#__PURE__*/_jsx(AudioOutlined, {}),
|
|
147
|
-
color: "#722ed1"
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Video
|
|
152
|
-
if (["mp4", "mov", "webm", "mkv", "avi"].includes(ext)) {
|
|
153
|
-
return {
|
|
154
|
-
icon: /*#__PURE__*/_jsx(VideoCameraOutlined, {}),
|
|
155
|
-
color: "#fa8c16"
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// 压缩包
|
|
160
|
-
if (["zip", "rar", "7z", "tar", "gz", "bz2", "xz", "tgz"].includes(ext)) {
|
|
161
|
-
return {
|
|
162
|
-
icon: /*#__PURE__*/_jsx(FileZipOutlined, {}),
|
|
163
|
-
color: "#eb2f96"
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Markdown
|
|
168
|
-
if (["md", "markdown"].includes(ext)) {
|
|
169
|
-
return {
|
|
170
|
-
icon: /*#__PURE__*/_jsx(FileMarkdownOutlined, {}),
|
|
171
|
-
color: "#13c2c2"
|
|
172
|
-
};
|
|
46
|
+
// URL 扩展名兜底
|
|
47
|
+
var url = getFileUrl(file);
|
|
48
|
+
var urlExtMatch = url.match(/\.(\w+)(\?.*)?$/);
|
|
49
|
+
if (urlExtMatch) {
|
|
50
|
+
var urlExt = urlExtMatch[1].toLowerCase();
|
|
51
|
+
if (IMAGE_EXTS.includes(urlExt)) return "image";
|
|
52
|
+
if (AUDIO_EXTS.includes(urlExt)) return "audio";
|
|
53
|
+
if (VIDEO_EXTS.includes(urlExt)) return "video";
|
|
173
54
|
}
|
|
55
|
+
return "file";
|
|
56
|
+
};
|
|
174
57
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
58
|
+
/** 根据扩展名获取文件图标类型 key */
|
|
59
|
+
var getFileIconType = function getFileIconType(file) {
|
|
60
|
+
var ext = getFileExtension(getFileName(file));
|
|
61
|
+
if (ext === "pdf") return "pdf";
|
|
62
|
+
if (["doc", "docx"].includes(ext)) return "word";
|
|
63
|
+
if (["xls", "xlsx", "csv"].includes(ext)) return "excel";
|
|
64
|
+
if (["ppt", "pptx"].includes(ext)) return "ppt";
|
|
65
|
+
if (AUDIO_EXTS.includes(ext)) return "audio";
|
|
66
|
+
if (VIDEO_EXTS.includes(ext)) return "video";
|
|
67
|
+
if (["zip", "rar", "7z", "tar", "gz", "bz2", "xz", "tgz"].includes(ext)) return "zip";
|
|
68
|
+
if (["md", "markdown"].includes(ext)) return "markdown";
|
|
69
|
+
if (IMAGE_EXTS.includes(ext)) return "image";
|
|
70
|
+
return "default";
|
|
71
|
+
};
|
|
182
72
|
|
|
183
|
-
|
|
184
|
-
|
|
73
|
+
/** 默认图标映射 */
|
|
74
|
+
var DEFAULT_ICON_MAP = {
|
|
75
|
+
pdf: {
|
|
76
|
+
icon: /*#__PURE__*/_jsx(FilePdfOutlined, {}),
|
|
77
|
+
color: "#ff4d4f"
|
|
78
|
+
},
|
|
79
|
+
word: {
|
|
80
|
+
icon: /*#__PURE__*/_jsx(FileWordOutlined, {}),
|
|
81
|
+
color: "#1677ff"
|
|
82
|
+
},
|
|
83
|
+
excel: {
|
|
84
|
+
icon: /*#__PURE__*/_jsx(FileExcelOutlined, {}),
|
|
85
|
+
color: "#22b35e"
|
|
86
|
+
},
|
|
87
|
+
ppt: {
|
|
88
|
+
icon: /*#__PURE__*/_jsx(FilePptOutlined, {}),
|
|
89
|
+
color: "#ff6e31"
|
|
90
|
+
},
|
|
91
|
+
audio: {
|
|
92
|
+
icon: /*#__PURE__*/_jsx(AudioOutlined, {}),
|
|
93
|
+
color: "#722ed1"
|
|
94
|
+
},
|
|
95
|
+
video: {
|
|
96
|
+
icon: /*#__PURE__*/_jsx(VideoCameraOutlined, {}),
|
|
97
|
+
color: "#fa8c16"
|
|
98
|
+
},
|
|
99
|
+
zip: {
|
|
100
|
+
icon: /*#__PURE__*/_jsx(FileZipOutlined, {}),
|
|
101
|
+
color: "#eb2f96"
|
|
102
|
+
},
|
|
103
|
+
markdown: {
|
|
104
|
+
icon: /*#__PURE__*/_jsx(FileMarkdownOutlined, {}),
|
|
105
|
+
color: "#13c2c2"
|
|
106
|
+
},
|
|
107
|
+
image: {
|
|
108
|
+
icon: /*#__PURE__*/_jsx(FileImageOutlined, {}),
|
|
109
|
+
color: "#8c8c8c"
|
|
110
|
+
},
|
|
111
|
+
default: {
|
|
185
112
|
icon: /*#__PURE__*/_jsx(FileOutlined, {}),
|
|
186
113
|
color: "#8c8c8c"
|
|
187
|
-
}
|
|
114
|
+
}
|
|
188
115
|
};
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* 格式化文件大小
|
|
192
|
-
*/
|
|
193
116
|
var formatFileSize = function formatFileSize(bytes) {
|
|
194
117
|
if (bytes < 1024) return bytes + " B";
|
|
195
118
|
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
|
|
196
119
|
return (bytes / (1024 * 1024)).toFixed(1) + " MB";
|
|
197
120
|
};
|
|
198
|
-
var
|
|
121
|
+
var FALLBACK_IMAGE = "data:image/png;base64,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";
|
|
122
|
+
|
|
123
|
+
// ==================== 子组件:图片加载状态管理 ====================
|
|
199
124
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
* - 🎨 支持卡片内部布局控制(align:图标和信息的排列方式)
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* // XAdkSender 场景 - 可删除的本地文件
|
|
215
|
-
* {files.map(file => (
|
|
216
|
-
* <FileGallery
|
|
217
|
-
* key={file.id}
|
|
218
|
-
* file={file}
|
|
219
|
-
* removable
|
|
220
|
-
* onRemove={handleRemove}
|
|
221
|
-
* />
|
|
222
|
-
* ))}
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* // XadkChatbot 场景 - 只读的远程文件
|
|
226
|
-
* {files.map(file => (
|
|
227
|
-
* <FileGallery key={file.id} file={file} />
|
|
228
|
-
* ))}
|
|
229
|
-
*/
|
|
230
|
-
var FileGallery = function FileGallery(_ref) {
|
|
231
|
-
var file = _ref.file,
|
|
232
|
-
_ref$align = _ref.align,
|
|
233
|
-
align = _ref$align === void 0 ? "left" : _ref$align,
|
|
234
|
-
_ref$removable = _ref.removable,
|
|
235
|
-
removable = _ref$removable === void 0 ? false : _ref$removable,
|
|
236
|
-
_ref$onRemove = _ref.onRemove,
|
|
237
|
-
onRemove = _ref$onRemove === void 0 ? function () {} : _ref$onRemove,
|
|
238
|
-
className = _ref.className,
|
|
239
|
-
style = _ref.style,
|
|
240
|
-
_onClick = _ref.onClick;
|
|
241
|
-
var _useState = useState(""),
|
|
125
|
+
var ImageWithLoading = function ImageWithLoading(_ref) {
|
|
126
|
+
var src = _ref.src,
|
|
127
|
+
alt = _ref.alt,
|
|
128
|
+
width = _ref.width,
|
|
129
|
+
height = _ref.height,
|
|
130
|
+
loading = _ref.loading,
|
|
131
|
+
preview = _ref.preview,
|
|
132
|
+
fallback = _ref.fallback,
|
|
133
|
+
displayMode = _ref.displayMode,
|
|
134
|
+
styles = _ref.styles;
|
|
135
|
+
var _useState = useState("loading"),
|
|
242
136
|
_useState2 = _slicedToArray(_useState, 2),
|
|
243
|
-
|
|
244
|
-
|
|
137
|
+
loadState = _useState2[0],
|
|
138
|
+
setLoadState = _useState2[1];
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
setLoadState("loading");
|
|
141
|
+
}, [src]);
|
|
142
|
+
var modeClass = displayMode === "full" ? styles.imageFullMode : displayMode === "preview" ? styles.imagePreviewMode : styles.imageThumbnail;
|
|
143
|
+
var containerStyle = {};
|
|
144
|
+
if (width) containerStyle.width = typeof width === "number" ? "".concat(width, "px") : width;
|
|
145
|
+
if (height) containerStyle.height = typeof height === "number" ? "".concat(height, "px") : height;
|
|
146
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
147
|
+
className: modeClass,
|
|
148
|
+
style: containerStyle,
|
|
149
|
+
children: [loadState === "loading" && /*#__PURE__*/_jsx("div", {
|
|
150
|
+
className: styles.imageLoadingSkeleton,
|
|
151
|
+
children: /*#__PURE__*/_jsx(PictureOutlined, {
|
|
152
|
+
style: {
|
|
153
|
+
fontSize: 20,
|
|
154
|
+
color: "#d9d9d9"
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}), loadState === "error" && /*#__PURE__*/_jsxs("div", {
|
|
158
|
+
className: styles.imageErrorFallback,
|
|
159
|
+
children: [/*#__PURE__*/_jsx(PictureOutlined, {}), /*#__PURE__*/_jsx("span", {
|
|
160
|
+
children: "\u52A0\u8F7D\u5931\u8D25"
|
|
161
|
+
})]
|
|
162
|
+
}), /*#__PURE__*/_jsx(Image, {
|
|
163
|
+
src: src,
|
|
164
|
+
alt: alt,
|
|
165
|
+
fallback: fallback,
|
|
166
|
+
preview: preview,
|
|
167
|
+
loading: loading,
|
|
168
|
+
style: _objectSpread({
|
|
169
|
+
display: loadState === "error" ? "none" : "block",
|
|
170
|
+
opacity: loadState === "loading" ? 0 : 1,
|
|
171
|
+
transition: "opacity 0.3s ease"
|
|
172
|
+
}, displayMode === "thumbnail" ? {
|
|
173
|
+
width: "100%",
|
|
174
|
+
height: "100%",
|
|
175
|
+
objectFit: "cover"
|
|
176
|
+
} : {
|
|
177
|
+
maxWidth: "100%",
|
|
178
|
+
objectFit: "contain"
|
|
179
|
+
}),
|
|
180
|
+
onLoad: function onLoad() {
|
|
181
|
+
return setLoadState("loaded");
|
|
182
|
+
},
|
|
183
|
+
onError: function onError() {
|
|
184
|
+
return setLoadState("error");
|
|
185
|
+
}
|
|
186
|
+
})]
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// ==================== 主组件 ====================
|
|
191
|
+
|
|
192
|
+
var FileGallery = function FileGallery(_ref2) {
|
|
193
|
+
var file = _ref2.file,
|
|
194
|
+
_ref2$align = _ref2.align,
|
|
195
|
+
align = _ref2$align === void 0 ? "left" : _ref2$align,
|
|
196
|
+
_ref2$removable = _ref2.removable,
|
|
197
|
+
removable = _ref2$removable === void 0 ? false : _ref2$removable,
|
|
198
|
+
_ref2$onRemove = _ref2.onRemove,
|
|
199
|
+
onRemove = _ref2$onRemove === void 0 ? function () {} : _ref2$onRemove,
|
|
200
|
+
className = _ref2.className,
|
|
201
|
+
style = _ref2.style,
|
|
202
|
+
_onClick = _ref2.onClick,
|
|
203
|
+
customType = _ref2.type,
|
|
204
|
+
_ref2$imageDisplayMod = _ref2.imageDisplayMode,
|
|
205
|
+
imageDisplayMode = _ref2$imageDisplayMod === void 0 ? "thumbnail" : _ref2$imageDisplayMod,
|
|
206
|
+
imageWidth = _ref2.imageWidth,
|
|
207
|
+
imageHeight = _ref2.imageHeight,
|
|
208
|
+
_ref2$imageLoading = _ref2.imageLoading,
|
|
209
|
+
imageLoading = _ref2$imageLoading === void 0 ? "eager" : _ref2$imageLoading,
|
|
210
|
+
imageAlt = _ref2.imageAlt,
|
|
211
|
+
_ref2$mediaAutoPlay = _ref2.mediaAutoPlay,
|
|
212
|
+
mediaAutoPlay = _ref2$mediaAutoPlay === void 0 ? false : _ref2$mediaAutoPlay,
|
|
213
|
+
_ref2$mediaLoop = _ref2.mediaLoop,
|
|
214
|
+
mediaLoop = _ref2$mediaLoop === void 0 ? false : _ref2$mediaLoop,
|
|
215
|
+
_ref2$mediaMuted = _ref2.mediaMuted,
|
|
216
|
+
mediaMuted = _ref2$mediaMuted === void 0 ? false : _ref2$mediaMuted,
|
|
217
|
+
mediaPoster = _ref2.mediaPoster,
|
|
218
|
+
videoProps = _ref2.videoProps,
|
|
219
|
+
audioProps = _ref2.audioProps,
|
|
220
|
+
iconMap = _ref2.iconMap,
|
|
221
|
+
customIcon = _ref2.customIcon;
|
|
222
|
+
var styles = useStyles();
|
|
223
|
+
var _useState3 = useState(""),
|
|
224
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
225
|
+
objectUrl = _useState4[0],
|
|
226
|
+
setObjectUrl = _useState4[1];
|
|
245
227
|
useEffect(function () {
|
|
246
228
|
if (!(file !== null && file !== void 0 && file.file)) return;
|
|
247
229
|
var url = URL.createObjectURL(file.file);
|
|
@@ -251,18 +233,66 @@ var FileGallery = function FileGallery(_ref) {
|
|
|
251
233
|
};
|
|
252
234
|
}, [file === null || file === void 0 ? void 0 : file.file]);
|
|
253
235
|
if (!file) return null;
|
|
254
|
-
var isImage = isImageFile(file);
|
|
255
|
-
var isAudio = isAudioFile(file);
|
|
256
|
-
var isVideo = isVideoFile(file);
|
|
257
|
-
var isZip = isZipFile(file);
|
|
258
|
-
var isMarkdown = isMarkdownFile(file);
|
|
259
236
|
var fileName = getFileName(file);
|
|
260
237
|
var fileSize = getFileSize(file);
|
|
261
238
|
var fileId = getFileId(file);
|
|
262
239
|
var url = getFileUrl(file) || objectUrl;
|
|
263
240
|
|
|
264
|
-
//
|
|
265
|
-
|
|
241
|
+
// 核心逻辑:type prop 决定渲染方式(参考 file-card)
|
|
242
|
+
// - 不传 type:自动推断,图片/音频/视频用原生渲染
|
|
243
|
+
// - type="file":强制附件卡片(音视频不可播放)
|
|
244
|
+
// - type="image"/"audio"/"video":强制指定类型
|
|
245
|
+
var fileType = useMemo(function () {
|
|
246
|
+
return customType || inferFileType(file);
|
|
247
|
+
}, [customType, file]);
|
|
248
|
+
|
|
249
|
+
/** 获取图标(支持自定义) */
|
|
250
|
+
var getIcon = function getIcon(iconType) {
|
|
251
|
+
if (customIcon) return {
|
|
252
|
+
icon: customIcon,
|
|
253
|
+
color: "inherit"
|
|
254
|
+
};
|
|
255
|
+
if (iconMap !== null && iconMap !== void 0 && iconMap[iconType]) return {
|
|
256
|
+
icon: iconMap[iconType],
|
|
257
|
+
color: "inherit"
|
|
258
|
+
};
|
|
259
|
+
return DEFAULT_ICON_MAP[iconType];
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// ==================== 渲染删除按钮 ====================
|
|
263
|
+
var renderRemoveBtn = function renderRemoveBtn() {
|
|
264
|
+
return removable ? /*#__PURE__*/_jsx("button", {
|
|
265
|
+
className: styles.fileRemoveBtn,
|
|
266
|
+
onClick: function onClick(e) {
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
onRemove(fileId);
|
|
269
|
+
},
|
|
270
|
+
disabled: file.status === "uploading",
|
|
271
|
+
"aria-label": "\u5220\u9664\u6587\u4EF6",
|
|
272
|
+
children: /*#__PURE__*/_jsx(CloseOutlined, {})
|
|
273
|
+
}) : null;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// ==================== 渲染上传进度遮罩 ====================
|
|
277
|
+
var renderUploadOverlay = function renderUploadOverlay() {
|
|
278
|
+
return file.status === "uploading" ? /*#__PURE__*/_jsx("div", {
|
|
279
|
+
className: styles.imageOverlay,
|
|
280
|
+
children: /*#__PURE__*/_jsx(Progress, {
|
|
281
|
+
type: "circle",
|
|
282
|
+
percent: file.progress,
|
|
283
|
+
size: 30,
|
|
284
|
+
strokeColor: "#1677ff"
|
|
285
|
+
})
|
|
286
|
+
}) : null;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// ==================== 附件卡片渲染(type="file" 或普通文档) ====================
|
|
290
|
+
var renderFileCard = function renderFileCard() {
|
|
291
|
+
var iconType = getFileIconType(file);
|
|
292
|
+
var _getIcon = getIcon(iconType),
|
|
293
|
+
icon = _getIcon.icon,
|
|
294
|
+
color = _getIcon.color;
|
|
295
|
+
var isExternalUrl = url && url.startsWith("http");
|
|
266
296
|
return /*#__PURE__*/_jsxs("div", {
|
|
267
297
|
className: "".concat(styles.fileCard, " ").concat(align === "right" ? "align-right" : "", " ").concat(className || ""),
|
|
268
298
|
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
@@ -271,194 +301,162 @@ var FileGallery = function FileGallery(_ref) {
|
|
|
271
301
|
onClick: function onClick() {
|
|
272
302
|
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(file);
|
|
273
303
|
},
|
|
274
|
-
children: [/*#__PURE__*/
|
|
275
|
-
className: styles.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
preview: _onClick ? false : {
|
|
281
|
-
src: url
|
|
282
|
-
}
|
|
283
|
-
}), file.status === "uploading" && /*#__PURE__*/_jsx("div", {
|
|
284
|
-
className: styles.imageOverlay,
|
|
285
|
-
children: /*#__PURE__*/_jsx(Progress, {
|
|
286
|
-
type: "circle",
|
|
287
|
-
percent: file.progress,
|
|
288
|
-
size: 30,
|
|
289
|
-
strokeColor: "#1677ff"
|
|
290
|
-
})
|
|
291
|
-
})]
|
|
304
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
305
|
+
className: styles.fileIcon,
|
|
306
|
+
style: {
|
|
307
|
+
color: color
|
|
308
|
+
},
|
|
309
|
+
children: icon
|
|
292
310
|
}), /*#__PURE__*/_jsxs("div", {
|
|
293
311
|
className: styles.fileInfo,
|
|
294
|
-
children: [/*#__PURE__*/_jsx(
|
|
312
|
+
children: [isExternalUrl && !_onClick ? /*#__PURE__*/_jsx("a", {
|
|
313
|
+
href: url,
|
|
314
|
+
target: "_blank",
|
|
315
|
+
rel: "noopener noreferrer",
|
|
316
|
+
className: styles.fileLink,
|
|
317
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
318
|
+
title: fileName,
|
|
319
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
320
|
+
className: styles.fileName,
|
|
321
|
+
children: fileName.length > 15 ? "".concat(fileName.substring(0, 15), "...") : fileName
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
}) : /*#__PURE__*/_jsx(Tooltip, {
|
|
295
325
|
title: fileName,
|
|
296
326
|
children: /*#__PURE__*/_jsx("div", {
|
|
297
327
|
className: styles.fileName,
|
|
298
328
|
children: fileName.length > 15 ? "".concat(fileName.substring(0, 15), "...") : fileName
|
|
299
329
|
})
|
|
300
|
-
}),
|
|
330
|
+
}), file.status === "uploading" ? /*#__PURE__*/_jsx(Progress, {
|
|
331
|
+
percent: file.progress,
|
|
332
|
+
size: "small",
|
|
333
|
+
showInfo: false,
|
|
334
|
+
strokeColor: "#1677ff",
|
|
335
|
+
className: styles.progress
|
|
336
|
+
}) : fileSize > 0 && /*#__PURE__*/_jsx("div", {
|
|
301
337
|
className: styles.fileSize,
|
|
302
338
|
children: formatFileSize(fileSize)
|
|
339
|
+
}), file.status === "error" && file.errorMessage && /*#__PURE__*/_jsx("div", {
|
|
340
|
+
style: {
|
|
341
|
+
fontSize: "11px",
|
|
342
|
+
color: "#ff4d4f",
|
|
343
|
+
marginTop: "2px"
|
|
344
|
+
},
|
|
345
|
+
children: file.errorMessage
|
|
303
346
|
})]
|
|
304
|
-
}),
|
|
305
|
-
className: styles.fileRemoveBtn,
|
|
306
|
-
onClick: function onClick() {
|
|
307
|
-
return onRemove(fileId);
|
|
308
|
-
},
|
|
309
|
-
disabled: file.status === "uploading",
|
|
310
|
-
"aria-label": "\u5220\u9664\u6587\u4EF6",
|
|
311
|
-
children: /*#__PURE__*/_jsx(CloseOutlined, {})
|
|
312
|
-
})]
|
|
347
|
+
}), renderRemoveBtn()]
|
|
313
348
|
});
|
|
314
|
-
}
|
|
349
|
+
};
|
|
315
350
|
|
|
316
|
-
//
|
|
317
|
-
if (
|
|
351
|
+
// ==================== 图片渲染 ====================
|
|
352
|
+
if (fileType === "image") {
|
|
353
|
+
// full / preview 模式:独立展示
|
|
354
|
+
if (imageDisplayMode === "full" || imageDisplayMode === "preview") {
|
|
355
|
+
var containerStyle = _objectSpread({}, style);
|
|
356
|
+
if (imageWidth) containerStyle.width = typeof imageWidth === "number" ? "".concat(imageWidth, "px") : imageWidth;
|
|
357
|
+
if (imageHeight) containerStyle.height = typeof imageHeight === "number" ? "".concat(imageHeight, "px") : imageHeight;
|
|
358
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
359
|
+
className: "".concat(imageDisplayMode === "full" ? styles.imageFullMode : styles.imagePreviewMode, " ").concat(className || ""),
|
|
360
|
+
style: containerStyle,
|
|
361
|
+
children: [/*#__PURE__*/_jsx(ImageWithLoading, {
|
|
362
|
+
src: url,
|
|
363
|
+
alt: imageAlt || fileName,
|
|
364
|
+
displayMode: imageDisplayMode,
|
|
365
|
+
loading: imageLoading,
|
|
366
|
+
preview: _onClick ? false : {
|
|
367
|
+
src: url
|
|
368
|
+
},
|
|
369
|
+
fallback: FALLBACK_IMAGE,
|
|
370
|
+
styles: styles
|
|
371
|
+
}), renderUploadOverlay(), renderRemoveBtn()]
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// thumbnail 模式:卡片形式
|
|
318
376
|
return /*#__PURE__*/_jsxs("div", {
|
|
319
377
|
className: "".concat(styles.fileCard, " ").concat(align === "right" ? "align-right" : "", " ").concat(className || ""),
|
|
320
|
-
style: style,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
378
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
379
|
+
cursor: _onClick ? "pointer" : undefined
|
|
380
|
+
}),
|
|
381
|
+
onClick: function onClick() {
|
|
382
|
+
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(file);
|
|
383
|
+
},
|
|
384
|
+
children: [/*#__PURE__*/_jsx(ImageWithLoading, {
|
|
385
|
+
src: url,
|
|
386
|
+
alt: imageAlt || fileName,
|
|
387
|
+
width: imageWidth,
|
|
388
|
+
height: imageHeight,
|
|
389
|
+
displayMode: "thumbnail",
|
|
390
|
+
loading: imageLoading,
|
|
391
|
+
preview: _onClick ? false : {
|
|
392
|
+
src: url
|
|
325
393
|
},
|
|
326
|
-
|
|
327
|
-
|
|
394
|
+
fallback: FALLBACK_IMAGE,
|
|
395
|
+
styles: styles
|
|
396
|
+
}), renderUploadOverlay(), /*#__PURE__*/_jsxs("div", {
|
|
328
397
|
className: styles.fileInfo,
|
|
329
398
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
330
399
|
title: fileName,
|
|
331
400
|
children: /*#__PURE__*/_jsx("div", {
|
|
332
401
|
className: styles.fileName,
|
|
333
|
-
children: fileName
|
|
402
|
+
children: fileName.length > 15 ? "".concat(fileName.substring(0, 15), "...") : fileName
|
|
334
403
|
})
|
|
335
|
-
}), /*#__PURE__*/_jsx("
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
className: styles.mediaWrapper,
|
|
339
|
-
style: {
|
|
340
|
-
width: "100%",
|
|
341
|
-
height: 28
|
|
342
|
-
}
|
|
404
|
+
}), Number(file === null || file === void 0 ? void 0 : file.size) > 0 && /*#__PURE__*/_jsx("div", {
|
|
405
|
+
className: styles.fileSize,
|
|
406
|
+
children: formatFileSize(fileSize)
|
|
343
407
|
})]
|
|
344
|
-
}),
|
|
345
|
-
className: styles.fileRemoveBtn,
|
|
346
|
-
onClick: function onClick() {
|
|
347
|
-
return onRemove(fileId);
|
|
348
|
-
},
|
|
349
|
-
disabled: file.status === "uploading",
|
|
350
|
-
"aria-label": "\u5220\u9664\u6587\u4EF6",
|
|
351
|
-
children: /*#__PURE__*/_jsx(CloseOutlined, {})
|
|
352
|
-
})]
|
|
408
|
+
}), renderRemoveBtn()]
|
|
353
409
|
});
|
|
354
410
|
}
|
|
355
411
|
|
|
356
|
-
//
|
|
357
|
-
if (
|
|
412
|
+
// ==================== 音频渲染(原生播放器,无卡片包裹) ====================
|
|
413
|
+
if (fileType === "audio") {
|
|
358
414
|
return /*#__PURE__*/_jsxs("div", {
|
|
359
|
-
className: "
|
|
360
|
-
style:
|
|
361
|
-
|
|
362
|
-
|
|
415
|
+
className: "file-gallery-audio ".concat(className || ""),
|
|
416
|
+
style: _objectSpread({
|
|
417
|
+
position: "relative",
|
|
418
|
+
width: 268
|
|
419
|
+
}, style),
|
|
420
|
+
children: [/*#__PURE__*/_jsx("audio", _objectSpread({
|
|
421
|
+
src: url,
|
|
422
|
+
controls: true,
|
|
423
|
+
autoPlay: mediaAutoPlay,
|
|
424
|
+
loop: mediaLoop,
|
|
425
|
+
muted: mediaMuted,
|
|
363
426
|
style: {
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
368
|
-
className: styles.fileInfo,
|
|
369
|
-
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
370
|
-
title: fileName,
|
|
371
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
372
|
-
className: styles.fileName,
|
|
373
|
-
children: fileName
|
|
374
|
-
})
|
|
375
|
-
}), /*#__PURE__*/_jsx("video", {
|
|
376
|
-
src: url,
|
|
377
|
-
controls: true,
|
|
378
|
-
className: styles.mediaWrapper,
|
|
379
|
-
style: {
|
|
380
|
-
width: "100%",
|
|
381
|
-
height: 40
|
|
382
|
-
}
|
|
383
|
-
})]
|
|
384
|
-
}), removable && /*#__PURE__*/_jsx("button", {
|
|
385
|
-
className: styles.fileRemoveBtn,
|
|
386
|
-
onClick: function onClick() {
|
|
387
|
-
return onRemove(fileId);
|
|
388
|
-
},
|
|
389
|
-
disabled: file.status === "uploading",
|
|
390
|
-
"aria-label": "\u5220\u9664\u6587\u4EF6",
|
|
391
|
-
children: /*#__PURE__*/_jsx(CloseOutlined, {})
|
|
392
|
-
})]
|
|
427
|
+
width: "100%"
|
|
428
|
+
}
|
|
429
|
+
}, audioProps)), renderRemoveBtn()]
|
|
393
430
|
});
|
|
394
431
|
}
|
|
395
432
|
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
style: {
|
|
412
|
-
color: color
|
|
413
|
-
},
|
|
414
|
-
children: icon
|
|
415
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
416
|
-
className: styles.fileInfo,
|
|
417
|
-
children: [isExternalUrl && !_onClick ? /*#__PURE__*/_jsx("a", {
|
|
418
|
-
href: url,
|
|
419
|
-
target: "_blank",
|
|
420
|
-
rel: "noopener noreferrer",
|
|
421
|
-
className: styles.fileLink,
|
|
422
|
-
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
423
|
-
title: fileName,
|
|
424
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
425
|
-
className: styles.fileName,
|
|
426
|
-
children: fileName.length > 15 ? "".concat(fileName.substring(0, 15), "...") : fileName
|
|
427
|
-
})
|
|
428
|
-
})
|
|
429
|
-
}) : /*#__PURE__*/_jsx(Tooltip, {
|
|
430
|
-
title: fileName,
|
|
431
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
432
|
-
className: styles.fileName,
|
|
433
|
-
children: fileName.length > 15 ? "".concat(fileName.substring(0, 15), "...") : fileName
|
|
434
|
-
})
|
|
435
|
-
}), file.status === "uploading" ? /*#__PURE__*/_jsx(Progress, {
|
|
436
|
-
percent: file.progress,
|
|
437
|
-
size: "small",
|
|
438
|
-
showInfo: false,
|
|
439
|
-
strokeColor: "#1677ff",
|
|
440
|
-
className: styles.progress
|
|
441
|
-
}) : fileSize > 0 && /*#__PURE__*/_jsx("div", {
|
|
442
|
-
className: styles.fileSize,
|
|
443
|
-
children: formatFileSize(fileSize)
|
|
444
|
-
}), file.status === "error" && file.errorMessage && /*#__PURE__*/_jsx("div", {
|
|
433
|
+
// ==================== 视频渲染(原生播放器,无卡片包裹) ====================
|
|
434
|
+
if (fileType === "video") {
|
|
435
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
436
|
+
className: "file-gallery-video ".concat(className || ""),
|
|
437
|
+
style: _objectSpread({
|
|
438
|
+
position: "relative",
|
|
439
|
+
width: 268
|
|
440
|
+
}, style),
|
|
441
|
+
children: [/*#__PURE__*/_jsx("video", _objectSpread({
|
|
442
|
+
src: url,
|
|
443
|
+
controls: true,
|
|
444
|
+
autoPlay: mediaAutoPlay,
|
|
445
|
+
loop: mediaLoop,
|
|
446
|
+
muted: mediaMuted,
|
|
447
|
+
poster: mediaPoster,
|
|
445
448
|
style: {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
})]
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
disabled: file.status === "uploading",
|
|
458
|
-
"aria-label": "\u5220\u9664\u6587\u4EF6",
|
|
459
|
-
children: /*#__PURE__*/_jsx(CloseOutlined, {})
|
|
460
|
-
})]
|
|
461
|
-
});
|
|
449
|
+
width: "100%",
|
|
450
|
+
aspectRatio: "16 / 9",
|
|
451
|
+
borderRadius: 8,
|
|
452
|
+
background: "#000"
|
|
453
|
+
}
|
|
454
|
+
}, videoProps)), renderRemoveBtn()]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ==================== 其他文件(附件卡片) ====================
|
|
459
|
+
return renderFileCard();
|
|
462
460
|
};
|
|
463
461
|
export default FileGallery;
|
|
464
462
|
//# sourceMappingURL=index.js.map
|