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.
@@ -32,6 +32,8 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
32
32
  if (fileUpload) {
33
33
  fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
34
34
  }
35
+ var footerDomRef = useRef(null);
36
+ var resizeObserverRef = useRef(null);
35
37
  var fileListRef = useRef(null);
36
38
  var ctrl = useRef(); //停止生成ai回答时使用
37
39
  var _useState = _sliced_to_array(useState(""), 2), textValue = _useState[0], setTextValue = _useState[1];
@@ -74,7 +76,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
74
76
  }, fileListRef.current);
75
77
  });
76
78
  useEffect(function() {
79
+ listenerFooterHeight();
77
80
  return function() {
81
+ resizeObserverRef.current && resizeObserverRef.current.disconnect();
78
82
  clearTimeout(updateMsgRef.current);
79
83
  };
80
84
  }, []);
@@ -87,6 +91,16 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
87
91
  referencesSource,
88
92
  sending
89
93
  ]);
94
+ // 监听footer变化
95
+ var listenerFooterHeight = function() {
96
+ if (!footerDomRef.current) return;
97
+ // 创建ResizeObserver实例
98
+ resizeObserverRef.current = new ResizeObserver(function(entries) {
99
+ apiRef.contentApi && apiRef.contentApi.scrollToBottom();
100
+ });
101
+ // 开始观察footer元素
102
+ resizeObserverRef.current.observe(footerDomRef.current);
103
+ };
90
104
  // 是否允许发送消息
91
105
  var canSendMsg = useMemo(function() {
92
106
  if (textValue.trim().length === 0) return false;
@@ -188,7 +202,8 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
188
202
  content: value,
189
203
  location: "right",
190
204
  reference: recordRef.current.referencesSource,
191
- source: null
205
+ source: null,
206
+ fileList: fileListRef.current.getFileList()
192
207
  });
193
208
  sendMsgAjax();
194
209
  };
@@ -213,7 +228,8 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
213
228
  content: "正在输入...",
214
229
  location: "left",
215
230
  reference: null,
216
- source: null
231
+ source: null,
232
+ fileList: fileListRef.current.getFileList()
217
233
  });
218
234
  var msgContent = "";
219
235
  setSending(true);
@@ -236,6 +252,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
236
252
  setSending(false);
237
253
  if (recordMsgObj.id) {
238
254
  apiRef.contentApi.recordMsg(recordMsgObj);
255
+ apiRef.contentApi.setSendingId(recordMsgObj.id);
239
256
  }
240
257
  console.log("onclose: ", recordMsgObj);
241
258
  };
@@ -266,11 +283,12 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
266
283
  delete data.content;
267
284
  recordMsgObj = _object_spread({
268
285
  createTime: createTime,
269
- content: msgContent,
286
+ content: msgContent || "正在输入...",
270
287
  location: "left",
271
288
  reference: null,
272
289
  source: null
273
290
  }, data);
291
+ apiRef.contentApi.setSendingId(data.id);
274
292
  apiRef.contentApi.updateMsg(msgId, recordMsgObj);
275
293
  msgId = data.id;
