bhd-components 0.10.7 → 0.10.9

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.
@@ -129,7 +129,8 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
129
129
  fileId: fileId,
130
130
  url: "",
131
131
  status: "waiting",
132
- source: file
132
+ source: file,
133
+ size: file.size
133
134
  };
134
135
  }
135
136
  return item;
@@ -152,7 +153,8 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
152
153
  fileId: fileId,
153
154
  url: "",
154
155
  status: "uploading",
155
- source: file
156
+ source: file,
157
+ size: file.size
156
158
  };
157
159
  }
158
160
  return item;
@@ -234,7 +236,8 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
234
236
  fileId: params.fileId || guidGenerator(),
235
237
  url: params.url || "",
236
238
  status: params.status || "waiting",
237
- source: file
239
+ source: file,
240
+ size: file.size
238
241
  };
239
242
  return customFile;
240
243
  };
@@ -30,6 +30,8 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
30
30
  if (fileUpload) {
31
31
  fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
32
32
  }
33
+ const footerDomRef = useRef(null);
34
+ const resizeObserverRef = useRef(null);
33
35
  const fileListRef = useRef(null);
34
36
  const ctrl = useRef(); //停止生成ai回答时使用
35
37
  const [textValue, setTextValue] = useState("");
@@ -72,7 +74,9 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
72
74
  }, fileListRef.current);
73
75
  });
74
76
  useEffect(()=>{
77
+ listenerFooterHeight();
75
78
  return ()=>{
79
+ resizeObserverRef.current && resizeObserverRef.current.disconnect();
76
80
  clearTimeout(updateMsgRef.current);
77
81
  };
78
82
  }, []);
@@ -85,6 +89,16 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
85
89
  referencesSource,
86
90
  sending
87
91
  ]);
92
+ // 监听footer变化
93
+ const listenerFooterHeight = ()=>{
94
+ if (!footerDomRef.current) return;
95
+ // 创建ResizeObserver实例
96
+ resizeObserverRef.current = new ResizeObserver((entries)=>{
97
+ apiRef.contentApi && apiRef.contentApi.scrollToBottom();
98
+ });
99
+ // 开始观察footer元素
100
+ resizeObserverRef.current.observe(footerDomRef.current);
101
+ };
88
102
  // 是否允许发送消息
89
103
  const canSendMsg = useMemo(()=>{
90
104
  if (textValue.trim().length === 0) return false;
@@ -186,7 +200,8 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
186
200
  content: value,
187
201
  location: "right",
188
202
  reference: recordRef.current.referencesSource,
189
- source: null
203
+ source: null,
204
+ fileList: fileListRef.current.getFileList()
190
205
  });
191
206
  sendMsgAjax();
192
207
  };
@@ -203,7 +218,8 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
203
218
  content: "正在输入...",
204
219
  location: "left",
205
220
  reference: null,
206
- source: null
221
+ source: null,
222
+ fileList: fileListRef.current.getFileList()
207
223
  });
208
224
  let msgContent = "";
209
225
  setSending(true);
@@ -226,6 +242,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
226
242
  setSending(false);
227
243
  if (recordMsgObj.id) {
228
244
  apiRef.contentApi.recordMsg(recordMsgObj);
245
+ apiRef.contentApi.setSendingId(recordMsgObj.id);
229
246
  }
230
247
  console.log("onclose: ", recordMsgObj);
231
248
  };
@@ -254,11 +271,12 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
254
271
  delete data.content;
255
272
  recordMsgObj = _object_spread({
256
273
  createTime: createTime,
257
- content: msgContent,
274
+ content: msgContent || "正在输入...",
258
275
  location: "left",
259
276
  reference: null,
260
277
  source: null
261
278
  }, data);
279
+ apiRef.contentApi.setSendingId(data.id);
262
280
  apiRef.contentApi.updateMsg(msgId, recordMsgObj);
263
281
  msgId = data.id;
