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
@@ -58,12 +58,16 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
58
58
  return recordObj.current.fileList;
59
59
  },
60
60
  vaildFile: vaildFile,
61
- fileToCustomFile: fileToCustomFile
61
+ fileToCustomFile: fileToCustomFile,
62
+ clearFileList: clearFileList
62
63
  };
63
64
  });
64
65
  var getCls = function(clsName) {
65
66
  return styles[clsName] + " " + prefix + "-" + clsName;
66
67
  };
68
+ var clearFileList = function() {
69
+ setFileList([]);
70
+ };
67
71
  var vaildFile = function(file, fileId) {
68
72
  if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
69
73
  errorCallback({
@@ -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,11 +228,13 @@ 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);
220
236
  setTextValue("");
237
+ fileListRef.current.clearFileList();
221
238
  setReferencesSource(null);
222
239
  var recordMsgObj = {};
223
240
  var arg = [
@@ -227,11 +244,23 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
227
244
  ];
228
245
  beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
229
246
  var callback = function() {
247
+ var isClose = false;
248
+ var closeCallback = function() {
249
+ if (isClose) return;
250
+ isClose = true;
251
+ onClose();
252
+ setSending(false);
253
+ if (recordMsgObj.id) {
254
+ apiRef.contentApi.recordMsg(recordMsgObj);
255
+ apiRef.contentApi.setSendingId(recordMsgObj.id);
256
+ }
257
+ console.log("onclose: ", recordMsgObj);
258
+ };
230
259
  fetchEventSource(url, _object_spread({
231
260
  method: method,
232
261
  headers: _object_spread({
233
262
  "Content-Type": "application/json",
234
- "Accept": "text/event-stream,application/json"
263
+ Accept: "text/event-stream,application/json"
235
264
  }, headers()),
236
265
  body: params.apply(void 0, _to_consumable_array(arg).concat([
237
266
  beforeInfo
@@ -249,28 +278,25 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
249
278
  return null;
250
279
  },
251
280
  onmessage: function(ev) {
252
- var data = onMessage(ev);
281
+ var data = onMessage(ev, closeCallback);
253
282
  msgContent += data.content;
254
283
  delete data.content;
255
284
  recordMsgObj = _object_spread({
256
285
  createTime: createTime,
257
- content: msgContent,
286
+ content: msgContent || "正在输入...",
258
287
  location: "left",
259
288
  reference: null,
260
289
  source: null
261
290
  }, data);
291
+ apiRef.contentApi.setSendingId(data.id);
292
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
293
+ msgId = data.id;
262
294
  updateMsgRef.current = setTimeout(function() {
263
- apiRef.contentApi.updateMsg(msgId, recordMsgObj);
264
- msgId = data.id;
295
+ apiRef.contentApi.scrollToBottom();
265
296
  }, 100);
266
297
  },
267
298
  onclose: function() {
268
- onClose();
269
- setSending(false);
270
- if (recordMsgObj.id) {
271
- apiRef.contentApi.recordMsg(recordMsgObj);
272
- }
273
- console.log("onclose: ", recordMsgObj);
299
+ closeCallback();
274
300
  },
275
301
  onerror: function(err) {
276
302
  onError(err);
@@ -296,6 +322,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
296
322
  };
297
323
  return /*#__PURE__*/ _jsx("div", {
298
324
  className: "".concat(getCls("footer"), " ").concat(className),
325
+ ref: footerDomRef,
299
326
  children: /*#__PURE__*/ _jsxs("div", {
300
327
  className: "".concat(getCls("footerBody"), " ").concat(judegTextLengthWarn() ? getCls("footerBodyWarn") : ""),
301
328
  children: [
@@ -29,11 +29,11 @@ var 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 @@ var 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 @@ var 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 @@ 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", {
@@ -9,7 +9,7 @@ var 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 @@ var 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 @@ var upvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
15
15
  var 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",
@@ -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;
@@ -49,15 +50,16 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
49
50
  var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
50
51
  "copy",
51
52
  "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;
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, iconFileRender = contentConfig.iconFileRender;
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,7 +70,8 @@ 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;
@@ -84,6 +87,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
84
87
  msg
85
88
  ]);
86
89
  });
90
+ timerRef.current.scrollTimer = setTimeout(function() {
91
+ scrollToBottom();
92
+ }, 100);
87
93
  },
88
94
  updateMsg: function(id, obj) {
89
95
  setDataSource(function(data) {
@@ -120,6 +126,10 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
120
126
  },
121
127
  changeDataSource: function(data) {
122
128
  setDataSource(data);
129
+ },
130
+ scrollToBottom: scrollToBottom,
131
+ setSendingId: function(id) {
132
+ setSendingId(id);
123
133
  }
124
134
  };
125
135
  });
@@ -136,18 +146,18 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
136
146
  }, []);
137
147
  useEffect(function() {
138
148
  if (!virtuosoRef.current) return;
139
- virtuosoRef.current.scrollToIndex({
140
- index: "LAST",
141
- behavior: "auto"
142
- });
143
- clearTimeout(timerRef.current.scrollTimer);
144
- timerRef.current.scrollTimer = setTimeout(function() {
145
- virtuosoRef.current.scrollToIndex({
146
- index: "LAST",
147
- behavior: "auto",
148
- align: "end"
149
- });
150
- }, 500);
149
+ // virtuosoRef.current.scrollToIndex({
150
+ // index: "LAST", // 或者使用 dataSource.length - 1
151
+ // behavior: "auto", // 可以是 "smooth" 实现平滑滚动
152
+ // });
153
+ // clearTimeout(timerRef.current.scrollTimer);
154
+ // timerRef.current.scrollTimer = setTimeout(() => {
155
+ // virtuosoRef.current.scrollToIndex({
156
+ // index: "LAST", // 或者使用 dataSource.length - 1
157
+ // behavior: "auto", // 可以是 "smooth" 实现平滑滚动
158
+ // align: "end",
159
+ // });
160
+ // }, 500);
151
161
  }, [
152
162
  dataSource
153
163
  ]);
@@ -157,12 +167,21 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
157
167
  recordRef.current.total = total;
158
168
  recordRef.current.dataSource = dataSource;
159
169
  recordRef.current.maxPage = Math.ceil(total / pageSize);
170
+ recordRef.current.sendingId = sendingId;
160
171
  }, [
161
172
  page,
162
173
  pageSize,
163
174
  total,
164
- dataSource
175
+ dataSource,
176
+ sendingId
165
177
  ]);
178
+ var scrollToBottom = function() {
179
+ if (!virtuosoRef.current) return;
180
+ virtuosoRef.current.scrollToIndex({
181
+ index: "LAST",
182
+ behavior: "auto"
183
+ });
184
+ };
166
185
  var getData = function(page, pageSize) {
167
186
  setLoading(true);
168
187
  clearTimeout(timerRef.current.loadMore);
@@ -194,21 +213,41 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
194
213
  ]);
195
214
  var itemContent = function(index, item) {
196
215
  var timeNode = renderTime(item);
197
- var cahceKey = item.id + "-" + item.content;
198
216
  var contentNode = null;
199
- if (htmlRenderCache.has(cahceKey)) {
200
- contentNode = htmlRenderCache.get(cahceKey);
201
- } else {
202
- var html = markToHtml(item.content, item.id);
203
- contentNode = /*#__PURE__*/ _jsx("div", {
204
- dangerouslySetInnerHTML: {
205
- __html: html
206
- }
207
- });
208
- if (coverRenderText) {
209
- contentNode = coverRenderText(item, html);
217
+ var html = markToHtml(item.content, item.id);
218
+ contentNode = /*#__PURE__*/ _jsx("div", {
219
+ dangerouslySetInnerHTML: {
220
+ __html: html
210
221
  }
211
- htmlRenderCache.set(cahceKey, contentNode);
222
+ });
223
+ if (coverRenderText) {
224
+ contentNode = coverRenderText(item, html);
225
+ }
226
+ // item.type = "file";
227
+ // item.suffix = "docx";
228
+ // item.fileTitle = "这是一个文件名称.docx";
229
+ // item.fileSize = "5Mb";
230
+ if (item.type === "file") {
231
+ contentNode = /*#__PURE__*/ _jsxs("div", {
232
+ className: "".concat(getCls("msgItem-file")),
233
+ children: [
234
+ /*#__PURE__*/ _jsx("div", {
235
+ className: "".concat(getCls("msgItem-file-left")),
236
+ children: fileIconRender(item.suffix, iconFileRender)
237
+ }),
238
+ /*#__PURE__*/ _jsxs("div", {
239
+ className: "".concat(getCls("msgItem-file-right")),
240
+ children: [
241
+ /*#__PURE__*/ _jsx("p", {
242
+ children: item.fileTitle
243
+ }),
244
+ /*#__PURE__*/ _jsx("p", {
245
+ children: item.fileSize
246
+ })
247
+ ]
248
+ })
249
+ ]
250
+ });
212
251
  }
213
252
  // 是否显示时间
214
253
  var itemNode = /*#__PURE__*/ _jsx("div", {
@@ -309,6 +348,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
309
348
  topDom.style.cssText = "";
310
349
  };
311
350
  var renderAction = function(location, item) {
351
+ if (item.id === "inputing" || item.id === "helloMsg" || item.id === recordRef.current.sendingId) return null;
312
352
  var copyNode = /*#__PURE__*/ _jsx(CopyIcon, {
313
353
  prefix: prefix,
314
354
  content: item.content
@@ -322,6 +362,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
322
362
  prefix: prefix,
323
363
  isActive: item.vote === "up",
324
364
  clickFn: function() {
365
+ onVoteChange(item.vote === "up" ? "" : "up", item);
325
366
  setDataSource(function(data) {
326
367
  return data.map(function(ite) {
327
368
  if (item.id === ite.id) {
@@ -330,13 +371,13 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
330
371
  return ite;
331
372
  });
332
373
  });
333
- onVoteChange(item.vote === "up" ? "" : "up", item);
334
374
  }
335
375
  });
336
376
  var DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
337
377
  prefix: prefix,
338
378
  isActive: item.vote === "down",
339
379
  clickFn: function() {
380
+ onVoteChange(item.vote === "down" ? "" : "down", item);
340
381
  setDataSource(function(data) {
341
382
  return data.map(function(ite) {
342
383
  if (item.id === ite.id) {
@@ -345,7 +386,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
345
386
  return ite;
346
387
  });
347
388
  });
348
- onVoteChange(item.vote === "down" ? "" : "down", item);
349
389
  }
350
390
  });
351
391
  var RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
@@ -358,6 +398,12 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
358
398
  UpVoteNode = null;
359
399
  DownVoteNode = null;
360
400
  }
401
+ if (item.type === "file") {
402
+ copyNode = null;
403
+ UpVoteNode = null;
404
+ DownVoteNode = null;
405
+ RefreshNode = null;
406
+ }
361
407
  var leftNodes = null;
362
408
  var rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
363
409
  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
  }
@@ -467,7 +467,13 @@ var HistoryFun = function(props) {
467
467
  return /*#__PURE__*/ _jsxs("div", {
468
468
  className: styles.list,
469
469
  onClick: function() {
470
- calculationData(item.roomId, list.id, list.receiver);
470
+ calculationData(item.roomId, list.id, props.userData.mid == list.sender ? list.receiver : list.sender);
471
+ console.log("答应一下111111", {
472
+ roomId: item.roomId,
473
+ id: list.id,
474
+ sender: list.sender
475
+ });
476
+ // calculationData(item.roomId, list.id, list.sender);
471
477
  },
472
478
  children: [
473
479
  /*#__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{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.10.6",
3
+ "version": "0.10.8",
4
4
  "description": "组件功能描述",
5
5
  "config": {
6
6
  "commitizen": {