276
294
  updateMsgRef.current = setTimeout(function() {
@@ -304,6 +322,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
304
322
  };
305
323
  return /*#__PURE__*/ _jsx("div", {
306
324
  className: "".concat(getCls("footer"), " ").concat(className),
325
+ ref: footerDomRef,
307
326
  children: /*#__PURE__*/ _jsxs("div", {
308
327
  className: "".concat(getCls("footerBody"), " ").concat(judegTextLengthWarn() ? getCls("footerBodyWarn") : ""),
309
328
  children: [
@@ -32,15 +32,30 @@ var ReferencesIcon = function(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: "".concat(getCls("msgItem-action-references")),
58
+ className: "".concat(getCls("msgItem-action-reference")),
44
59
  onClick: function() {
45
60
  return clickFn();
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;
@@ -16,6 +16,7 @@ import CopyIcon from "../copyIcon";
16
16
  import ReferencesIcon from "../referencesIcon";
17
17
  import { UpVoteBtn, DownVoteBtn } from "../remarkBtn";
18
18
  import RefreshBtn from "../refreshBtn";
19
+ import { fileIconRender } from "../fileList/fileIcon";
19
20
  var Header = function(param) {
20
21
  var context = param.context;
21
22
  var prefix = context.prefix, loading = context.loading;
@@ -48,16 +49,17 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
48
49
  var prefix = props.prefix, contentConfig = props.contentConfig, apiRef = props.apiRef;
49
50
  var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
50
51
  "copy",
51
- "references"
52
- ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage, _contentConfig_onVoteChange = contentConfig.onVoteChange, onVoteChange = _contentConfig_onVoteChange === void 0 ? function() {} : _contentConfig_onVoteChange, _contentConfig_onRefresh = contentConfig.onRefresh, onRefresh = _contentConfig_onRefresh === void 0 ? function() {} : _contentConfig_onRefresh;
52
+ "reference"
53
+ ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage, _contentConfig_onVoteChange = contentConfig.onVoteChange, onVoteChange = _contentConfig_onVoteChange === void 0 ? function() {} : _contentConfig_onVoteChange, _contentConfig_onRefresh = contentConfig.onRefresh, onRefresh = _contentConfig_onRefresh === void 0 ? function() {} : _contentConfig_onRefresh, helloMsg = contentConfig.helloMsg, _contentConfig_fileCustomRender = contentConfig.fileCustomRender, fileCustomRender = _contentConfig_fileCustomRender === void 0 ? {} : _contentConfig_fileCustomRender;
53
54
  var loadMoreProps = contentConfig.loadMore || true;
54
55
  var virtuosoRef = useRef(null);
55
56
  var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
56
57
  var _useState1 = _sliced_to_array(useState([]), 2), dataSource = _useState1[0], setDataSource = _useState1[1];
57
58
  var _useState2 = _sliced_to_array(useState(0), 2), firstItemIndex = _useState2[0], setFirstItemIndex = _useState2[1];
58
59
  var _useState3 = _sliced_to_array(useState(1), 2), page = _useState3[0], setPage = _useState3[1];
59
- var _useState4 = _sliced_to_array(useState(contentConfig.pageSize || 30), 2), pageSize = _useState4[0], setPageSize = _useState4[1];
60
- var _useState5 = _sliced_to_array(useState(0), 2), total = _useState5[0], setTotal = _useState5[1];
60
+ var _useState4 = _sliced_to_array(useState(""), 2), sendingId = _useState4[0], setSendingId = _useState4[1];
61
+ var _useState5 = _sliced_to_array(useState(contentConfig.pageSize || 30), 2), pageSize = _useState5[0], setPageSize = _useState5[1];
62
+ var _useState6 = _sliced_to_array(useState(0), 2), total = _useState6[0], setTotal = _useState6[1];
61
63
  var timerRef = useRef({
62
64
  loadMore: null,
63
65
  scrollTimer: null
@@ -68,23 +70,14 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
68
70
  pageSize: pageSize,
69
71
  total: total,
70
72
  dataSource: dataSource,
71
- maxPage: Math.ceil(total / pageSize)
73
+ maxPage: Math.ceil(total / pageSize),
74
+ sendingId: ""
72
75
  });
73
76
  var timeRenderCache = useRef(new Map()).current;
74
77
  var htmlRenderCache = useRef(new Map()).current;
75
78
  useImperativeHandle(ref, function() {
76
79
  return {
77
- addMsg: function(msg) {
78
- if (msg.id !== "inputing") {
79
- // 不记录"正在输入..."的消息
80
- onRecordMessage(msg);
81
- }
82
- setDataSource(function(data) {
83
- return _to_consumable_array(data).concat([
84
- msg
85
- ]);
86
- });
87
- },
80
+ addMsg: addMsg,
88
81
  updateMsg: function(id, obj) {
89
82
  setDataSource(function(data) {
90
83
  return data.map(function(item) {
@@ -121,17 +114,26 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
121
114
  changeDataSource: function(data) {
122
115
  setDataSource(data);
123
116
  },
124
- scrollToBottom: function scrollToBottom() {
125
- if (!virtuosoRef.current) return;
126
- virtuosoRef.current.scrollToIndex({
127
- index: "LAST",
128
- behavior: "auto"
129
- });
117
+ scrollToBottom: scrollToBottom,
118
+ setSendingId: function(id) {
119
+ setSendingId(id);
130
120
  }
131
121
  };
132
122
  });
133
123
  useEffect(function() {
134
- getData(page, pageSize);
124
+ getData(page, pageSize).then(function() {
125
+ if (helloMsg) {
126
+ addMsg({
127
+ id: "helloMsg",
128
+ createTime: new Date().getTime(),
129
+ content: helloMsg,
130
+ location: "left",
131
+ reference: null,
132
+ source: null,
133
+ fileList: []
134
+ });
135
+ }
136
+ });
135
137
  var removeFn = delegate(wrapperRef.current, "click", ".".concat(styles.copyCode), function(event, target) {
136
138
  findCopyContent(event);
137
139
  });
@@ -164,29 +166,65 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
164
166
  recordRef.current.total = total;
165
167
  recordRef.current.dataSource = dataSource;
166
168
  recordRef.current.maxPage = Math.ceil(total / pageSize);
169
+ recordRef.current.sendingId = sendingId;
167
170
  }, [
168
171
  page,
169
172
  pageSize,
170
173
  total,
171
- dataSource
174
+ dataSource,
175
+ sendingId
172
176
  ]);
177
+ var addMsg = function(msg) {
178
+ if (msg.id !== "inputing" && msg.id !== "helloMsg") {
179
+ // 不记录"正在输入..."的消息
180
+ onRecordMessage(msg);
181
+ }
182
+ var list = [];
183
+ if (msg.location === "right" && msg.fileList && msg.fileList.length > 0) {
184
+ console.log("fileList", msg, msg.fileList);
185
+ msg.fileList.map(function(item) {
186
+ list.push({
187
+ type: "file",
188
+ id: item.fileId,
189
+ createTime: msg.createTime,
190
+ content: "",
191
+ location: "right",
192
+ reference: null,
193
+ source: null,
194
+ suffix: item.suffix,
195
+ fileSize: item.size || 0,
196
+ fileTitle: item.name
197
+ });
198
+ });
199
+ }
200
+ list.push(msg);
201
+ setDataSource(function(data) {
202
+ return _to_consumable_array(data).concat(_to_consumable_array(list));
203
+ });
204
+ timerRef.current.scrollTimer = setTimeout(function() {
205
+ scrollToBottom();
206
+ }, 100);
207
+ };
208
+ var scrollToBottom = function() {
209
+ if (!virtuosoRef.current) return;
210
+ virtuosoRef.current.scrollToIndex({
211
+ index: "LAST",
212
+ behavior: "auto"
213
+ });
214
+ };
173
215
  var getData = function(page, pageSize) {
174
216
  setLoading(true);
175
- clearTimeout(timerRef.current.loadMore);
176
- timerRef.current.loadMore = setTimeout(function() {
217
+ return getList(page, pageSize).then(function(listObj) {
177
218
  setLoading(false);
178
- getList(page, pageSize).then(function(listObj) {
179
- setLoading(false);
180
- console.log("listObjlistObj", listObj);
181
- setDataSource(function(data) {
182
- return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
183
- });
184
- setTotal(listObj.total);
185
- setPage(page);
186
- setPageSize(pageSize);
187
- setFirstItemIndex(listObj.total - pageSize * (page - 1));
219
+ console.log("listObjlistObj", listObj);
220
+ setDataSource(function(data) {
221
+ return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
188
222
  });
189
- }, 500);
223
+ setTotal(listObj.total);
224
+ setPage(page);
225
+ setPageSize(pageSize);
226
+ setFirstItemIndex(listObj.total - pageSize * (page - 1));
227
+ });
190
228
  };
191
229
  var getCls = function(clsName) {
192
230
  return styles[clsName] + " " + prefix + "-" + clsName;
@@ -201,18 +239,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
201
239
  ]);
202
240
  var itemContent = function(index, item) {
203
241
  var timeNode = renderTime(item);
204
- var cahceKey = item.id + "-" + item.content;
205
242
  var contentNode = null;
206
- // if (htmlRenderCache.has(cahceKey)) {
207
- // contentNode = htmlRenderCache.get(cahceKey);
208
- // } else {
209
- // const html = markToHtml(item.content, item.id);
210
- // contentNode = <div dangerouslySetInnerHTML={{ __html: html }}></div>;
211
- // if (coverRenderText) {
212
- // contentNode = coverRenderText(item, html);
213
- // }
214
- // htmlRenderCache.set(cahceKey, contentNode);
215
- // }
216
243
  var html = markToHtml(item.content, item.id);
217
244
  contentNode = /*#__PURE__*/ _jsx("div", {
218
245
  dangerouslySetInnerHTML: {
@@ -222,6 +249,38 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
222
249
  if (coverRenderText) {
223
250
  contentNode = coverRenderText(item, html);
224
251
  }
252
+ // item.type = "file";
253
+ // item.suffix = "docx";
254
+ // item.fileTitle = "这是一个文件名称.docx";
255
+ // item.fileSize = "5Mb";
256
+ if (item.type === "file") {
257
+ var renderFileObj = _object_spread({
258
+ fileTitleRender: function(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: "".concat(getCls("msgItem-file")),
269
+ children: [
270
+ /*#__PURE__*/ _jsx("div", {
271
+ className: "".concat(getCls("msgItem-file-left")),
272
+ children: fileIconRender(item.suffix, renderFileObj.iconFileRender)
273
+ }),
274
+ /*#__PURE__*/ _jsx("div", {
275
+ className: "".concat(getCls("msgItem-file-right")),
276
+ children: /*#__PURE__*/ _jsx("p", {
277
+ children: renderFileObj.fileTitleRender(item)
278
+ })
279
+ })
280
+ ]
281
+ });
282
+ }
283
+ }
225
284
  // 是否显示时间
226
285
  var itemNode = /*#__PURE__*/ _jsx("div", {
227
286
  className: "".concat(getCls("msgItem"), " ").concat(item.location === "left" ? getCls("msgItem-left") : getCls("msgItem-right")),
@@ -264,12 +323,30 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
264
323
  var referenceNode = null;
265
324
  if (reference.type === "text") {
266
325
  referenceNode = /*#__PURE__*/ _jsx("div", {
267
- className: "".concat(getCls("msgItem-references-text")),
326
+ className: "".concat(getCls("msgItem-reference-text")),
268
327
  children: /*#__PURE__*/ _jsx("div", {
269
328
  children: reference.value
270
329
  })
271
330
  });
272
331
  }
332
+ if (reference.type === "file") {
333
+ referenceNode = /*#__PURE__*/ _jsx("div", {
334
+ className: "".concat(getCls("msgItem-reference-file")),
335
+ children: /*#__PURE__*/ _jsxs("div", {
336
+ className: "".concat(getCls("msgItem-reference-file-box")),
337
+ children: [
338
+ /*#__PURE__*/ _jsx("div", {
339
+ className: "".concat(getCls("msgItem-reference-file-left")),
340
+ children: fileIconRender(reference.value.suffix, fileCustomRender.iconFileRender)
341
+ }),
342
+ /*#__PURE__*/ _jsx("div", {
343
+ className: "".concat(getCls("msgItem-reference-file-right")),
344
+ children: reference.value.name
345
+ })
346
+ ]
347
+ })
348
+ });
349
+ }
273
350
  if (coverRenderReferences) {
274
351
  return coverRenderReferences(item, referenceNode);
275
352
  } else {
@@ -321,6 +398,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
321
398
  topDom.style.cssText = "";
322
399
  };
323
400
  var renderAction = function(location, item) {
401
+ if (item.id === "inputing" || item.id === "helloMsg" || item.id === recordRef.current.sendingId) return null;
324
402
  var copyNode = /*#__PURE__*/ _jsx(CopyIcon, {
325
403
  prefix: prefix,
326
404
  content: item.content
@@ -334,6 +412,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
334
412
  prefix: prefix,
335
413
  isActive: item.vote === "up",
336
414
  clickFn: function() {
415
+ onVoteChange(item.vote === "up" ? "" : "up", item);
337
416
  setDataSource(function(data) {
338
417
  return data.map(function(ite) {
339
418
  if (item.id === ite.id) {
@@ -342,13 +421,13 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
342
421
  return ite;
343
422
  });
344
423
  });
345
- onVoteChange(item.vote === "up" ? "" : "up", item);
346
424
  }
347
425
  });
348
426
  var DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
349
427
  prefix: prefix,
350
428
  isActive: item.vote === "down",
351
429
  clickFn: function() {
430
+ onVoteChange(item.vote === "down" ? "" : "down", item);
352
431
  setDataSource(function(data) {
353
432
  return data.map(function(ite) {
354
433
  if (item.id === ite.id) {
@@ -357,7 +436,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
357
436
  return ite;
358
437
  });
359
438
  });
360
- onVoteChange(item.vote === "down" ? "" : "down", item);
361
439
  }
362
440
  });
363
441
  var RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
@@ -370,6 +448,12 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
370
448
  UpVoteNode = null;
371
449
  DownVoteNode = null;
372
450
  }
451
+ if (item.type === "file") {
452
+ copyNode = null;
453
+ UpVoteNode = null;
454
+ DownVoteNode = null;
455
+ RefreshNode = null;
456
+ }
373
457
  var leftNodes = null;
374
458
  var rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
375
459
  children: [
@@ -385,7 +469,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
385
469
  if (!msgAction.includes("copy")) {
386
470
  copyNode = null;
387
471
  }
388
- if (!msgAction.includes("references")) {
472
+ if (!msgAction.includes("reference")) {
389
473
  referencesNode = null;
390
474
  }
391
475
  if (!msgAction.includes("upVite")) {
@@ -552,6 +636,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
552
636
  p[0].innerText = "复制代码";
553
637
  }
554
638
  };
639
+ var onScroll = function() {
640
+ console.log("滚动滚动");
641
+ };
555
642
  return /*#__PURE__*/ _jsx("div", {
556
643
  className: "".concat(getCls("virtuosoList-wrapper")),
557
644
  ref: wrapperRef,
@@ -576,7 +663,8 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
576
663
  Header: Header
577
664
  },
578
665
  increaseViewportBy: 200,
579
- overscan: 10
666
+ overscan: 10,
667
+ onScroll: onScroll
580
668
  })
581
669
  });
582
670
  });
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "description": "组件功能描述",
5
5
  "config": {
6
6
  "commitizen": {