bhd-components 0.10.6 → 0.10.8

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.
Files changed (33) hide show
  1. package/dist/index.esm.es5.development.css +1231 -1196
  2. package/dist/index.esm.es5.development.js +1326 -1229
  3. package/dist/index.esm.es5.production.css +2 -2
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +1 -1
  6. package/dist/vendor.esm.es5.production.js +1 -1
  7. package/es2017/AIMessageList/components/copyIcon/index.js +3 -3
  8. package/es2017/AIMessageList/components/fileList/index.js +5 -1
  9. package/es2017/AIMessageList/components/footer/index.js +41 -14
  10. package/es2017/AIMessageList/components/header/index.js +4 -4
  11. package/es2017/AIMessageList/components/referencesIcon/index.js +21 -6
  12. package/es2017/AIMessageList/components/refreshBtn/index.js +1 -1
  13. package/es2017/AIMessageList/components/remarkBtn/index.js +2 -2
  14. package/es2017/AIMessageList/components/virtuosoList/index.js +76 -30
  15. package/es2017/AIMessageList/components/virtuosoList/index.module.less +38 -3
  16. package/es2017/AIMessageList/type.d.ts +11 -2
  17. package/es2017/customerService/historyFun.js +7 -1
  18. package/es2017/customerService/index.module.less +1 -0
  19. package/es2017/customerService/index2.module.less +1 -0
  20. package/esm/AIMessageList/components/copyIcon/index.js +3 -3
  21. package/esm/AIMessageList/components/fileList/index.js +5 -1
  22. package/esm/AIMessageList/components/footer/index.js +40 -13
  23. package/esm/AIMessageList/components/header/index.js +4 -4
  24. package/esm/AIMessageList/components/referencesIcon/index.js +21 -6
  25. package/esm/AIMessageList/components/refreshBtn/index.js +1 -1
  26. package/esm/AIMessageList/components/remarkBtn/index.js +2 -2
  27. package/esm/AIMessageList/components/virtuosoList/index.js +78 -32
  28. package/esm/AIMessageList/components/virtuosoList/index.module.less +38 -3
  29. package/esm/AIMessageList/type.d.ts +11 -2
  30. package/esm/customerService/historyFun.js +7 -1
  31. package/esm/customerService/index.module.less +1 -0
  32. package/esm/customerService/index2.module.less +1 -0
  33. package/package.json +1 -1