264
282
  updateMsgRef.current = setTimeout(function() {
@@ -292,6 +310,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
292
310
  };
293
311
  return /*#__PURE__*/ _jsx("div", {
294
312
  className: `${getCls("footer")} ${className}`,
313
+ ref: footerDomRef,
295
314
  children: /*#__PURE__*/ _jsxs("div", {
296
315
  className: `${getCls("footerBody")} ${judegTextLengthWarn() ? getCls("footerBodyWarn") : ""}`,
297
316
  children: [
@@ -32,15 +32,30 @@ const ReferencesIcon = (props)=>{
32
32
  console.log("apiRef", apiRef);
33
33
  if (apiRef && apiRef.footerApi) {
34
34
  console.log("itemitem", item);
35
- apiRef.footerApi.setReferences({
36
- type: "text",
37
- value: item.content,
38
- source: item
39
- });
35
+ if (item.type === "file") {
36
+ apiRef.footerApi.setReferences({
37
+ type: "file",
38
+ value: {
39
+ name: item.fileTitle,
40
+ suffix: item.suffix,
41
+ fileId: item.id,
42
+ url: "",
43
+ status: "success",
44
+ source: null
45
+ },
46
+ source: item
47
+ });
48
+ } else {
49
+ apiRef.footerApi.setReferences({
50
+ type: "text",
51
+ value: item.content,
52
+ source: item
53
+ });
54
+ }
40
55
  }
41
56
  };
42
57
  return /*#__PURE__*/ _jsx("div", {
43
- className: `${getCls("msgItem-action-references")}`,
58
+ className: `${getCls("msgItem-action-reference")}`,
44
59
  onClick: ()=>clickFn(),
45
60
  children: referencesIcon
46
61
  });
@@ -1,4 +1,4 @@
1
- .msgItem-action-references {
1
+ .msgItem-action-reference {
2
2
  cursor: pointer;
3
3
  border-radius: 2px;
4
4
  display: flex;
@@ -13,6 +13,7 @@ import CopyIcon from "../copyIcon";
13
13
  import ReferencesIcon from "../referencesIcon";
14
14
  import { UpVoteBtn, DownVoteBtn } from "../remarkBtn";
15
15
  import RefreshBtn from "../refreshBtn";
16
+ import { fileIconRender } from "../fileList/fileIcon";
16
17
  const Header = ({ context })=>{
17
18
  const { prefix, loading } = context;
18
19
  if (!loading) return null;
@@ -44,14 +45,15 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
44
45
  const { prefix, contentConfig, apiRef } = props;
45
46
  const { getList, coverRenderText, msgAction = [
46
47
  "copy",
47
- "references"
48
- ], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{} } = contentConfig;
48
+ "reference"
49
+ ], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{}, helloMsg, fileCustomRender = {} } = contentConfig;
49
50
  const loadMoreProps = contentConfig.loadMore || true;
50
51
  const virtuosoRef = useRef(null);
51
52
  const [loading, setLoading] = useState(false); // 是否加载中
52
53
  const [dataSource, setDataSource] = useState([]);
53
54
  const [firstItemIndex, setFirstItemIndex] = useState(0);
54
55
  const [page, setPage] = useState(1);
56
+ const [sendingId, setSendingId] = useState("");
55
57
  const [pageSize, setPageSize] = useState(contentConfig.pageSize || 30);
56
58
  const [total, setTotal] = useState(0);
57
59
  const timerRef = useRef({
@@ -64,24 +66,14 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
64
66
  pageSize: pageSize,
65
67
  total: total,
66
68
  dataSource: dataSource,
67
- maxPage: Math.ceil(total / pageSize)
69
+ maxPage: Math.ceil(total / pageSize),
70
+ sendingId: ""
68
71
  });
69
72
  const timeRenderCache = useRef(new Map()).current;
70
73
  const htmlRenderCache = useRef(new Map()).current;
71
74
  useImperativeHandle(ref, ()=>{
72
75
  return {
73
- addMsg: (msg)=>{
74
- if (msg.id !== "inputing") {
75
- // 不记录"正在输入..."的消息
76
- onRecordMessage(msg);
77
- }
78
- setDataSource((data)=>{
79
- return [
80
- ...data,
81
- msg
82
- ];
83
- });
84
- },
76
+ addMsg,
85
77
  updateMsg: (id, obj)=>{
86
78
  setDataSource((data)=>{
87
79
  return data.map((item)=>{
@@ -116,17 +108,26 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
116
108
  changeDataSource: (data)=>{
117
109
  setDataSource(data);
118
110
  },
119
- scrollToBottom: function() {
120
- if (!virtuosoRef.current) return;
121
- virtuosoRef.current.scrollToIndex({
122
- index: "LAST",
123
- behavior: "auto"
124
- });
111
+ scrollToBottom,
112
+ setSendingId: (id)=>{
113
+ setSendingId(id);
125
114
  }
126
115
  };
127
116
  });
128
117
  useEffect(()=>{
129
- getData(page, pageSize);
118
+ getData(page, pageSize).then(()=>{
119
+ if (helloMsg) {
120
+ addMsg({
121
+ id: "helloMsg",
122
+ createTime: new Date().getTime(),
123
+ content: helloMsg,
124
+ location: "left",
125
+ reference: null,
126
+ source: null,
127
+ fileList: []
128
+ });
129
+ }
130
+ });
130
131
  let removeFn = delegate(wrapperRef.current, "click", `.${styles.copyCode}`, (event, target)=>{
131
132
  findCopyContent(event);
132
133
  });
@@ -159,32 +160,71 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
159
160
  recordRef.current.total = total;
160
161
  recordRef.current.dataSource = dataSource;
161
162
  recordRef.current.maxPage = Math.ceil(total / pageSize);
163
+ recordRef.current.sendingId = sendingId;
162
164
  }, [
163
165
  page,
164
166
  pageSize,
165
167
  total,
166
- dataSource
168
+ dataSource,
169
+ sendingId
167
170
  ]);
171
+ const addMsg = (msg)=>{
172
+ if (msg.id !== "inputing" && msg.id !== "helloMsg") {
173
+ // 不记录"正在输入..."的消息
174
+ onRecordMessage(msg);
175
+ }
176
+ let list = [];
177
+ if (msg.location === "right" && msg.fileList && msg.fileList.length > 0) {
178
+ console.log("fileList", msg, msg.fileList);
179
+ msg.fileList.map((item)=>{
180
+ list.push({
181
+ type: "file",
182
+ id: item.fileId,
183
+ createTime: msg.createTime,
184
+ content: "",
185
+ location: "right",
186
+ reference: null,
187
+ source: null,
188
+ suffix: item.suffix,
189
+ fileSize: item.size || 0,
190
+ fileTitle: item.name
191
+ });
192
+ });
193
+ }
194
+ list.push(msg);
195
+ setDataSource((data)=>{
196
+ return [
197
+ ...data,
198
+ ...list
199
+ ];
200
+ });
201
+ timerRef.current.scrollTimer = setTimeout(()=>{
202
+ scrollToBottom();
203
+ }, 100);
204
+ };
205
+ const scrollToBottom = ()=>{
206
+ if (!virtuosoRef.current) return;
207
+ virtuosoRef.current.scrollToIndex({
208
+ index: "LAST",
209
+ behavior: "auto"
210
+ });
211
+ };
168
212
  const getData = (page, pageSize)=>{
169
213
  setLoading(true);
170
- clearTimeout(timerRef.current.loadMore);
171
- timerRef.current.loadMore = setTimeout(()=>{
214
+ return getList(page, pageSize).then((listObj)=>{
172
215
  setLoading(false);
173
- getList(page, pageSize).then((listObj)=>{
174
- setLoading(false);
175
- console.log("listObjlistObj", listObj);
176
- setDataSource((data)=>{
177
- return [
178
- ...data,
179
- ...listObj.dataSource
180
- ];
181
- });
182
- setTotal(listObj.total);
183
- setPage(page);
184
- setPageSize(pageSize);
185
- setFirstItemIndex(listObj.total - pageSize * (page - 1));
216
+ console.log("listObjlistObj", listObj);
217
+ setDataSource((data)=>{
218
+ return [
219
+ ...data,
220
+ ...listObj.dataSource
221
+ ];
186
222
  });
187
- }, 500);
223
+ setTotal(listObj.total);
224
+ setPage(page);
225
+ setPageSize(pageSize);
226
+ setFirstItemIndex(listObj.total - pageSize * (page - 1));
227
+ });
188
228
  };
189
229
  const getCls = (clsName)=>{
190
230
  return styles[clsName] + " " + prefix + "-" + clsName;
@@ -199,18 +239,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
199
239
  ]);
200
240
  const itemContent = (index, item)=>{
201
241
  const timeNode = renderTime(item);
202
- let cahceKey = item.id + "-" + item.content;
203
242
  let contentNode = null;
204
- // if (htmlRenderCache.has(cahceKey)) {
205
- // contentNode = htmlRenderCache.get(cahceKey);
206
- // } else {
207
- // const html = markToHtml(item.content, item.id);
208
- // contentNode = <div dangerouslySetInnerHTML={{ __html: html }}></div>;
209
- // if (coverRenderText) {
210
- // contentNode = coverRenderText(item, html);
211
- // }
212
- // htmlRenderCache.set(cahceKey, contentNode);
213
- // }
214
243
  const html = markToHtml(item.content, item.id);
215
244
  contentNode = /*#__PURE__*/ _jsx("div", {
216
245
  dangerouslySetInnerHTML: {
@@ -220,6 +249,38 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
220
249
  if (coverRenderText) {
221
250
  contentNode = coverRenderText(item, html);
222
251
  }
252
+ // item.type = "file";
253
+ // item.suffix = "docx";
254
+ // item.fileTitle = "这是一个文件名称.docx";
255
+ // item.fileSize = "5Mb";
256
+ if (item.type === "file") {
257
+ let renderFileObj = _object_spread({
258
+ fileTitleRender: (item)=>{
259
+ return /*#__PURE__*/ _jsx(_Fragment, {
260
+ children: item.fileTitle
261
+ });
262
+ }
263
+ }, fileCustomRender);
264
+ if (renderFileObj.fileRender) {
265
+ contentNode = renderFileObj.fileRender(item);
266
+ } else {
267
+ contentNode = /*#__PURE__*/ _jsxs("div", {
268
+ className: `${getCls("msgItem-file")}`,
269
+ children: [
270
+ /*#__PURE__*/ _jsx("div", {
271
+ className: `${getCls("msgItem-file-left")}`,
272
+ children: fileIconRender(item.suffix, renderFileObj.iconFileRender)
273
+ }),
274
+ /*#__PURE__*/ _jsx("div", {
275
+ className: `${getCls("msgItem-file-right")}`,
276
+ children: /*#__PURE__*/ _jsx("p", {
277
+ children: renderFileObj.fileTitleRender(item)
278
+ })
279
+ })
280
+ ]
281
+ });
282
+ }
283
+ }
223
284
  // 是否显示时间
224
285
  let itemNode = /*#__PURE__*/ _jsx("div", {
225
286
  className: `${getCls("msgItem")} ${item.location === "left" ? getCls("msgItem-left") : getCls("msgItem-right")}`,
@@ -258,12 +319,30 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
258
319
  let referenceNode = null;
259
320
  if (reference.type === "text") {
260
321
  referenceNode = /*#__PURE__*/ _jsx("div", {
261
- className: `${getCls("msgItem-references-text")}`,
322
+ className: `${getCls("msgItem-reference-text")}`,
262
323
  children: /*#__PURE__*/ _jsx("div", {
263
324
  children: reference.value
264
325
  })
265
326
  });
266
327
  }
328
+ if (reference.type === "file") {
329
+ referenceNode = /*#__PURE__*/ _jsx("div", {
330
+ className: `${getCls("msgItem-reference-file")}`,
331
+ children: /*#__PURE__*/ _jsxs("div", {
332
+ className: `${getCls("msgItem-reference-file-box")}`,
333
+ children: [
334
+ /*#__PURE__*/ _jsx("div", {
335
+ className: `${getCls("msgItem-reference-file-left")}`,
336
+ children: fileIconRender(reference.value.suffix, fileCustomRender.iconFileRender)
337
+ }),
338
+ /*#__PURE__*/ _jsx("div", {
339
+ className: `${getCls("msgItem-reference-file-right")}`,
340
+ children: reference.value.name
341
+ })
342
+ ]
343
+ })
344
+ });
345
+ }
267
346
  if (coverRenderReferences) {
268
347
  return coverRenderReferences(item, referenceNode);
269
348
  } else {
@@ -315,6 +394,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
315
394
  topDom.style.cssText = "";
316
395
  };
317
396
  const renderAction = (location, item)=>{
397
+ if (item.id === "inputing" || item.id === "helloMsg" || item.id === recordRef.current.sendingId) return null;
318
398
  let copyNode = /*#__PURE__*/ _jsx(CopyIcon, {
319
399
  prefix: prefix,
320
400
  content: item.content
@@ -328,6 +408,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
328
408
  prefix: prefix,
329
409
  isActive: item.vote === "up",
330
410
  clickFn: ()=>{
411
+ onVoteChange(item.vote === "up" ? "" : "up", item);
331
412
  setDataSource((data)=>{
332
413
  return data.map((ite)=>{
333
414
  if (item.id === ite.id) {
@@ -336,13 +417,13 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
336
417
  return ite;
337
418
  });
338
419
  });
339
- onVoteChange(item.vote === "up" ? "" : "up", item);
340
420
  }
341
421
  });
342
422
  let DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
343
423
  prefix: prefix,
344
424
  isActive: item.vote === "down",
345
425
  clickFn: ()=>{
426
+ onVoteChange(item.vote === "down" ? "" : "down", item);
346
427
  setDataSource((data)=>{
347
428
  return data.map((ite)=>{
348
429
  if (item.id === ite.id) {
@@ -351,7 +432,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
351
432
  return ite;
352
433
  });
353
434
  });
354
- onVoteChange(item.vote === "down" ? "" : "down", item);
355
435
  }
356
436
  });
357
437
  let RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
@@ -362,6 +442,12 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
362
442
  UpVoteNode = null;
363
443
  DownVoteNode = null;
364
444
  }
445
+ if (item.type === "file") {
446
+ copyNode = null;
447
+ UpVoteNode = null;
448
+ DownVoteNode = null;
449
+ RefreshNode = null;
450
+ }
365
451
  let leftNodes = null;
366
452
  let rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
367
453
  children: [
@@ -377,7 +463,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
377
463
  if (!msgAction.includes("copy")) {
378
464
  copyNode = null;
379
465
  }
380
- if (!msgAction.includes("references")) {
466
+ if (!msgAction.includes("reference")) {
381
467
  referencesNode = null;
382
468
  }
383
469
  if (!msgAction.includes("upVite")) {
@@ -573,6 +659,9 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
573
659
  p[0].innerText = "复制代码";
574
660
  }
575
661
  };
662
+ const onScroll = ()=>{
663
+ console.log("滚动滚动");
664
+ };
576
665
  return /*#__PURE__*/ _jsx("div", {
577
666
  className: `${getCls("virtuosoList-wrapper")}`,
578
667
  ref: wrapperRef,
@@ -597,7 +686,8 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
597
686
  Header: Header
598
687
  },
599
688
  increaseViewportBy: 200,
600
- overscan: 10
689
+ overscan: 10,
690
+ onScroll: onScroll
601
691
  })
602
692
  });
603
693
  });
@@ -71,11 +71,11 @@
71
71
  text-align: right;
72
72
  height: 37px;
73
73
  line-height: 37px;
74
- padding: 0 ;
75
- padding-right: 16px ;
74
+ padding: 0;
75
+ padding-right: 16px;
76
76
  position: relative;
77
77
  cursor: pointer;
78
- font-weight: 400 ;
78
+ font-weight: 400;
79
79
  top: 6px;
80
80
  &.copyCodeFun {
81
81
  display: flex;
@@ -266,6 +266,42 @@
266
266
  border-radius: 0 0 4px 4px;
267
267
  }
268
268
  }
269
+ .msgItem-file {
270
+ display: flex;
271
+ align-items: center;
272
+ padding: 8px 12px;
273
+ background: #fafafa;
274
+ border-radius: 8px;
275
+ border: 1px solid #ebebeb;
276
+ gap: 12px;
277
+ min-width: 216px;
278
+ .msgItem-file-left {
279
+ font-size: 24px;
280
+ display: flex;
281
+ justify-content: center;
282
+ align-items: center;
283
+ padding: 0;
284
+ margin: 0;
285
+ & > i {
286
+ display: flex;
287
+ font-size: 24px;
288
+ }
289
+ }
290
+ .msgItem-file-right {
291
+ font-size: 14px;
292
+ font-weight: 400;
293
+ color: rgba(0, 0, 0, 0.65);
294
+ & > p {
295
+ &:nth-child(1) {
296
+ // margin-bottom: 4px;
297
+ }
298
+ // &:nth-child(2) {
299
+ // font-size: 12px;
300
+ // color: rgba(0, 0, 0, 0.25);
301
+ // }
302
+ }
303
+ }
304
+ }
269
305
  }
270
306
  .msgItem-action {
271
307
  border-top: 1px solid rgba(0, 0, 0, 0.06);
@@ -321,7 +357,7 @@
321
357
  }
322
358
  }
323
359
 
324
- .msgItem-references-text {
360
+ .msgItem-reference-text {
325
361
  padding: 8px;
326
362
  border-radius: 2px;
327
363
  background: #e7e7e7;
@@ -340,6 +376,45 @@
340
376
  word-wrap: break-word;
341
377
  }
342
378
  }
379
+ .msgItem-reference-file {
380
+ padding: 8px;
381
+ border-radius: 2px;
382
+ background: #e7e7e7;
383
+ font-size: 12px;
384
+ color: rgba(0, 0, 0, 0.65);
385
+ margin-top: 8px;
386
+
387
+ .msgItem-reference-file-box {
388
+ display: flex;
389
+ align-items: center;
390
+ gap: 12px;
391
+ background: #fafafa;
392
+ border-radius: 8px;
393
+ border: 1px solid #ebebeb;
394
+ display: flex;
395
+ align-items: center;
396
+ gap: 12px;
397
+ padding: 8px 12px;
398
+ min-width: 216px;
399
+ .msgItem-reference-file-left {
400
+ font-size: 24px;
401
+ display: flex;
402
+ justify-content: center;
403
+ align-items: center;
404
+ padding: 0;
405
+ margin: 0;
406
+ & > i {
407
+ display: flex;
408
+ font-size: 24px;
409
+ }
410
+ }
411
+ .msgItem-reference-file-right {
412
+ font-size: 14px;
413
+ font-weight: 400;
414
+ color: rgba(0, 0, 0, 0.65);
415
+ }
416
+ }
417
+ }
343
418
  &.msgItem-left {
344
419
  justify-content: flex-start;
345
420
  .msgItem-box {
@@ -62,6 +62,12 @@ export interface contentConfigProps {
62
62
  onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
63
63
  onVoteChange?: (type:string,item: dataItemType) => void; // 点赞 或踩
64
64
  onRefresh?: (item:dataItemType) => void;// 刷新
65
+ fileCustomRender?: {// 文件对象的自定义渲染
66
+ iconFileRender?: (suffix: string) => React.ReactNode; // 文件上传的 icon。参数 文件对象file 返回值为图标
67
+ fileTitleRender?: (item: dataItemType) => React.ReactNode;
68
+ fileBottomRender?: (item: dataItemType) => React.ReactNode;
69
+ fileRender?: (item: dataItemType) => React.ReactNode;
70
+ };
65
71
  }
66
72
 
67
73
  // content props
@@ -205,6 +211,7 @@ export interface fileCustomProps {
205
211
  url: string;
206
212
  status: fileStatus | undefined;
207
213
  source: File | undefined;
214
+ size:number
208
215
  }
209
216
 
210
217
  // FileList 组件 ref props
@@ -271,6 +278,7 @@ export interface VirtuosoListRefProps {
271
278
  upateDataSource:(id:string,obj:dataItemType)=>void;
272
279
  changeDataSource:(list:dataItemType[])=>void;
273
280
  scrollToBottom: () => void;
281
+ setSendingId:(id:string)=>void;
274
282
  }
275
283
 
276
284
  export interface contentRefProps extends VirtuosoListRefProps {}
@@ -290,4 +298,9 @@ export interface dataItemType {
290
298
  reference: referenceType | null; // 引用数据
291
299
  source: any; //原消息对象
292
300
  vote?:string;// "up":点赞。"down":踩
301
+ type?:"file"|"text",
302
+ suffix?:string;
303
+ fileSize?:number;
304
+ fileTitle?:string;
305
+ fileList?:fileCustomProps[];
293
306
  }
@@ -139,7 +139,8 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
139
139
  fileId: fileId,
140
140
  url: "",
141
141
  status: "waiting",
142
- source: file
142
+ source: file,
143
+ size: file.size
143
144
  };
144
145
  }
145
146
  return item;
@@ -161,7 +162,8 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
161
162
  fileId: fileId,
162
163
  url: "",
163
164
  status: "uploading",
164
- source: file
165
+ source: file,
166
+ size: file.size
165
167
  };
166
168
  }
167
169
  return item;
@@ -248,7 +250,8 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
248
250
  fileId: params.fileId || guidGenerator(),
249
251
  url: params.url || "",
250
252
  status: params.status || "waiting",
251
- source: file
253
+ source: file,
254
+ size: file.size
252
255
  };
253
256
  return customFile;
254
257
  };