bhd-components 0.10.17 → 0.10.19
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/index.esm.es5.development.js +76 -51
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +1 -1
- package/dist/vendor.esm.es5.production.js +1 -1
- package/es2017/AIMessageList/components/copyIcon/index.js +0 -1
- package/es2017/AIMessageList/components/fileList/index.js +53 -29
- package/es2017/AIMessageList/components/footer/index.js +15 -8
- package/es2017/AIMessageList/components/referencesIcon/index.js +2 -3
- package/es2017/AIMessageList/components/renderReferrnce/index.js +0 -4
- package/es2017/AIMessageList/components/virtuosoList/index.js +0 -4
- package/es2017/AIMessageList/type.d.ts +2 -1
- package/esm/AIMessageList/components/copyIcon/index.js +0 -1
- package/esm/AIMessageList/components/fileList/index.js +56 -30
- package/esm/AIMessageList/components/footer/index.js +18 -10
- package/esm/AIMessageList/components/referencesIcon/index.js +2 -3
- package/esm/AIMessageList/components/renderReferrnce/index.js +0 -4
- package/esm/AIMessageList/components/virtuosoList/index.js +0 -4
- package/esm/AIMessageList/type.d.ts +2 -1
- package/package.json +1 -1
|
@@ -6,17 +6,16 @@ import styles from "./index.module.less";
|
|
|
6
6
|
import { fileIconRender, statusRender } from "./fileIcon";
|
|
7
7
|
import { CloseCircleFilled, DoubleRightOutlined } from "../../../icons";
|
|
8
8
|
import { guidGenerator } from "../../../utils/number";
|
|
9
|
-
import { Upload } from "antd";
|
|
10
9
|
// 通过文件名 获取文件后缀
|
|
11
10
|
const getSuffix = (fileName)=>{
|
|
12
11
|
return fileName.split(".").pop().toLowerCase();
|
|
13
12
|
};
|
|
14
13
|
const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
15
|
-
const { prefix, fileUpload, errorCallback, changeFileCanSending } = props;
|
|
16
|
-
console.log("fileUpload", fileUpload);
|
|
14
|
+
const { prefix, fileUpload, errorCallback, changeFileCanSending, onChange } = props;
|
|
17
15
|
const [fileList, setFileList] = useState([]);
|
|
18
16
|
const [page, setPage] = useState(1);
|
|
19
17
|
const [pageSize, setPageSize] = useState(5);
|
|
18
|
+
const recordListLength = useRef(0);
|
|
20
19
|
const recordObj = useRef({
|
|
21
20
|
page: page,
|
|
22
21
|
pageSize: pageSize,
|
|
@@ -26,6 +25,11 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
26
25
|
recordObj.current.page = page;
|
|
27
26
|
recordObj.current.pageSize = pageSize;
|
|
28
27
|
recordObj.current.fileList = fileList;
|
|
28
|
+
onChange && onChange({
|
|
29
|
+
page,
|
|
30
|
+
pageSize,
|
|
31
|
+
fileList
|
|
32
|
+
});
|
|
29
33
|
}, [
|
|
30
34
|
page,
|
|
31
35
|
pageSize,
|
|
@@ -60,10 +64,11 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
60
64
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
61
65
|
};
|
|
62
66
|
const clearFileList = ()=>{
|
|
67
|
+
recordListLength.current = 0;
|
|
63
68
|
setFileList([]);
|
|
64
69
|
};
|
|
65
70
|
const vaildFile = (file, fileId)=>{
|
|
66
|
-
if (fileUpload.maxCount > 0 &&
|
|
71
|
+
if (fileUpload.maxCount > 0 && recordListLength.current + 1 > fileUpload.maxCount) {
|
|
67
72
|
errorCallback({
|
|
68
73
|
type: "fileCountOver",
|
|
69
74
|
message: "上传失败,文件数量超过限制"
|
|
@@ -112,8 +117,8 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
112
117
|
return true;
|
|
113
118
|
};
|
|
114
119
|
const addFile = (file, fileId)=>{
|
|
115
|
-
console.log("addFileaddFile", file, fileUpload);
|
|
116
120
|
if (vaildFile(file, fileId)) {
|
|
121
|
+
recordListLength.current += 1;
|
|
117
122
|
// 等待上传
|
|
118
123
|
// 判断是否存在等待上传的文件
|
|
119
124
|
setFileList((fileList)=>{
|
|
@@ -199,13 +204,14 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
199
204
|
// 删除文件
|
|
200
205
|
const deleteFile = (fileId)=>{
|
|
201
206
|
let fileObj = null;
|
|
207
|
+
recordListLength.current -= 0;
|
|
202
208
|
setFileList((fileList)=>{
|
|
203
209
|
return fileList.filter((item)=>{
|
|
204
210
|
if (item.fileId === fileId) {
|
|
205
211
|
fileObj = item;
|
|
206
|
-
return
|
|
212
|
+
return false;
|
|
207
213
|
}
|
|
208
|
-
return
|
|
214
|
+
return true;
|
|
209
215
|
});
|
|
210
216
|
});
|
|
211
217
|
// 删除文件时如果删除的是最后一条 则page-1
|
|
@@ -245,6 +251,22 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
245
251
|
setPage(page);
|
|
246
252
|
setPageSize(pageSize);
|
|
247
253
|
};
|
|
254
|
+
const retryUploadFile = (fileItem)=>{
|
|
255
|
+
setFileList((fileList)=>{
|
|
256
|
+
let uploadingList = fileList.filter((item)=>item.status === "uploading");
|
|
257
|
+
return fileList.map((item)=>{
|
|
258
|
+
if (fileItem.fileId === item.fileId) {
|
|
259
|
+
if (uploadingList.length >= fileUpload.mapUploadCount) {
|
|
260
|
+
item.status = "waiting";
|
|
261
|
+
} else {
|
|
262
|
+
item.status = "uploading";
|
|
263
|
+
uploadFile(item.source);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return item;
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
248
270
|
const list = fileList.slice((page - 1) * pageSize, page * pageSize);
|
|
249
271
|
if (list.length === 0) return null;
|
|
250
272
|
return /*#__PURE__*/ _jsxs("div", {
|
|
@@ -253,10 +275,7 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
253
275
|
page !== 1 && /*#__PURE__*/ _jsx("div", {
|
|
254
276
|
className: `${getCls("footer-fileList-pre")}`,
|
|
255
277
|
onClick: ()=>changePage(page - 1),
|
|
256
|
-
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
|
|
257
|
-
onPointerEnterCapture: undefined,
|
|
258
|
-
onPointerLeaveCapture: undefined
|
|
259
|
-
})
|
|
278
|
+
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {})
|
|
260
279
|
}),
|
|
261
280
|
/*#__PURE__*/ _jsx("div", {
|
|
262
281
|
className: `${getCls("footer-fileList-list")}`,
|
|
@@ -273,18 +292,28 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
273
292
|
title: item.name,
|
|
274
293
|
children: item.name
|
|
275
294
|
}),
|
|
276
|
-
item.status === "uploadError" ?
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
295
|
+
item.status === "uploadError" ? // <Upload
|
|
296
|
+
// fileList={[]}
|
|
297
|
+
// accept={fileUpload.accept}
|
|
298
|
+
// customRequest={(options: any) =>
|
|
299
|
+
// addFile(options.file, item.fileId)
|
|
300
|
+
// }
|
|
301
|
+
// multiple={false}
|
|
302
|
+
// >
|
|
303
|
+
// <div
|
|
304
|
+
// className={`${getCls("footer-fileList-listItem-status")}`}
|
|
305
|
+
// style={{ cursor: "pointer" }}
|
|
306
|
+
// >
|
|
307
|
+
// {statusRender(item.status, fileUpload.statusText)}
|
|
308
|
+
// </div>
|
|
309
|
+
// </Upload>
|
|
310
|
+
/*#__PURE__*/ _jsx("div", {
|
|
311
|
+
className: `${getCls("footer-fileList-listItem-status")}`,
|
|
312
|
+
style: {
|
|
313
|
+
cursor: "pointer"
|
|
314
|
+
},
|
|
315
|
+
onClick: ()=>retryUploadFile(item),
|
|
316
|
+
children: statusRender(item.status, fileUpload.statusText)
|
|
288
317
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
289
318
|
className: `${getCls("footer-fileList-listItem-status")}`,
|
|
290
319
|
children: statusRender(item.status, fileUpload.statusText)
|
|
@@ -292,8 +321,6 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
292
321
|
/*#__PURE__*/ _jsx("div", {
|
|
293
322
|
className: `${getCls("footer-fileList-listItem-delete")}`,
|
|
294
323
|
children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
|
|
295
|
-
onPointerEnterCapture: undefined,
|
|
296
|
-
onPointerLeaveCapture: undefined,
|
|
297
324
|
onClick: ()=>deleteFile(item.fileId)
|
|
298
325
|
})
|
|
299
326
|
})
|
|
@@ -304,10 +331,7 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
304
331
|
page * pageSize < fileList.length && /*#__PURE__*/ _jsx("div", {
|
|
305
332
|
className: `${getCls("footer-fileList-next")}`,
|
|
306
333
|
onClick: ()=>changePage(page + 1),
|
|
307
|
-
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
|
|
308
|
-
onPointerEnterCapture: undefined,
|
|
309
|
-
onPointerLeaveCapture: undefined
|
|
310
|
-
})
|
|
334
|
+
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {})
|
|
311
335
|
})
|
|
312
336
|
]
|
|
313
337
|
});
|
|
@@ -38,6 +38,11 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
38
38
|
const [sending, setSending] = useState(false);
|
|
39
39
|
const [fileCanSending, setFileCanSending] = useState(true); // 是否允许发送 关联文件
|
|
40
40
|
const updateMsgRef = useRef(null);
|
|
41
|
+
const recordFileList = useRef({
|
|
42
|
+
page: 1,
|
|
43
|
+
pageSize: 5,
|
|
44
|
+
fileList: []
|
|
45
|
+
});
|
|
41
46
|
// const [referencesSource, setReferencesSource] = useState<referenceType>({
|
|
42
47
|
// type: "file",
|
|
43
48
|
// value: {
|
|
@@ -146,7 +151,6 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
146
151
|
fileUpload: fileUpload,
|
|
147
152
|
customRequest: (options)=>{
|
|
148
153
|
var _fileListRef_current;
|
|
149
|
-
console.log("customRequestcustomRequest", options);
|
|
150
154
|
(_fileListRef_current = fileListRef.current) === null || _fileListRef_current === void 0 ? void 0 : _fileListRef_current.addFile(options.file);
|
|
151
155
|
}
|
|
152
156
|
});
|
|
@@ -195,11 +199,11 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
195
199
|
};
|
|
196
200
|
// 发现消息
|
|
197
201
|
const sendMsg = (value)=>{
|
|
198
|
-
console.log("发送消息:", value);
|
|
199
202
|
if (value.trim().length === 0) {
|
|
200
203
|
throw new Error("消息不能为空");
|
|
201
204
|
return;
|
|
202
205
|
}
|
|
206
|
+
recordRef.current.value = value;
|
|
203
207
|
apiRef.contentApi.addMsg({
|
|
204
208
|
id: guidGenerator(),
|
|
205
209
|
createTime: new Date().getTime(),
|
|
@@ -232,7 +236,6 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
232
236
|
const { url, method = "POST", headers = ()=>({}), params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {}, beforeSendMsg = ()=>Promise.resolve() } = sendMsgAjaxParams;
|
|
233
237
|
ctrl.current = new AbortController();
|
|
234
238
|
// apiRef
|
|
235
|
-
console.log("apiRef", apiRef);
|
|
236
239
|
let msgId = "inputing";
|
|
237
240
|
let createTime = new Date().getTime();
|
|
238
241
|
if (recordObj) {
|
|
@@ -281,6 +284,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
281
284
|
];
|
|
282
285
|
}
|
|
283
286
|
beforeSendMsg(...arg).then((beforeInfo)=>{
|
|
287
|
+
let bodyParams = params(...arg, beforeInfo);
|
|
284
288
|
const callback = ()=>{
|
|
285
289
|
let isClose = false;
|
|
286
290
|
const closeCallback = ()=>{
|
|
@@ -292,7 +296,6 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
292
296
|
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
293
297
|
}
|
|
294
298
|
apiRef.contentApi.setSendingId("");
|
|
295
|
-
console.log("onclose: ", recordMsgObj);
|
|
296
299
|
};
|
|
297
300
|
fetchEventSource(url, _object_spread({
|
|
298
301
|
method,
|
|
@@ -300,7 +303,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
300
303
|
"Content-Type": "application/json",
|
|
301
304
|
Accept: "text/event-stream,application/json"
|
|
302
305
|
}, headers()),
|
|
303
|
-
body:
|
|
306
|
+
body: bodyParams,
|
|
304
307
|
openWhenHidden: true,
|
|
305
308
|
signal: ctrl.current.signal,
|
|
306
309
|
onopen: (res)=>{
|
|
@@ -314,7 +317,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
314
317
|
return null;
|
|
315
318
|
},
|
|
316
319
|
onmessage: (ev)=>{
|
|
317
|
-
let data = onMessage(ev, closeCallback);
|
|
320
|
+
let data = onMessage(ev, closeCallback, bodyParams, msgId);
|
|
318
321
|
if (recordObj) {
|
|
319
322
|
data.id = recordObj.id;
|
|
320
323
|
}
|
|
@@ -344,7 +347,6 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
344
347
|
if (recordMsgObj.id) {
|
|
345
348
|
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
346
349
|
}
|
|
347
|
-
console.log("onerror: ", err);
|
|
348
350
|
}
|
|
349
351
|
}, coverProps));
|
|
350
352
|
};
|
|
@@ -374,7 +376,12 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
374
376
|
fileUpload: fileUpload,
|
|
375
377
|
ref: fileListRef,
|
|
376
378
|
errorCallback: errorCallback,
|
|
377
|
-
changeFileCanSending: setFileCanSending
|
|
379
|
+
changeFileCanSending: setFileCanSending,
|
|
380
|
+
onChange: ({ page, pageSize, fileList })=>{
|
|
381
|
+
recordFileList.current.fileList = fileList;
|
|
382
|
+
recordFileList.current.page = page;
|
|
383
|
+
recordFileList.current.pageSize = pageSize;
|
|
384
|
+
}
|
|
378
385
|
})
|
|
379
386
|
}),
|
|
380
387
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -29,9 +29,7 @@ const ReferencesIcon = (props)=>{
|
|
|
29
29
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
30
30
|
};
|
|
31
31
|
const clickFn = ()=>{
|
|
32
|
-
console.log("apiRef", apiRef);
|
|
33
32
|
if (apiRef && apiRef.footerApi) {
|
|
34
|
-
console.log("itemitem", item);
|
|
35
33
|
if (item.type === "file") {
|
|
36
34
|
apiRef.footerApi.setReferences({
|
|
37
35
|
type: "file",
|
|
@@ -41,7 +39,8 @@ const ReferencesIcon = (props)=>{
|
|
|
41
39
|
fileId: item.id,
|
|
42
40
|
url: "",
|
|
43
41
|
status: "success",
|
|
44
|
-
source: null
|
|
42
|
+
source: null,
|
|
43
|
+
size: 0
|
|
45
44
|
},
|
|
46
45
|
source: item
|
|
47
46
|
});
|
|
@@ -23,8 +23,6 @@ const References = (props)=>{
|
|
|
23
23
|
/*#__PURE__*/ _jsx("div", {
|
|
24
24
|
className: `${getCls("footerReferences_right")}`,
|
|
25
25
|
children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
|
|
26
|
-
onPointerEnterCapture: undefined,
|
|
27
|
-
onPointerLeaveCapture: undefined,
|
|
28
26
|
onClick: ()=>deleteReferences()
|
|
29
27
|
})
|
|
30
28
|
})
|
|
@@ -55,8 +53,6 @@ const References = (props)=>{
|
|
|
55
53
|
/*#__PURE__*/ _jsx("div", {
|
|
56
54
|
className: `${getCls("footerReferences_right")}`,
|
|
57
55
|
children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
|
|
58
|
-
onPointerEnterCapture: undefined,
|
|
59
|
-
onPointerLeaveCapture: undefined,
|
|
60
56
|
onClick: ()=>deleteReferences()
|
|
61
57
|
})
|
|
62
58
|
})
|
|
@@ -180,7 +180,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
180
180
|
}
|
|
181
181
|
let list = [];
|
|
182
182
|
if (msg.location === "right" && msg.fileList && msg.fileList.length > 0) {
|
|
183
|
-
console.log("fileList", msg, msg.fileList);
|
|
184
183
|
msg.fileList.map((item)=>{
|
|
185
184
|
list.push({
|
|
186
185
|
type: "file",
|
|
@@ -218,7 +217,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
218
217
|
setLoading(true);
|
|
219
218
|
return getList(page, pageSize).then((listObj)=>{
|
|
220
219
|
setLoading(false);
|
|
221
|
-
console.log("listObjlistObj", listObj);
|
|
222
220
|
setDataSource((data)=>{
|
|
223
221
|
return [
|
|
224
222
|
...data,
|
|
@@ -357,7 +355,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
357
355
|
const topDom = dom.querySelector("." + styles["msgItem-action-popover-floatTop"]);
|
|
358
356
|
const bottomDom = dom.querySelector("." + styles["msgItem-action-popover-floatBottom"]);
|
|
359
357
|
if (!topDom || !bottomDom) return;
|
|
360
|
-
console.log("itemitem", dom, container);
|
|
361
358
|
let con_obj = container.getBoundingClientRect(); // 外层盒子
|
|
362
359
|
let dom_obj = dom.getBoundingClientRect(); // 鼠标滑过元素
|
|
363
360
|
let y = dom_obj.y - con_obj.y;
|
|
@@ -373,7 +370,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
373
370
|
topDom.style.cssText = "display:flex";
|
|
374
371
|
}
|
|
375
372
|
} else {
|
|
376
|
-
console.log("yyyy", y, dom_obj, con_obj, y + dom_obj.height < con_obj.height);
|
|
377
373
|
// 元素top不在可视区域内
|
|
378
374
|
if (y + dom_obj.height < con_obj.height) {
|
|
379
375
|
// 底部在可视区域内
|
|
@@ -110,7 +110,7 @@ export interface sendMsgAjaxParams {
|
|
|
110
110
|
beforeInfo: any
|
|
111
111
|
) => string;
|
|
112
112
|
onOpen?: (res: Response, onOpenProps: onOpenProps) => void;
|
|
113
|
-
onMessage?: (ev: EventSourceMessage,closeCallback:()=>void) => { id: string; content: string };
|
|
113
|
+
onMessage?: (ev: EventSourceMessage,closeCallback:()=>void,bodyParams:string,msgId:string) => { id: string; content: string };
|
|
114
114
|
onClose?: () => void;
|
|
115
115
|
onError?: (err: any) => void;
|
|
116
116
|
coverProps?: object;
|
|
@@ -203,6 +203,7 @@ export interface fileListProps {
|
|
|
203
203
|
fileUpload: fileUploadProps;
|
|
204
204
|
errorCallback: (error: errorMessageProps) => void;
|
|
205
205
|
changeFileCanSending: (flag: boolean) => void;
|
|
206
|
+
onChange:(obj:{page:number,pageSize:number,fileList:fileCustomProps[]})=>void
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
// file 自定义对象
|
|
@@ -8,17 +8,16 @@ import styles from "./index.module.less";
|
|
|
8
8
|
import { fileIconRender, statusRender } from "./fileIcon";
|
|
9
9
|
import { CloseCircleFilled, DoubleRightOutlined } from "../../../icons";
|
|
10
10
|
import { guidGenerator } from "../../../utils/number";
|
|
11
|
-
import { Upload } from "antd";
|
|
12
11
|
// 通过文件名 获取文件后缀
|
|
13
12
|
var getSuffix = function(fileName) {
|
|
14
13
|
return fileName.split(".").pop().toLowerCase();
|
|
15
14
|
};
|
|
16
15
|
var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
17
|
-
var prefix = props.prefix, fileUpload = props.fileUpload, errorCallback = props.errorCallback, changeFileCanSending = props.changeFileCanSending;
|
|
18
|
-
console.log("fileUpload", fileUpload);
|
|
16
|
+
var prefix = props.prefix, fileUpload = props.fileUpload, errorCallback = props.errorCallback, changeFileCanSending = props.changeFileCanSending, onChange = props.onChange;
|
|
19
17
|
var _useState = _sliced_to_array(useState([]), 2), fileList = _useState[0], setFileList = _useState[1];
|
|
20
18
|
var _useState1 = _sliced_to_array(useState(1), 2), page = _useState1[0], setPage = _useState1[1];
|
|
21
19
|
var _useState2 = _sliced_to_array(useState(5), 2), pageSize = _useState2[0], setPageSize = _useState2[1];
|
|
20
|
+
var recordListLength = useRef(0);
|
|
22
21
|
var recordObj = useRef({
|
|
23
22
|
page: page,
|
|
24
23
|
pageSize: pageSize,
|
|
@@ -28,6 +27,11 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
28
27
|
recordObj.current.page = page;
|
|
29
28
|
recordObj.current.pageSize = pageSize;
|
|
30
29
|
recordObj.current.fileList = fileList;
|
|
30
|
+
onChange && onChange({
|
|
31
|
+
page: page,
|
|
32
|
+
pageSize: pageSize,
|
|
33
|
+
fileList: fileList
|
|
34
|
+
});
|
|
31
35
|
}, [
|
|
32
36
|
page,
|
|
33
37
|
pageSize,
|
|
@@ -66,10 +70,11 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
66
70
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
67
71
|
};
|
|
68
72
|
var clearFileList = function() {
|
|
73
|
+
recordListLength.current = 0;
|
|
69
74
|
setFileList([]);
|
|
70
75
|
};
|
|
71
76
|
var vaildFile = function(file, fileId) {
|
|
72
|
-
if (fileUpload.maxCount > 0 &&
|
|
77
|
+
if (fileUpload.maxCount > 0 && recordListLength.current + 1 > fileUpload.maxCount) {
|
|
73
78
|
errorCallback({
|
|
74
79
|
type: "fileCountOver",
|
|
75
80
|
message: "上传失败,文件数量超过限制"
|
|
@@ -120,8 +125,8 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
120
125
|
return true;
|
|
121
126
|
};
|
|
122
127
|
var addFile = function(file, fileId) {
|
|
123
|
-
console.log("addFileaddFile", file, fileUpload);
|
|
124
128
|
if (vaildFile(file, fileId)) {
|
|
129
|
+
recordListLength.current += 1;
|
|
125
130
|
// 等待上传
|
|
126
131
|
// 判断是否存在等待上传的文件
|
|
127
132
|
setFileList(function(fileList) {
|
|
@@ -209,13 +214,14 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
209
214
|
// 删除文件
|
|
210
215
|
var deleteFile = function(fileId) {
|
|
211
216
|
var fileObj = null;
|
|
217
|
+
recordListLength.current -= 0;
|
|
212
218
|
setFileList(function(fileList) {
|
|
213
219
|
return fileList.filter(function(item) {
|
|
214
220
|
if (item.fileId === fileId) {
|
|
215
221
|
fileObj = item;
|
|
216
|
-
return
|
|
222
|
+
return false;
|
|
217
223
|
}
|
|
218
|
-
return
|
|
224
|
+
return true;
|
|
219
225
|
});
|
|
220
226
|
});
|
|
221
227
|
// 删除文件时如果删除的是最后一条 则page-1
|
|
@@ -259,6 +265,24 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
259
265
|
setPage(page);
|
|
260
266
|
setPageSize(pageSize);
|
|
261
267
|
};
|
|
268
|
+
var retryUploadFile = function(fileItem) {
|
|
269
|
+
setFileList(function(fileList) {
|
|
270
|
+
var uploadingList = fileList.filter(function(item) {
|
|
271
|
+
return item.status === "uploading";
|
|
272
|
+
});
|
|
273
|
+
return fileList.map(function(item) {
|
|
274
|
+
if (fileItem.fileId === item.fileId) {
|
|
275
|
+
if (uploadingList.length >= fileUpload.mapUploadCount) {
|
|
276
|
+
item.status = "waiting";
|
|
277
|
+
} else {
|
|
278
|
+
item.status = "uploading";
|
|
279
|
+
uploadFile(item.source);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return item;
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
262
286
|
var list = fileList.slice((page - 1) * pageSize, page * pageSize);
|
|
263
287
|
if (list.length === 0) return null;
|
|
264
288
|
return /*#__PURE__*/ _jsxs("div", {
|
|
@@ -269,10 +293,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
269
293
|
onClick: function() {
|
|
270
294
|
return changePage(page - 1);
|
|
271
295
|
},
|
|
272
|
-
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
|
|
273
|
-
onPointerEnterCapture: undefined,
|
|
274
|
-
onPointerLeaveCapture: undefined
|
|
275
|
-
})
|
|
296
|
+
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {})
|
|
276
297
|
}),
|
|
277
298
|
/*#__PURE__*/ _jsx("div", {
|
|
278
299
|
className: "".concat(getCls("footer-fileList-list")),
|
|
@@ -289,20 +310,30 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
289
310
|
title: item.name,
|
|
290
311
|
children: item.name
|
|
291
312
|
}),
|
|
292
|
-
item.status === "uploadError" ?
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
313
|
+
item.status === "uploadError" ? // <Upload
|
|
314
|
+
// fileList={[]}
|
|
315
|
+
// accept={fileUpload.accept}
|
|
316
|
+
// customRequest={(options: any) =>
|
|
317
|
+
// addFile(options.file, item.fileId)
|
|
318
|
+
// }
|
|
319
|
+
// multiple={false}
|
|
320
|
+
// >
|
|
321
|
+
// <div
|
|
322
|
+
// className={`${getCls("footer-fileList-listItem-status")}`}
|
|
323
|
+
// style={{ cursor: "pointer" }}
|
|
324
|
+
// >
|
|
325
|
+
// {statusRender(item.status, fileUpload.statusText)}
|
|
326
|
+
// </div>
|
|
327
|
+
// </Upload>
|
|
328
|
+
/*#__PURE__*/ _jsx("div", {
|
|
329
|
+
className: "".concat(getCls("footer-fileList-listItem-status")),
|
|
330
|
+
style: {
|
|
331
|
+
cursor: "pointer"
|
|
297
332
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
cursor: "pointer"
|
|
303
|
-
},
|
|
304
|
-
children: statusRender(item.status, fileUpload.statusText)
|
|
305
|
-
})
|
|
333
|
+
onClick: function() {
|
|
334
|
+
return retryUploadFile(item);
|
|
335
|
+
},
|
|
336
|
+
children: statusRender(item.status, fileUpload.statusText)
|
|
306
337
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
307
338
|
className: "".concat(getCls("footer-fileList-listItem-status")),
|
|
308
339
|
children: statusRender(item.status, fileUpload.statusText)
|
|
@@ -310,8 +341,6 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
310
341
|
/*#__PURE__*/ _jsx("div", {
|
|
311
342
|
className: "".concat(getCls("footer-fileList-listItem-delete")),
|
|
312
343
|
children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
|
|
313
|
-
onPointerEnterCapture: undefined,
|
|
314
|
-
onPointerLeaveCapture: undefined,
|
|
315
344
|
onClick: function() {
|
|
316
345
|
return deleteFile(item.fileId);
|
|
317
346
|
}
|
|
@@ -326,10 +355,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
326
355
|
onClick: function() {
|
|
327
356
|
return changePage(page + 1);
|
|
328
357
|
},
|
|
329
|
-
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
|
|
330
|
-
onPointerEnterCapture: undefined,
|
|
331
|
-
onPointerLeaveCapture: undefined
|
|
332
|
-
})
|
|
358
|
+
children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {})
|
|
333
359
|
})
|
|
334
360
|
]
|
|
335
361
|
});
|
|
@@ -42,6 +42,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
42
42
|
var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
|
|
43
43
|
var _useState2 = _sliced_to_array(useState(true), 2), fileCanSending = _useState2[0], setFileCanSending = _useState2[1]; // 是否允许发送 关联文件
|
|
44
44
|
var updateMsgRef = useRef(null);
|
|
45
|
+
var recordFileList = useRef({
|
|
46
|
+
page: 1,
|
|
47
|
+
pageSize: 5,
|
|
48
|
+
fileList: []
|
|
49
|
+
});
|
|
45
50
|
// const [referencesSource, setReferencesSource] = useState<referenceType>({
|
|
46
51
|
// type: "file",
|
|
47
52
|
// value: {
|
|
@@ -150,7 +155,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
150
155
|
fileUpload: fileUpload,
|
|
151
156
|
customRequest: function(options) {
|
|
152
157
|
var _fileListRef_current;
|
|
153
|
-
console.log("customRequestcustomRequest", options);
|
|
154
158
|
(_fileListRef_current = fileListRef.current) === null || _fileListRef_current === void 0 ? void 0 : _fileListRef_current.addFile(options.file);
|
|
155
159
|
}
|
|
156
160
|
});
|
|
@@ -199,11 +203,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
199
203
|
};
|
|
200
204
|
// 发现消息
|
|
201
205
|
var sendMsg = function(value) {
|
|
202
|
-
console.log("发送消息:", value);
|
|
203
206
|
if (value.trim().length === 0) {
|
|
204
207
|
throw new Error("消息不能为空");
|
|
205
208
|
return;
|
|
206
209
|
}
|
|
210
|
+
recordRef.current.value = value;
|
|
207
211
|
apiRef.contentApi.addMsg({
|
|
208
212
|
id: guidGenerator(),
|
|
209
213
|
createTime: new Date().getTime(),
|
|
@@ -244,7 +248,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
244
248
|
} : _sendMsgAjaxParams_beforeSendMsg;
|
|
245
249
|
ctrl.current = new AbortController();
|
|
246
250
|
// apiRef
|
|
247
|
-
console.log("apiRef", apiRef);
|
|
248
251
|
var msgId = "inputing";
|
|
249
252
|
var createTime = new Date().getTime();
|
|
250
253
|
if (recordObj) {
|
|
@@ -293,6 +296,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
293
296
|
];
|
|
294
297
|
}
|
|
295
298
|
beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
|
|
299
|
+
var bodyParams = params.apply(void 0, _to_consumable_array(arg).concat([
|
|
300
|
+
beforeInfo
|
|
301
|
+
]));
|
|
296
302
|
var callback = function() {
|
|
297
303
|
var isClose = false;
|
|
298
304
|
var closeCallback = function() {
|
|
@@ -304,7 +310,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
304
310
|
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
305
311
|
}
|
|
306
312
|
apiRef.contentApi.setSendingId("");
|
|
307
|
-
console.log("onclose: ", recordMsgObj);
|
|
308
313
|
};
|
|
309
314
|
fetchEventSource(url, _object_spread({
|
|
310
315
|
method: method,
|
|
@@ -312,9 +317,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
312
317
|
"Content-Type": "application/json",
|
|
313
318
|
Accept: "text/event-stream,application/json"
|
|
314
319
|
}, headers()),
|
|
315
|
-
body:
|
|
316
|
-
beforeInfo
|
|
317
|
-
])),
|
|
320
|
+
body: bodyParams,
|
|
318
321
|
openWhenHidden: true,
|
|
319
322
|
signal: ctrl.current.signal,
|
|
320
323
|
onopen: function(res) {
|
|
@@ -328,7 +331,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
328
331
|
return null;
|
|
329
332
|
},
|
|
330
333
|
onmessage: function(ev) {
|
|
331
|
-
var data = onMessage(ev, closeCallback);
|
|
334
|
+
var data = onMessage(ev, closeCallback, bodyParams, msgId);
|
|
332
335
|
if (recordObj) {
|
|
333
336
|
data.id = recordObj.id;
|
|
334
337
|
}
|
|
@@ -358,7 +361,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
358
361
|
if (recordMsgObj.id) {
|
|
359
362
|
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
360
363
|
}
|
|
361
|
-
console.log("onerror: ", err);
|
|
362
364
|
}
|
|
363
365
|
}, coverProps));
|
|
364
366
|
};
|
|
@@ -388,7 +390,13 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
388
390
|
fileUpload: fileUpload,
|
|
389
391
|
ref: fileListRef,
|
|
390
392
|
errorCallback: errorCallback,
|
|
391
|
-
changeFileCanSending: setFileCanSending
|
|
393
|
+
changeFileCanSending: setFileCanSending,
|
|
394
|
+
onChange: function(param) {
|
|
395
|
+
var page = param.page, pageSize = param.pageSize, fileList = param.fileList;
|
|
396
|
+
recordFileList.current.fileList = fileList;
|
|
397
|
+
recordFileList.current.page = page;
|
|
398
|
+
recordFileList.current.pageSize = pageSize;
|
|
399
|
+
}
|
|
392
400
|
})
|
|
393
401
|
}),
|
|
394
402
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -29,9 +29,7 @@ var ReferencesIcon = function(props) {
|
|
|
29
29
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
30
30
|
};
|
|
31
31
|
var clickFn = function() {
|
|
32
|
-
console.log("apiRef", apiRef);
|
|
33
32
|
if (apiRef && apiRef.footerApi) {
|
|
34
|
-
console.log("itemitem", item);
|
|
35
33
|
if (item.type === "file") {
|
|
36
34
|
apiRef.footerApi.setReferences({
|
|
37
35
|
type: "file",
|
|
@@ -41,7 +39,8 @@ var ReferencesIcon = function(props) {
|
|
|
41
39
|
fileId: item.id,
|
|
42
40
|
url: "",
|
|
43
41
|
status: "success",
|
|
44
|
-
source: null
|
|
42
|
+
source: null,
|
|
43
|
+
size: 0
|
|
45
44
|
},
|
|
46
45
|
source: item
|
|
47
46
|
});
|