@@ -7,12 +7,12 @@ const copyIconSvg = /*#__PURE__*/ _jsx("i", {
7
7
  width: "1em",
8
8
  height: "1em",
9
9
  viewBox: "0 0 14 14",
10
- "shape-rendering": "geometricPrecision",
10
+ shapeRendering: "geometricPrecision",
11
11
  fill: "currentColor",
12
12
  xmlns: "http://www.w3.org/2000/svg",
13
13
  children: [
14
14
  /*#__PURE__*/ _jsx("g", {
15
- "clip-path": "url(#clip0_518_8403)",
15
+ clipPath: "url(#clip0_518_8403)",
16
16
  children: /*#__PURE__*/ _jsx("path", {
17
17
  d: "M6.16666 1.66666H13.1667C13.4761 1.66666 13.7728 1.78957 13.9916 2.00837C14.2104 2.22716 14.3333 2.5239 14.3333 2.83332V9.83332C14.3333 10.1427 14.2104 10.4395 13.9916 10.6583C13.7728 10.8771 13.4761 11 13.1667 11H6.16666C5.85724 11 5.5605 10.8771 5.34171 10.6583C5.12291 10.4395 5 10.1427 5 9.83332V2.83332C5 2.5239 5.12291 2.22716 5.34171 2.00837C5.5605 1.78957 5.85724 1.66666 6.16666 1.66666ZM6.16666 2.66666C6.12246 2.66666 6.08007 2.68422 6.04881 2.71547C6.01756 2.74673 6 2.78912 6 2.83332V9.83332C6 9.85521 6.00431 9.87688 6.01268 9.8971C6.02106 9.91732 6.03334 9.9357 6.04881 9.95117C6.06429 9.96665 6.08266 9.97893 6.10288 9.9873C6.1231 9.99568 6.14478 9.99999 6.16666 9.99999H13.1667C13.2109 9.99999 13.2533 9.98243 13.2845 9.95117C13.3158 9.91992 13.3333 9.87753 13.3333 9.83332V2.83332C13.3333 2.78912 13.3158 2.74673 13.2845 2.71547C13.2533 2.68422 13.2109 2.66666 13.1667 2.66666H6.16666ZM10 12C10 11.8674 10.0527 11.7402 10.1464 11.6464C10.2402 11.5527 10.3674 11.5 10.5 11.5C10.6326 11.5 10.7598 11.5527 10.8536 11.6464C10.9473 11.7402 11 11.8674 11 12V13.1667C11 13.4761 10.8771 13.7728 10.6583 13.9916C10.4395 14.2104 10.1427 14.3333 9.83333 14.3333H2.83333C2.52391 14.3333 2.22717 14.2104 2.00837 13.9916C1.78958 13.7728 1.66666 13.4761 1.66666 13.1667V6.16666C1.66666 5.85724 1.78958 5.56049 2.00837 5.3417C2.22717 5.12291 2.52391 4.99999 2.83333 4.99999H4C4.13261 4.99999 4.25978 5.05267 4.35355 5.14644C4.44732 5.2402 4.5 5.36738 4.5 5.49999C4.5 5.6326 4.44732 5.75978 4.35355 5.85354C4.25978 5.94731 4.13261 5.99999 4 5.99999H2.83333C2.78913 5.99999 2.74674 6.01755 2.71548 6.04881C2.68422 6.08006 2.66666 6.12245 2.66666 6.16666V13.1667C2.66666 13.2109 2.68422 13.2533 2.71548 13.2845C2.74674 13.3158 2.78913 13.3333 2.83333 13.3333H9.83333C9.87753 13.3333 9.91993 13.3158 9.95118 13.2845C9.98244 13.2533 10 13.2109 10 13.1667V12Z"
18
18
  })
@@ -33,7 +33,7 @@ const copySuccessSvg = /*#__PURE__*/ _jsx("i", {
33
33
  children: /*#__PURE__*/ _jsx("svg", {
34
34
  width: "1em",
35
35
  height: "1em",
36
- "shape-rendering": "geometricPrecision",
36
+ shapeRendering: "geometricPrecision",
37
37
  fill: "currentColor",
38
38
  viewBox: "0 0 12 7",
39
39
  xmlns: "http://www.w3.org/2000/svg",
@@ -52,12 +52,16 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
52
52
  updateFile,
53
53
  getFileList: ()=>recordObj.current.fileList,
54
54
  vaildFile,
55
- fileToCustomFile
55
+ fileToCustomFile,
56
+ clearFileList
56
57
  };
57
58
  });
58
59
  const getCls = (clsName)=>{
59
60
  return styles[clsName] + " " + prefix + "-" + clsName;
60
61
  };
62
+ const clearFileList = ()=>{
63
+ setFileList([]);
64
+ };
61
65
  const vaildFile = (file, fileId)=>{
62
66
  if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
63
67
  errorCallback({
@@ -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,11 +218,13 @@ 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);
210
226
  setTextValue("");
227
+ fileListRef.current.clearFileList();
211
228
  setReferencesSource(null);
212
229
  let recordMsgObj = {};
213
230
  let arg = [
@@ -217,11 +234,23 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
217
234
  ];
218
235
  beforeSendMsg(...arg).then((beforeInfo)=>{
219
236
  const callback = ()=>{
237
+ let isClose = false;
238
+ const closeCallback = ()=>{
239
+ if (isClose) return;
240
+ isClose = true;
241
+ onClose();
242
+ setSending(false);
243
+ if (recordMsgObj.id) {
244
+ apiRef.contentApi.recordMsg(recordMsgObj);
245
+ apiRef.contentApi.setSendingId(recordMsgObj.id);
246
+ }
247
+ console.log("onclose: ", recordMsgObj);
248
+ };
220
249
  fetchEventSource(url, _object_spread({
221
250
  method,
222
251
  headers: _object_spread({
223
252
  "Content-Type": "application/json",
224
- "Accept": "text/event-stream,application/json"
253
+ Accept: "text/event-stream,application/json"
225
254
  }, headers()),
226
255
  body: params(...arg, beforeInfo),
227
256
  openWhenHidden: true,
@@ -237,28 +266,25 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
237
266
  return null;
238
267
  },
239
268
  onmessage: (ev)=>{
240
- let data = onMessage(ev);
269
+ let data = onMessage(ev, closeCallback);
241
270
  msgContent += data.content;
242
271
  delete data.content;
243
272
  recordMsgObj = _object_spread({
244
273
  createTime: createTime,
245
- content: msgContent,
274
+ content: msgContent || "正在输入...",
246
275
  location: "left",
247
276
  reference: null,
248
277
  source: null
249
278
  }, data);
250
- updateMsgRef.current = setTimeout(()=>{
251
- apiRef.contentApi.updateMsg(msgId, recordMsgObj);
252
- msgId = data.id;
279
+ apiRef.contentApi.setSendingId(data.id);
280
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
281
+ msgId = data.id;
282
+ updateMsgRef.current = setTimeout(function() {
283
+ apiRef.contentApi.scrollToBottom();
253
284
  }, 100);
254
285
  },
255
286
  onclose: ()=>{
256
- onClose();
257
- setSending(false);
258
- if (recordMsgObj.id) {
259
- apiRef.contentApi.recordMsg(recordMsgObj);
260
- }
261
- console.log("onclose: ", recordMsgObj);
287
+ closeCallback();
262
288
  },
263
289
  onerror: (err)=>{
264
290
  onError(err);
@@ -284,6 +310,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
284
310
  };
285
311
  return /*#__PURE__*/ _jsx("div", {
286
312
  className: `${getCls("footer")} ${className}`,
313
+ ref: footerDomRef,
287
314
  children: /*#__PURE__*/ _jsxs("div", {
288
315
  className: `${getCls("footerBody")} ${judegTextLengthWarn() ? getCls("footerBodyWarn") : ""}`,
289
316
  children: [
@@ -29,11 +29,11 @@ const defaultProps = {
29
29
  gradientUnits: "userSpaceOnUse",
30
30
  children: [
31
31
  /*#__PURE__*/ _jsx("stop", {
32
- "stop-color": "#F87AFD"
32
+ stopColor: "#F87AFD"
33
33
  }),
34
34
  /*#__PURE__*/ _jsx("stop", {
35
35
  offset: "1",
36
- "stop-color": "#41DAF8"
36
+ stopColor: "#41DAF8"
37
37
  })
38
38
  ]
39
39
  }),
@@ -46,11 +46,11 @@ const defaultProps = {
46
46
  gradientUnits: "userSpaceOnUse",
47
47
  children: [
48
48
  /*#__PURE__*/ _jsx("stop", {
49
- "stop-color": "#F87AFD"
49
+ stopColor: "#F87AFD"
50
50
  }),
51
51
  /*#__PURE__*/ _jsx("stop", {
52
52
  offset: "1",
53
- "stop-color": "#41DAF8"
53
+ stopColor: "#41DAF8"
54
54
  })
55
55
  ]
56
56
  })
@@ -5,7 +5,7 @@ const referencesIcon = /*#__PURE__*/ _jsx("i", {
5
5
  children: /*#__PURE__*/ _jsxs("svg", {
6
6
  width: "1em",
7
7
  height: "1em",
8
- "shape-rendering": "geometricPrecision",
8
+ shapeRendering: "geometricPrecision",
9
9
  fill: "currentColor",
10
10
  viewBox: "0 0 14 14",
11
11
  xmlns: "http://www.w3.org/2000/svg",
@@ -32,11 +32,26 @@ 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", {
@@ -9,7 +9,7 @@ const refreshSvg = /*#__PURE__*/ _jsx("svg", {
9
9
  width: "1em",
10
10
  height: "1em",
11
11
  fill: "currentColor",
12
- "shape-rendering": "geometricPrecision",
12
+ shapeRendering: "geometricPrecision",
13
13
  "aria-hidden": "true",
14
14
  children: /*#__PURE__*/ _jsx("path", {
15
15
  d: "M8 3.80001C7.27938 3.80001 6.60141 3.97512 6.00464 4.2846C5.71048 4.43715 5.34834 4.32235 5.19579 4.02818C5.04324 3.73401 5.15804 3.37187 5.4522 3.21932C6.21563 2.82342 7.0826 2.60001 8 2.60001C11.0603 2.60001 13.5412 5.08088 13.5412 8.14118C13.5412 8.40936 13.5221 8.67343 13.4851 8.93202C13.4737 9.01141 13.4607 9.09026 13.446 9.16853L13.7175 9.02364C14.0098 8.86759 14.3733 8.97808 14.5293 9.27041C14.6854 9.56274 14.5749 9.92622 14.2825 10.0823L12.6718 10.9421C12.3819 11.0968 12.0215 10.9896 11.8633 10.7016L11.0035 9.13588C10.844 8.84542 10.9501 8.48065 11.2406 8.32115C11.5311 8.16164 11.8958 8.2678 12.0553 8.55825L12.2672 8.94405C12.2784 8.88383 12.2885 8.82318 12.2972 8.76211C12.3261 8.55962 12.3412 8.35233 12.3412 8.14118C12.3412 5.74362 10.3976 3.80001 8 3.80001ZM3.32824 5.34029C3.61811 5.18556 3.97853 5.29278 4.13669 5.58079L4.99651 7.14649C5.15601 7.43694 5.04986 7.80171 4.7594 7.96122C4.46895 8.12072 4.10418 8.01457 3.94467 7.72411L3.73281 7.33832C3.72156 7.39853 3.71155 7.45919 3.70282 7.52026C3.67386 7.72275 3.65883 7.93003 3.65883 8.14118C3.65883 10.5387 5.60244 12.4824 8 12.4824C8.72063 12.4824 9.39859 12.3072 9.99536 11.9978C10.2895 11.8452 10.6517 11.96 10.8042 12.2542C10.9568 12.5484 10.842 12.9105 10.5478 13.063C9.78437 13.4589 8.9174 13.6824 8 13.6824C4.93969 13.6824 2.45883 11.2015 2.45883 8.14118C2.45883 7.87301 2.47792 7.60894 2.51491 7.35034C2.52627 7.27095 2.5393 7.19211 2.55399 7.11384L2.28254 7.25873C1.99021 7.41477 1.62673 7.30429 1.47069 7.01196C1.31465 6.71963 1.42513 6.35615 1.71746 6.20011L3.32824 5.34029Z"
@@ -5,7 +5,7 @@ const upvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
5
5
  width: "1em",
6
6
  height: "1em",
7
7
  viewBox: "0 0 16 16",
8
- "shape-rendering": "geometricPrecision",
8
+ shapeRendering: "geometricPrecision",
9
9
  fill: "currentColor",
10
10
  xmlns: "http://www.w3.org/2000/svg",
11
11
  children: /*#__PURE__*/ _jsx("path", {
@@ -15,7 +15,7 @@ const upvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
15
15
  const downvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
16
16
  width: "1em",
17
17
  height: "1em",
18
- "shape-rendering": "geometricPrecision",
18
+ shapeRendering: "geometricPrecision",
19
19
  fill: "currentColor",
20
20
  viewBox: "0 0 16 16",
21
21
  xmlns: "http://www.w3.org/2000/svg",
@@ -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;
@@ -45,13 +46,14 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
45
46
  const { getList, coverRenderText, msgAction = [
46
47
  "copy",
47
48
  "references"
48
- ], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{} } = contentConfig;
49
+ ], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{}, iconFileRender } = 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,7 +66,8 @@ 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;
@@ -81,6 +84,9 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
81
84
  msg
82
85
  ];
83
86
  });
87
+ timerRef.current.scrollTimer = setTimeout(()=>{
88
+ scrollToBottom();
89
+ }, 100);
84
90
  },
85
91
  updateMsg: (id, obj)=>{
86
92
  setDataSource((data)=>{
@@ -115,6 +121,10 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
115
121
  },
116
122
  changeDataSource: (data)=>{
117
123
  setDataSource(data);
124
+ },
125
+ scrollToBottom,
126
+ setSendingId: (id)=>{
127
+ setSendingId(id);
118
128
  }
119
129
  };
120
130
  });
@@ -131,18 +141,18 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
131
141
  }, []);
132
142
  useEffect(()=>{
133
143
  if (!virtuosoRef.current) return;
134
- virtuosoRef.current.scrollToIndex({
135
- index: "LAST",
136
- behavior: "auto"
137
- });
138
- clearTimeout(timerRef.current.scrollTimer);
139
- timerRef.current.scrollTimer = setTimeout(()=>{
140
- virtuosoRef.current.scrollToIndex({
141
- index: "LAST",
142
- behavior: "auto",
143
- align: "end"
144
- });
145
- }, 500);
144
+ // virtuosoRef.current.scrollToIndex({
145
+ // index: "LAST", // 或者使用 dataSource.length - 1
146
+ // behavior: "auto", // 可以是 "smooth" 实现平滑滚动
147
+ // });
148
+ // clearTimeout(timerRef.current.scrollTimer);
149
+ // timerRef.current.scrollTimer = setTimeout(() => {
150
+ // virtuosoRef.current.scrollToIndex({
151
+ // index: "LAST", // 或者使用 dataSource.length - 1
152
+ // behavior: "auto", // 可以是 "smooth" 实现平滑滚动
153
+ // align: "end",
154
+ // });
155
+ // }, 500);
146
156
  }, [
147
157
  dataSource
148
158
  ]);
@@ -152,12 +162,21 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
152
162
  recordRef.current.total = total;
153
163
  recordRef.current.dataSource = dataSource;
154
164
  recordRef.current.maxPage = Math.ceil(total / pageSize);
165
+ recordRef.current.sendingId = sendingId;
155
166
  }, [
156
167
  page,
157
168
  pageSize,
158
169
  total,
159
- dataSource
170
+ dataSource,
171
+ sendingId
160
172
  ]);
173
+ const scrollToBottom = ()=>{
174
+ if (!virtuosoRef.current) return;
175
+ virtuosoRef.current.scrollToIndex({
176
+ index: "LAST",
177
+ behavior: "auto"
178
+ });
179
+ };
161
180
  const getData = (page, pageSize)=>{
162
181
  setLoading(true);
163
182
  clearTimeout(timerRef.current.loadMore);
@@ -192,21 +211,41 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
192
211
  ]);
193
212
  const itemContent = (index, item)=>{
194
213
  const timeNode = renderTime(item);
195
- let cahceKey = item.id + "-" + item.content;
196
214
  let contentNode = null;
197
- if (htmlRenderCache.has(cahceKey)) {
198
- contentNode = htmlRenderCache.get(cahceKey);
199
- } else {
200
- const html = markToHtml(item.content, item.id);
201
- contentNode = /*#__PURE__*/ _jsx("div", {
202
- dangerouslySetInnerHTML: {
203
- __html: html
204
- }
205
- });
206
- if (coverRenderText) {
207
- contentNode = coverRenderText(item, html);
215
+ const html = markToHtml(item.content, item.id);
216
+ contentNode = /*#__PURE__*/ _jsx("div", {
217
+ dangerouslySetInnerHTML: {
218
+ __html: html
208
219
  }
209
- htmlRenderCache.set(cahceKey, contentNode);
220
+ });
221
+ if (coverRenderText) {
222
+ contentNode = coverRenderText(item, html);
223
+ }
224
+ // item.type = "file";
225
+ // item.suffix = "docx";
226
+ // item.fileTitle = "这是一个文件名称.docx";
227
+ // item.fileSize = "5Mb";
228
+ if (item.type === "file") {
229
+ contentNode = /*#__PURE__*/ _jsxs("div", {
230
+ className: `${getCls("msgItem-file")}`,
231
+ children: [
232
+ /*#__PURE__*/ _jsx("div", {
233
+ className: `${getCls("msgItem-file-left")}`,
234
+ children: fileIconRender(item.suffix, iconFileRender)
235
+ }),
236
+ /*#__PURE__*/ _jsxs("div", {
237
+ className: `${getCls("msgItem-file-right")}`,
238
+ children: [
239
+ /*#__PURE__*/ _jsx("p", {
240
+ children: item.fileTitle
241
+ }),
242
+ /*#__PURE__*/ _jsx("p", {
243
+ children: item.fileSize
244
+ })
245
+ ]
246
+ })
247
+ ]
248
+ });
210
249
  }
211
250
  // 是否显示时间
212
251
  let itemNode = /*#__PURE__*/ _jsx("div", {
@@ -303,6 +342,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
303
342
  topDom.style.cssText = "";
304
343
  };
305
344
  const renderAction = (location, item)=>{
345
+ if (item.id === "inputing" || item.id === "helloMsg" || item.id === recordRef.current.sendingId) return null;
306
346
  let copyNode = /*#__PURE__*/ _jsx(CopyIcon, {
307
347
  prefix: prefix,
308
348
  content: item.content
@@ -316,6 +356,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
316
356
  prefix: prefix,
317
357
  isActive: item.vote === "up",
318
358
  clickFn: ()=>{
359
+ onVoteChange(item.vote === "up" ? "" : "up", item);
319
360
  setDataSource((data)=>{
320
361
  return data.map((ite)=>{
321
362
  if (item.id === ite.id) {
@@ -324,13 +365,13 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
324
365
  return ite;
325
366
  });
326
367
  });
327
- onVoteChange(item.vote === "up" ? "" : "up", item);
328
368
  }
329
369
  });
330
370
  let DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
331
371
  prefix: prefix,
332
372
  isActive: item.vote === "down",
333
373
  clickFn: ()=>{
374
+ onVoteChange(item.vote === "down" ? "" : "down", item);
334
375
  setDataSource((data)=>{
335
376
  return data.map((ite)=>{
336
377
  if (item.id === ite.id) {
@@ -339,7 +380,6 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
339
380
  return ite;
340
381
  });
341
382
  });
342
- onVoteChange(item.vote === "down" ? "" : "down", item);
343
383
  }
344
384
  });
345
385
  let RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
@@ -350,6 +390,12 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
350
390
  UpVoteNode = null;
351
391
  DownVoteNode = null;
352
392
  }
393
+ if (item.type === "file") {
394
+ copyNode = null;
395
+ UpVoteNode = null;
396
+ DownVoteNode = null;
397
+ RefreshNode = null;
398
+ }
353
399
  let leftNodes = null;
354
400
  let rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
355
401
  children: [
@@ -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,41 @@
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
+ .msgItem-file-left{
278
+ font-size: 24px;
279
+ display: flex;
280
+ justify-content: center;
281
+ align-items: center;
282
+ padding: 0;
283
+ margin: 0;
284
+ &>i{
285
+ display: flex;
286
+ font-size: 24px;
287
+ }
288
+ }
289
+ .msgItem-file-right{
290
+ font-size: 14px;
291
+ font-weight: 400;
292
+ color: rgba(0, 0, 0, 0.65);
293
+ &>p{
294
+ &:nth-child(1){
295
+ margin-bottom: 4px;
296
+ }
297
+ &:nth-child(2){
298
+ font-size: 12px;
299
+ color: rgba(0, 0, 0, 0.25);
300
+ }
301
+ }
302
+ }
303
+ }
269
304
  }
270
305
  .msgItem-action {
271
306
  border-top: 1px solid rgba(0, 0, 0, 0.06);
@@ -62,6 +62,7 @@ export interface contentConfigProps {
62
62
  onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
63
63
  onVoteChange?: (type:string,item: dataItemType) => void; // 点赞 或踩
64
64
  onRefresh?: (item:dataItemType) => void;// 刷新
65
+ iconFileRender?: (suffix: string) => React.ReactNode; // 文件上传的 icon。参数 文件对象file 返回值为图标
65
66
  }
66
67
 
67
68
  // content props
@@ -103,7 +104,7 @@ export interface sendMsgAjaxParams {
103
104
  beforeInfo: any
104
105
  ) => string;
105
106
  onOpen?: (res: Response, onOpenProps: onOpenProps) => void;
106
- onMessage?: (ev: EventSourceMessage) => { id: string; content: string };
107
+ onMessage?: (ev: EventSourceMessage,closeCallback:()=>void) => { id: string; content: string };
107
108
  onClose?: () => void;
108
109
  onError?: (err: any) => void;
109
110
  coverProps?: object;
@@ -217,6 +218,7 @@ export interface FileListRefProps {
217
218
  getFileList: () => fileCustomProps[];
218
219
  vaildFile: (file: File, fileId?: string) => boolean; // 校验文件是否合规
219
220
  fileToCustomFile: (file: File, params: any) => fileCustomProps;
221
+ clearFileList: () => void;
220
222
  }
221
223
 
222
224
  // error Message
@@ -268,7 +270,9 @@ export interface VirtuosoListRefProps {
268
270
  recordMsg: (item: dataItemType) => void;
269
271
  getDataSource: () => dataItemType[];
270
272
  upateDataSource:(id:string,obj:dataItemType)=>void;
271
- changeDataSource:(list:dataItemType[])=>void
273
+ changeDataSource:(list:dataItemType[])=>void;
274
+ scrollToBottom: () => void;
275
+ setSendingId:(id:string)=>void;
272
276
  }
273
277
 
274
278
  export interface contentRefProps extends VirtuosoListRefProps {}
@@ -288,4 +292,9 @@ export interface dataItemType {
288
292
  reference: referenceType | null; // 引用数据
289
293
  source: any; //原消息对象
290
294
  vote?:string;// "up":点赞。"down":踩
295
+ type?:"file"|"text",
296
+ suffix?:string;
297
+ fileSize?:string;
298
+ fileTitle?:string;
299
+ fileList?:fileCustomProps[];
291
300
  }
@@ -462,7 +462,13 @@ const HistoryFun = (props)=>{
462
462
  return /*#__PURE__*/ _jsxs("div", {
463
463
  className: styles.list,
464
464
  onClick: ()=>{
465
- calculationData(item.roomId, list.id, list.receiver);
465
+ calculationData(item.roomId, list.id, props.userData.mid == list.sender ? list.receiver : list.sender);
466
+ console.log('答应一下111111', {
467
+ roomId: item.roomId,
468
+ id: list.id,
469
+ sender: list.sender
470
+ });
471
+ // calculationData(item.roomId, list.id, list.sender);
466
472
  },
467
473
  children: [
468
474
  /*#__PURE__*/ _jsxs("div", {
@@ -425,6 +425,7 @@
425
425
  // margin-top:16px;
426
426
  // }
427
427
  > *:not(pre){
428
+ word-break: break-all;
428
429
  padding-top: 8px;
429
430
  padding-bottom: 8px;
430
431
  &:first-child{
@@ -421,6 +421,7 @@
421
421
  // margin-top:16px;
422
422
  // }
423
423
  > *:not(pre){
424
+ word-break: break-all;
424
425
  padding-top: 8px;
425
426
  padding-bottom: 8px;
426
427
  &:first-child{
@@ -8,12 +8,12 @@ var copyIconSvg = /*#__PURE__*/ _jsx("i", {
8
8
  width: "1em",
9
9
  height: "1em",
10
10
  viewBox: "0 0 14 14",
11
- "shape-rendering": "geometricPrecision",
11
+ shapeRendering: "geometricPrecision",
12
12
  fill: "currentColor",
13
13
  xmlns: "http://www.w3.org/2000/svg",
14
14
  children: [
15
15
  /*#__PURE__*/ _jsx("g", {
16
- "clip-path": "url(#clip0_518_8403)",
16
+ clipPath: "url(#clip0_518_8403)",
17
17
  children: /*#__PURE__*/ _jsx("path", {
18
18
  d: "M6.16666 1.66666H13.1667C13.4761 1.66666 13.7728 1.78957 13.9916 2.00837C14.2104 2.22716 14.3333 2.5239 14.3333 2.83332V9.83332C14.3333 10.1427 14.2104 10.4395 13.9916 10.6583C13.7728 10.8771 13.4761 11 13.1667 11H6.16666C5.85724 11 5.5605 10.8771 5.34171 10.6583C5.12291 10.4395 5 10.1427 5 9.83332V2.83332C5 2.5239 5.12291 2.22716 5.34171 2.00837C5.5605 1.78957 5.85724 1.66666 6.16666 1.66666ZM6.16666 2.66666C6.12246 2.66666 6.08007 2.68422 6.04881 2.71547C6.01756 2.74673 6 2.78912 6 2.83332V9.83332C6 9.85521 6.00431 9.87688 6.01268 9.8971C6.02106 9.91732 6.03334 9.9357 6.04881 9.95117C6.06429 9.96665 6.08266 9.97893 6.10288 9.9873C6.1231 9.99568 6.14478 9.99999 6.16666 9.99999H13.1667C13.2109 9.99999 13.2533 9.98243 13.2845 9.95117C13.3158 9.91992 13.3333 9.87753 13.3333 9.83332V2.83332C13.3333 2.78912 13.3158 2.74673 13.2845 2.71547C13.2533 2.68422 13.2109 2.66666 13.1667 2.66666H6.16666ZM10 12C10 11.8674 10.0527 11.7402 10.1464 11.6464C10.2402 11.5527 10.3674 11.5 10.5 11.5C10.6326 11.5 10.7598 11.5527 10.8536 11.6464C10.9473 11.7402 11 11.8674 11 12V13.1667C11 13.4761 10.8771 13.7728 10.6583 13.9916C10.4395 14.2104 10.1427 14.3333 9.83333 14.3333H2.83333C2.52391 14.3333 2.22717 14.2104 2.00837 13.9916C1.78958 13.7728 1.66666 13.4761 1.66666 13.1667V6.16666C1.66666 5.85724 1.78958 5.56049 2.00837 5.3417C2.22717 5.12291 2.52391 4.99999 2.83333 4.99999H4C4.13261 4.99999 4.25978 5.05267 4.35355 5.14644C4.44732 5.2402 4.5 5.36738 4.5 5.49999C4.5 5.6326 4.44732 5.75978 4.35355 5.85354C4.25978 5.94731 4.13261 5.99999 4 5.99999H2.83333C2.78913 5.99999 2.74674 6.01755 2.71548 6.04881C2.68422 6.08006 2.66666 6.12245 2.66666 6.16666V13.1667C2.66666 13.2109 2.68422 13.2533 2.71548 13.2845C2.74674 13.3158 2.78913 13.3333 2.83333 13.3333H9.83333C9.87753 13.3333 9.91993 13.3158 9.95118 13.2845C9.98244 13.2533 10 13.2109 10 13.1667V12Z"
19
19
  })
@@ -34,7 +34,7 @@ var copySuccessSvg = /*#__PURE__*/ _jsx("i", {
34
34
  children: /*#__PURE__*/ _jsx("svg", {
35
35
  width: "1em",
36
36
  height: "1em",
37
- "shape-rendering": "geometricPrecision",
37
+ shapeRendering: "geometricPrecision",
38
38
  fill: "currentColor",
39
39
  viewBox: "0 0 12 7",
40
40
  xmlns: "http://www.w3.org/2000/svg",