bhd-components 0.10.23 → 0.10.24

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.
@@ -13,6 +13,7 @@ import ViewImage from "../viewImage";
13
13
  import cssStyle from "./index.module.less";
14
14
  import cssStyleOnline from "./index2.module.less";
15
15
  import Input from "../bhdEnterInput";
16
+ import { Virtuoso } from "react-virtuoso";
16
17
  var styles = cssStyle;
17
18
  if (false) {
18
19
  styles = cssStyleOnline;
@@ -64,6 +65,7 @@ var CustomerService = function(props) {
64
65
  var _useState1 = _sliced_to_array(useState({}), 2), citationContent = _useState1[0], setCitationContent = _useState1[1]; //引用内容
65
66
  var _useState2 = _sliced_to_array(useState(""), 2), roomId = _useState2[0], setRoomId = _useState2[1]; //聊天室id
66
67
  var _useState3 = _sliced_to_array(useState([]), 2), historyMessageList = _useState3[0], setHistoryMessageList = _useState3[1]; //历史消息
68
+ var historyMessageListRef = useRef([]);
67
69
  var _useState4 = _sliced_to_array(useState(""), 2), keyWord = _useState4[0], setKeyWord = _useState4[1]; //搜索内容
68
70
  var _useState5 = _sliced_to_array(useState([]), 2), questionsList = _useState5[0], setQuestionsList = _useState5[1]; //问题列表
69
71
  var _useState6 = _sliced_to_array(useState([]), 2), hotQuestionsList = _useState6[0], setHotQuestionsList = _useState6[1]; //热门问题
@@ -77,6 +79,7 @@ var CustomerService = function(props) {
77
79
  var _useState13 = _sliced_to_array(useState(true), 2), finished = _useState13[0], setFinished = _useState13[1]; //是否结束生成
78
80
  var finishedRef = useRef(true); //是否结束生成
79
81
  var _useState14 = _sliced_to_array(useState(""), 2), lastId = _useState14[0], setLastId = _useState14[1]; //最后一条数据的id,可用于定位当前位置
82
+ var lastIdRef = useRef("");
80
83
  var _useState15 = _sliced_to_array(useState({}), 2), chatWith = _useState15[0], setChatWith = _useState15[1]; //聊天的老师id或ai
81
84
  var _useState16 = _sliced_to_array(useState(false), 2), firstLoad = _useState16[0], setFirstLoad = _useState16[1]; //第一次切换全屏时滚动到页面底部
82
85
  var _useState17 = _sliced_to_array(useState(45), 2), buttomHei = _useState17[0], setButtomHei = _useState17[1]; //底部输入框的高度
@@ -106,6 +109,7 @@ var CustomerService = function(props) {
106
109
  var ctrl = useRef(); //停止生成ai回答时使用
107
110
  var childRef = useRef(null); //获取子组件方法
108
111
  var scrollTopHei = useRef(0);
112
+ var _useState33 = _sliced_to_array(useState(true), 2), isPositionState = _useState33[0], setIsPositionState = _useState33[1];
109
113
  var isPosition = useRef(true);
110
114
  var recommendeQuestionID = useRef([]); //推荐问题id
111
115
  var videoHotQuestionsList = useRef([]); //视频热门问题
@@ -113,6 +117,10 @@ var CustomerService = function(props) {
113
117
  var newShowType = useRef(false);
114
118
  var mid = props.userData.mid;
115
119
  var renderAiAnswerTimer = useRef(null);
120
+ var historyMessageListVirtuosoRef = useRef(null);
121
+ var _useState34 = _sliced_to_array(useState(0), 2), firstItemIndex = _useState34[0], setFirstItemIndex = _useState34[1];
122
+ var _useState35 = _sliced_to_array(useState(null), 2), historyMessageListVirtuosoHeight = _useState35[0], setHistoryMessageListVirtuosoHeight = _useState35[1];
123
+ var msgStreamingCountRef = useRef(0);
116
124
  var remarkable = new Remarkable({
117
125
  html: true,
118
126
  highlight: function highlight(str, lang) {
@@ -148,8 +156,7 @@ var CustomerService = function(props) {
148
156
  };
149
157
  return newRemarkable.render(message);
150
158
  };
151
- var _useState33 //1是 screenShotPlugin 2是html2canvas
152
- = _sliced_to_array(useState(0), 2), screenShotType = _useState33[0], setScreenShotType = _useState33[1];
159
+ var _useState36 = _sliced_to_array(useState(0), 2), screenShotType = _useState36[0], setScreenShotType = _useState36[1]; //1是 screenShotPlugin 2是html2canvas
153
160
  var screenShotPlugin = useRef();
154
161
  useEffect(function() {
155
162
  // if(config && config.type == 'video'){
@@ -168,8 +175,8 @@ var CustomerService = function(props) {
168
175
  setImgBese64("");
169
176
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
170
177
  setScreenShotType(1);
171
- console.log("看看变了没有1213133");
172
- console.log("截图方式:【screenShotPlugin】", ScreenShot);
178
+ // console.log("看看变了没有1213133");
179
+ // console.log("截图方式:【screenShotPlugin】", ScreenShot);
173
180
  screenShotPlugin.current = new ScreenShot({
174
181
  clickCutFullScreen: true,
175
182
  enableWebRtc: true,
@@ -206,7 +213,7 @@ var CustomerService = function(props) {
206
213
  },
207
214
  cancelCallback: function(err) {
208
215
  if (err.code === -1 || err.code === -2) {
209
- console.log(err);
216
+ // console.log(err);
210
217
  newShowType.current = false;
211
218
  if (saveShowType != -1) {
212
219
  setShowType(saveShowType);
@@ -222,8 +229,9 @@ var CustomerService = function(props) {
222
229
  });
223
230
  } else {
224
231
  setScreenShotType(2);
225
- console.log("截图方式:【html2canvas】");
232
+ // console.log("截图方式:【html2canvas】");
226
233
  html2canvas(screenshotAreaId, {
234
+ //__docusaurus
227
235
  useCORS: true,
228
236
  allowTaint: true,
229
237
  scale: 1,
@@ -275,11 +283,11 @@ var CustomerService = function(props) {
275
283
  // },
276
284
  // });
277
285
  } catch (error) {
278
- console.log(error);
286
+ // console.log(error);
279
287
  }
280
288
  };
281
289
  var cancelScreenshot = function cancelScreenshot() {
282
- console.log("cancelScreenshotcancelScreenshotcancelScreenshot");
290
+ // console.log("cancelScreenshotcancelScreenshotcancelScreenshot");
283
291
  newShowType.current = false;
284
292
  if (saveShowType != -1) {
285
293
  setShowType(saveShowType);
@@ -291,72 +299,81 @@ var CustomerService = function(props) {
291
299
  screenShotPlugin.current.destroyComponents();
292
300
  }
293
301
  };
294
- var handleScroll = function handleScroll() {
295
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
296
- var scrollTop = container.scrollTop;
297
- var clientHeight = container.clientHeight;
298
- var scrollHeight = container.scrollHeight;
299
- // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
300
- if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
301
- // if (pageNumHistory > 1) {
302
- // console.log(pageNumHistory,'pageNumpageNumpageNum')
303
- var number = pageNumHistory - 1;
304
- setPageNumHistory(number);
305
- clearTimeout(listTimer.current);
306
- listTimer.current = setTimeout(function() {
307
- if (number > 0) {
308
- setBottomLoading(true);
309
- getHistoryMessage(number, 4);
310
- setLastId("");
311
- } else {
312
- setPageNumHistory(0);
313
- }
314
- }, 1000);
315
- // } else {
316
- // }
317
- }
318
- if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
319
- console.log("到顶了", pageNum);
320
- setLoading(true);
321
- var number1 = pageNum + 1;
322
- setPageNum(function(pageNum) {
323
- return pageNum + 1;
324
- });
325
- listTimer.current = setTimeout(function() {
326
- getHistoryMessage(number1, 2);
327
- }, 1000);
328
- }
329
- //生成答案过程中
330
- if (!finished && scrollHeight > scrollTop) {
331
- console.log("生成答案过程中", scrollTopHei.current, scrollTop);
332
- // setIsPosition(false);
333
- isPosition.current = false;
334
- }
335
- if (!finished && clientHeight + scrollTop >= scrollHeight) {
336
- console.log("到顶了111", clientHeight, scrollTop, scrollHeight);
337
- isPosition.current = true;
338
- }
339
- scrollTopHei.current = scrollTop;
340
- };
341
302
  //|| showScreenshot
342
303
  if (showType == 5 || showScreenshot) {
343
- console.log("bbbbbbbbbbbbbb");
304
+ // console.log("bbbbbbbbbbbbbb");
344
305
  handlerHtml2canvas();
345
306
  // window.addEventListener('resize',handlerHtml2canvas)
346
307
  }
347
308
  if (showType != 1 && !firstLoad && pageCount > 0) {
348
309
  setFirstLoad(true);
349
- scrollToBottom();
350
- }
351
- var content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
352
- if (content) {
353
- content.addEventListener("scroll", handleScroll);
310
+ // scrollToBottom();
354
311
  }
312
+ // function handleScroll() {
313
+ // const container = document.getElementById(
314
+ // showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
315
+ // );
316
+ // const scrollTop = container.scrollTop;
317
+ // const clientHeight = container.clientHeight;
318
+ // const scrollHeight = container.scrollHeight;
319
+ // // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
320
+ // if (
321
+ // clientHeight + scrollTop + 0.5 >= scrollHeight &&
322
+ // pageNumHistory > 1
323
+ // ) {
324
+ // // if (pageNumHistory > 1) {
325
+ // // console.log(pageNumHistory,'pageNumpageNumpageNum')
326
+ // let number = pageNumHistory - 1;
327
+ // setPageNumHistory(number);
328
+ // clearTimeout(listTimer.current);
329
+ // listTimer.current = setTimeout(() => {
330
+ // if (number > 0) {
331
+ // setBottomLoading(true);
332
+ // getHistoryMessage(number, 4);
333
+ // setLastId("");
334
+ // } else {
335
+ // setPageNumHistory(0);
336
+ // }
337
+ // }, 1000);
338
+ // // } else {
339
+ // // }
340
+ // }
341
+ // if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
342
+ // // console.log("到顶了", pageNum);
343
+ // setLoading(true);
344
+ // let number = pageNum + 1;
345
+ // setPageNum((pageNum) => {
346
+ // return pageNum + 1;
347
+ // });
348
+ // listTimer.current = setTimeout(() => {
349
+ // getHistoryMessage(number, 2);
350
+ // }, 1000);
351
+ // }
352
+ // //生成答案过程中
353
+ // if (!finished && scrollHeight > scrollTop) {
354
+ // // console.log("生成答案过程中", scrollTopHei.current, scrollTop);
355
+ // // setIsPosition(false);
356
+ // isPosition.current = false;
357
+ // }
358
+ // if (!finished && clientHeight + scrollTop >= scrollHeight) {
359
+ // // console.log("到顶了111", clientHeight, scrollTop, scrollHeight);
360
+ // isPosition.current = true;
361
+ // }
362
+ // scrollTopHei.current = scrollTop;
363
+ // }
364
+ // const content = document.getElementById(
365
+ // showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
366
+ // );
367
+ // if (content) {
368
+ // content.addEventListener("scroll", handleScroll);
369
+ // }
355
370
  return function() {
356
- var content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
357
- if (content) {
358
- content.removeEventListener("scroll", handleScroll);
359
- }
371
+ // const content = document.getElementById(
372
+ // showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
373
+ // );
374
+ // if (content) {
375
+ // content.removeEventListener("scroll", handleScroll);
376
+ // }
360
377
  window.removeEventListener("resize", handlerHtml2canvas);
361
378
  window.removeEventListener("resize", cancelScreenshot);
362
379
  };
@@ -366,18 +383,41 @@ var CustomerService = function(props) {
366
383
  pageCount,
367
384
  showScreenshot
368
385
  ]);
386
+ useEffect(function() {
387
+ historyMessageListRef.current = historyMessageList;
388
+ }, [
389
+ historyMessageList
390
+ ]);
391
+ useEffect(function() {
392
+ lastIdRef.current = lastId;
393
+ }, [
394
+ lastId
395
+ ]);
396
+ useEffect(function() {
397
+ console.log("isPositionState", isPositionState, isPosition.current);
398
+ }, [
399
+ isPositionState
400
+ ]);
369
401
  useEffect(function() {
370
402
  resettingBottomHei();
371
- scrollToBottom();
403
+ var timer = setTimeout(function() {
404
+ scrollToBottom();
405
+ clearTimeout(timer);
406
+ }, 80);
372
407
  var dom = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
373
408
  if (dom) {
409
+ var hei = null;
374
410
  if (showType == 1) {
375
- dom.style.maxHeight = "".concat(window.innerHeight - 60 - buttomHei, "px");
411
+ hei = window.innerHeight - 60 - buttomHei;
412
+ dom.style.maxHeight = "".concat(hei, "px");
376
413
  } else if (showType == 3) {
377
- dom.style.maxHeight = "".concat(window.innerHeight - 114 - buttomHei, "px");
414
+ hei = window.innerHeight - 114 - buttomHei;
415
+ dom.style.maxHeight = "".concat(hei, "px");
378
416
  } else {
379
- dom.style.maxHeight = "".concat(window.innerHeight - 160 - 62 - buttomHei, "px");
417
+ hei = window.innerHeight - 160 - 62 - buttomHei;
418
+ dom.style.maxHeight = "".concat(hei, "px");
380
419
  }
420
+ setHistoryMessageListVirtuosoHeight(hei);
381
421
  }
382
422
  }, [
383
423
  buttomHei,
@@ -509,17 +549,17 @@ var CustomerService = function(props) {
509
549
  // watchTime= 753
510
550
  if (videoId && courseId && sectionId) {
511
551
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
512
- "recommendedQuestions": [],
513
- "contexts": [
552
+ recommendedQuestions: [],
553
+ contexts: [
514
554
  {
515
- "type": "VIDEO",
516
- "courseId": courseId,
517
- "sectionId": sectionId,
518
- "videoId": videoId,
519
- "watchTime": watchTime
555
+ type: "VIDEO",
556
+ courseId: courseId,
557
+ sectionId: sectionId,
558
+ videoId: videoId,
559
+ watchTime: watchTime
520
560
  }
521
561
  ],
522
- "maximum": 3
562
+ maximum: 3
523
563
  }).then(function(res) {
524
564
  try {
525
565
  var data = res.data.questions;
@@ -545,18 +585,18 @@ var CustomerService = function(props) {
545
585
  recommendeQuestionID.current = data.map(function(item) {
546
586
  return item.id;
547
587
  });
548
- console.log(recommendeQuestionID.current, 4444444);
588
+ // console.log(recommendeQuestionID.current, 4444444);
549
589
  }
550
- console.log("dflkvmdfklvdf欢迎语", data);
590
+ // console.log("dflkvmdfklvdf欢迎语", data);
551
591
  var obj = {
552
592
  roomId: roomId,
553
593
  sender: "AI",
554
594
  recevier: mid,
555
- message: "Hi,我是智能学习助手,你遇到了什么问题?",
595
+ message: "Hi,我是智能学习助手,你遇到了什么问题?1",
556
596
  extraInfos: questionsList == null ? null : questionsList
557
597
  };
558
598
  if (pageNumHistory <= 1) {
559
- console.log("欢迎语");
599
+ // console.log("欢迎语");
560
600
  setHistoryMessageList(function(historyMessageList) {
561
601
  var newHistoryMessageList = historyMessageList.filter(function(e) {
562
602
  return e.id != "123456_date";
@@ -582,7 +622,7 @@ var CustomerService = function(props) {
582
622
  roomId: roomId,
583
623
  sender: "AI",
584
624
  recevier: mid,
585
- message: "Hi,我是智能学习助手,你遇到了什么问题?"
625
+ message: "Hi,我是智能学习助手,你遇到了什么问题?2"
586
626
  };
587
627
  if (pageNumHistory <= 1) {
588
628
  setHistoryMessageList(function(historyMessageList) {
@@ -617,6 +657,7 @@ var CustomerService = function(props) {
617
657
  maxPageSize: 5
618
658
  }
619
659
  }).then(function(res) {
660
+ finishedRef.current = true;
620
661
  setFinished(true);
621
662
  if (res.data.total > 0) {
622
663
  var questionsList = res.data.questions.map(function(item) {
@@ -849,7 +890,6 @@ var CustomerService = function(props) {
849
890
  switch(_state.label){
850
891
  case 0:
851
892
  type = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "";
852
- console.log(item, flag, 888888888);
853
893
  questions = [];
854
894
  if (item && flag) {
855
895
  questions = [
@@ -890,13 +930,13 @@ var CustomerService = function(props) {
890
930
  return newHistoryMessageList;
891
931
  });
892
932
  }
933
+ finishedRef.current = false;
893
934
  setFinished(false);
894
935
  aiSendQuestions(3, sendData, 1);
895
936
  return [
896
937
  2
897
938
  ];
898
939
  }
899
- console.log(questions, "知识库内容11111");
900
940
  obj = {
901
941
  roomId: roomId,
902
942
  sender: mid,
@@ -929,7 +969,6 @@ var CustomerService = function(props) {
929
969
  3,
930
970
  4
931
971
  ];
932
- console.log("citationContent", citationContent);
933
972
  sendData1 = {
934
973
  //相关数据
935
974
  roomId: roomId,
@@ -949,14 +988,14 @@ var CustomerService = function(props) {
949
988
  ];
950
989
  case 2:
951
990
  base64 = _state.sent();
952
- console.log("base64", base64);
953
- console.log("citationContent.imageUrl", citationContent.imageUrl);
991
+ // console.log("base64", base64);
992
+ // console.log("citationContent.imageUrl", citationContent.imageUrl);
954
993
  sendData1.image = base64;
955
994
  imageUrl = base64;
956
995
  _state.label = 3;
957
996
  case 3:
958
997
  if (screenshotBese64) {
959
- console.log("screenshotBese64", screenshotBese64);
998
+ // console.log("screenshotBese64", screenshotBese64);
960
999
  sendData1.image = screenshotBese64;
961
1000
  imageUrl = screenshotBese64;
962
1001
  }
@@ -982,6 +1021,7 @@ var CustomerService = function(props) {
982
1021
  return newHistoryMessageList;
983
1022
  });
984
1023
  }
1024
+ finishedRef.current = false;
985
1025
  setFinished(false);
986
1026
  aiSendQuestions(3, sendData1, 1);
987
1027
  setScreenshotBese64("");
@@ -1019,7 +1059,7 @@ var CustomerService = function(props) {
1019
1059
  });
1020
1060
  scrollToBottom();
1021
1061
  }
1022
- console.log(type, "接受答案77777");
1062
+ // console.log(type, "接受答案77777");
1023
1063
  http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
1024
1064
  if (res.data.id) {
1025
1065
  if (pageNumHistory <= 1) {
@@ -1073,6 +1113,7 @@ var CustomerService = function(props) {
1073
1113
  return item.id != "123456";
1074
1114
  });
1075
1115
  });
1116
+ finishedRef.current = true;
1076
1117
  setFinished(true);
1077
1118
  ctrl.current.abort();
1078
1119
  setHistoryMessageList(function(historyMessageList) {
@@ -1087,7 +1128,11 @@ var CustomerService = function(props) {
1087
1128
  });
1088
1129
  });
1089
1130
  }, 60 * 1000);
1131
+ finishedRef.current = false;
1090
1132
  setFinished(false);
1133
+ isPosition.current = true;
1134
+ setIsPositionState(true);
1135
+ msgStreamingCountRef.current = 0;
1091
1136
  if (config && config.type == "video" && config.params) {
1092
1137
  var params = config.params;
1093
1138
  var videoId = params.videoId;
@@ -1171,7 +1216,8 @@ var CustomerService = function(props) {
1171
1216
  console.info("eventSource open: ", res);
1172
1217
  clearTimeout(receiveMessageTimer.current);
1173
1218
  if (res.status >= 300) {
1174
- console.log("sdckjsdncskdcjsdc", res.status);
1219
+ // console.log("sdckjsdncskdcjsdc", res.status);
1220
+ finishedRef.current = true;
1175
1221
  setFinished(true);
1176
1222
  setHistoryMessageList(function(historyMessageList) {
1177
1223
  return historyMessageList.filter(function(item) {
@@ -1181,12 +1227,13 @@ var CustomerService = function(props) {
1181
1227
  ctrl.current.abort();
1182
1228
  }
1183
1229
  if (res.status == 200) {
1230
+ finishedRef.current = true;
1184
1231
  setFinished(false);
1185
1232
  }
1186
1233
  if (res.status == 401) {
1187
1234
  //身份认证未通过,从新请求新的token后再次发送请求
1188
1235
  verifyJWT(urllocation).then(function() {
1189
- console.log("重新请求");
1236
+ // console.log("重新请求");
1190
1237
  setHistoryMessageList(function(historyMessageList) {
1191
1238
  return historyMessageList.filter(function(item) {
1192
1239
  return item.id != "123456" && item.id != "654321";
@@ -1197,7 +1244,7 @@ var CustomerService = function(props) {
1197
1244
  }
1198
1245
  if (res.status == 403) {
1199
1246
  //暂无权限
1200
- console.log("暂无权限");
1247
+ // console.log("暂无权限");
1201
1248
  setHistoryMessageList(function(historyMessageList) {
1202
1249
  return historyMessageList.concat({
1203
1250
  roomId: roomId,
@@ -1238,7 +1285,7 @@ var CustomerService = function(props) {
1238
1285
  })();
1239
1286
  },
1240
1287
  onerror: function onerror(err) {
1241
- console.log(err, "dflkvdmfvlkdfv");
1288
+ // console.log(err, "dflkvdmfvlkdfv");
1242
1289
  var state = err.response;
1243
1290
  setHistoryMessageList(function(historyMessageList) {
1244
1291
  return historyMessageList.concat({
@@ -1257,39 +1304,26 @@ var CustomerService = function(props) {
1257
1304
  // console.log("eventSource msg: ", event.data);
1258
1305
  var msg = JSON.parse(event.data);
1259
1306
  if (msg.message) {}
1260
- setFinished(function(prevData) {
1261
- finishedRef.current = false;
1262
- return finishedRef.current;
1263
- });
1307
+ finishedRef.current = false;
1308
+ setFinished(false);
1309
+ msgStreamingCountRef.current = msgStreamingCountRef.current + 1;
1264
1310
  console.log("返回中", msg);
1265
1311
  content = content + msg.message;
1266
- // isPosition.current = true;
1267
- // clearTimeout(renderAiAnswerTimer.current)
1268
1312
  renderAiAnswerTimer.current = setTimeout(function() {
1269
1313
  if (!finishedRef.current) {
1270
1314
  renderAiAnswer(msg, id, type);
1271
1315
  }
1272
- }, 100);
1316
+ }, 1 * msgStreamingCountRef.current);
1273
1317
  if (msg.finished) {
1274
1318
  // console.log('返回完成',msg)
1275
- // setFinished(true); //发送结束
1276
1319
  if (!flagKeyWord) {
1277
1320
  videoPageQuestiionsList(2);
1278
1321
  }
1279
- // isPosition.current = true;
1280
- // setTimeout(()=>{
1281
- // isPosition.current = true;
1282
- // },100)
1283
1322
  testLabQuestion(JSON.parse(data).message, content, "");
1284
1323
  } else {}
1285
1324
  },
1286
1325
  onclose: function onclose() {
1287
1326
  console.log("eventSource close");
1288
- // setFinished(true); //发送结束
1289
- // // isPosition.current = true;
1290
- // setTimeout(()=>{
1291
- // isPosition.current = true;
1292
- // },100)
1293
1327
  setHistoryMessageList(function(historyMessageList) {
1294
1328
  return historyMessageList.filter(function(item) {
1295
1329
  return item.id != "123456";
@@ -1321,7 +1355,6 @@ var CustomerService = function(props) {
1321
1355
  var list = prevHistoryMessageList.filter(function(item) {
1322
1356
  return item.id == id;
1323
1357
  });
1324
- // console.log('renderAiAnswer',{list1,list})
1325
1358
  var message = "";
1326
1359
  if (list.length == 0) {
1327
1360
  message = obj.message;
@@ -1371,25 +1404,13 @@ var CustomerService = function(props) {
1371
1404
  }
1372
1405
  });
1373
1406
  console.log("isPosition", isPosition.current);
1374
- if (isPosition.current) {
1375
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1376
- if (container) {
1377
- container.scrollTop = container.scrollHeight;
1378
- }
1379
- }
1407
+ scrollToBottom();
1380
1408
  if (msg.finished) {
1381
- console.log("返回完成", msg);
1409
+ console.log("返回完成", msg, msgStreamingCountRef.current);
1382
1410
  //发送结束
1383
- setFinished(function(prevData) {
1384
- finishedRef.current = true;
1385
- return finishedRef.current;
1386
- });
1411
+ finishedRef.current = true;
1412
+ setFinished(true);
1387
1413
  }
1388
- // console.log('historyMessageList',historyMessageList)
1389
- // if(isPosition.current){
1390
- // console.log('mmmmmmmmmmmmm打印一下',)
1391
- // scrollToBottom();
1392
- // }
1393
1414
  };
1394
1415
  //问题记录到实验报告中
1395
1416
  var testLabQuestion = function(title, content, teachId) {
@@ -1402,7 +1423,7 @@ var CustomerService = function(props) {
1402
1423
  stepId: stepId,
1403
1424
  stepIds: stepIds
1404
1425
  }).then(function() {
1405
- console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
1426
+ // console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
1406
1427
  setChatObj(function(list1) {
1407
1428
  var list = list1.filter(function(e) {
1408
1429
  return e.roomId != roomId;
@@ -1442,7 +1463,7 @@ var CustomerService = function(props) {
1442
1463
  params: {
1443
1464
  roomId: rid,
1444
1465
  page: page,
1445
- maxPageSize: 10,
1466
+ maxPageSize: 30,
1446
1467
  direction: "desc"
1447
1468
  }
1448
1469
  }).then(function(res) {
@@ -1451,7 +1472,7 @@ var CustomerService = function(props) {
1451
1472
  if (res.data.messages.length > 0) {
1452
1473
  clearTimeout(listTimer.current);
1453
1474
  var total = res.data.total;
1454
- var maxPageSize = 10;
1475
+ var maxPageSize = 30;
1455
1476
  var dataList = res.data.messages.reverse();
1456
1477
  //历史记录点击进来的,多加载一页,防止定位不准
1457
1478
  if (flag == 1 && page > 1) {
@@ -1461,6 +1482,7 @@ var CustomerService = function(props) {
1461
1482
  return;
1462
1483
  }
1463
1484
  setPageCount(Math.ceil(total / maxPageSize));
1485
+ setFirstItemIndex(total - maxPageSize * (page - 1));
1464
1486
  var newHistoryMessageList = [];
1465
1487
  setHistoryMessageList(function(historyMessageList) {
1466
1488
  //获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
@@ -1506,7 +1528,7 @@ var CustomerService = function(props) {
1506
1528
  scrollToBottom();
1507
1529
  }, 1000);
1508
1530
  } else {
1509
- scrollTo("li_flag");
1531
+ scrollTo(lastIdRef.current);
1510
1532
  }
1511
1533
  }
1512
1534
  setBottomLoading(false);
@@ -1557,7 +1579,7 @@ var CustomerService = function(props) {
1557
1579
  params: {
1558
1580
  roomId: rid,
1559
1581
  page: 1,
1560
- maxPageSize: totalNumber == 0 ? 10 : totalNumber,
1582
+ maxPageSize: totalNumber == 0 ? 30 : totalNumber,
1561
1583
  direction: "desc"
1562
1584
  }
1563
1585
  }).then(function(res) {
@@ -1578,7 +1600,7 @@ var CustomerService = function(props) {
1578
1600
  return newHistoryMessageList;
1579
1601
  });
1580
1602
  // console.log(dataList.length , originList,lastId,'dfkvdnfkvdfj44444');
1581
- if (!lastId && originList != newList) {
1603
+ if (!lastIdRef.current && originList != newList) {
1582
1604
  scrollToBottom();
1583
1605
  readMessage(roomId, urllocation, userData, http);
1584
1606
  }
@@ -1609,7 +1631,7 @@ var CustomerService = function(props) {
1609
1631
  if (room.length > 0) {
1610
1632
  // console.log(room,'dfvdfvdfvdfv')
1611
1633
  var chatID = room[0].id;
1612
- console.log(chatID, "chatIDchatIDchatID");
1634
+ // console.log(chatID, "chatIDchatIDchatID");
1613
1635
  var index = -1;
1614
1636
  newHistoryMessageList.forEach(function(item, i) {
1615
1637
  // console.log(item,item.id,'lskdcmsldksdcsdc')
@@ -1621,7 +1643,7 @@ var CustomerService = function(props) {
1621
1643
  //有新的消息
1622
1644
  if (index != -1) {
1623
1645
  var newMessage = newHistoryMessageList.slice(index);
1624
- console.log(newMessage, "newMessagenewMessage");
1646
+ // console.log(newMessage, "newMessagenewMessage");
1625
1647
  var result = [];
1626
1648
  newMessage.forEach(function(item, index) {
1627
1649
  var isQuestion = item.receiver !== mid; //是否为问题
@@ -1637,7 +1659,7 @@ var CustomerService = function(props) {
1637
1659
  }
1638
1660
  }
1639
1661
  });
1640
- console.log(result, "存储的消息");
1662
+ // console.log(result, "存储的消息");
1641
1663
  result.map(function(item) {
1642
1664
  testLabQuestion(item.question, item.answer, String(item.id));
1643
1665
  });
@@ -1737,7 +1759,7 @@ var CustomerService = function(props) {
1737
1759
  setQuestionsList(questionList);
1738
1760
  }
1739
1761
  if (questionList.length < 4 && flag == 3) {
1740
- console.log("视频页面,联想问题小于4个");
1762
+ // console.log("视频页面,联想问题小于4个");
1741
1763
  //视频页面,联想问题小于4个
1742
1764
  http.get("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions"), {
1743
1765
  params: {
@@ -1766,7 +1788,7 @@ var CustomerService = function(props) {
1766
1788
  //获取视频页面热门问题 flag == 1,默认推荐问题 == 2,底部渲染问题,flag == 3,ai回答后请求相关问题
1767
1789
  var videoPageQuestiionsList = function() {
1768
1790
  var flag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
1769
- console.log(flag, props, 3333333);
1791
+ // console.log(flag, props, 3333333);
1770
1792
  if (config && config.type == "video" && config.params) {
1771
1793
  var params = config.params;
1772
1794
  var videoId = params.videoId;
@@ -1778,19 +1800,22 @@ var CustomerService = function(props) {
1778
1800
  // videoId= "71399",
1779
1801
  // watchTime= 527
1780
1802
  if (videoId && courseId && sectionId) {
1781
- console.log(recommendeQuestionID.current, "recommendeQuestionID.current");
1803
+ // console.log(
1804
+ // recommendeQuestionID.current,
1805
+ // "recommendeQuestionID.current"
1806
+ // );
1782
1807
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
1783
- "recommendedQuestions": recommendeQuestionID.current,
1784
- "contexts": [
1808
+ recommendedQuestions: recommendeQuestionID.current,
1809
+ contexts: [
1785
1810
  {
1786
- "type": "VIDEO",
1787
- "courseId": courseId,
1788
- "sectionId": sectionId,
1789
- "videoId": videoId,
1790
- "watchTime": watchTime
1811
+ type: "VIDEO",
1812
+ courseId: courseId,
1813
+ sectionId: sectionId,
1814
+ videoId: videoId,
1815
+ watchTime: watchTime
1791
1816
  }
1792
1817
  ],
1793
- "maximum": flag == 1 || flag == 2 ? 3 : 5
1818
+ maximum: flag == 1 || flag == 2 ? 3 : 5
1794
1819
  }).then(function(res) {
1795
1820
  if (res.data.total > 0) {
1796
1821
  var data = res.data.questions;
@@ -1904,32 +1929,33 @@ var CustomerService = function(props) {
1904
1929
  };
1905
1930
  //设置滚动条滚动到底部
1906
1931
  var scrollToBottom = function() {
1907
- setTimeout(function() {
1908
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1909
- console.log("滚到底部", container, showType);
1910
- if (container) {
1911
- console.log("最好的最好的最好的", container.scrollHeight);
1912
- container.scrollTop = container.scrollHeight;
1913
- //container.scrollTop = new Date().getTime()
1914
- }
1915
- }, 100);
1932
+ if (!historyMessageListVirtuosoRef.current || !isPosition.current) {
1933
+ return;
1934
+ } else {
1935
+ historyMessageListVirtuosoRef.current.scrollToIndex({
1936
+ index: "LAST",
1937
+ align: "end",
1938
+ behavior: "auto"
1939
+ });
1940
+ }
1916
1941
  };
1917
1942
  //滚动到指定位置
1918
1943
  var scrollTo = function(id) {
1919
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1920
- var container2 = document.getElementById(id);
1921
- if (container && container2) {
1922
- container.scrollTop = 60;
1923
- try {
1924
- setTimeout(function() {
1925
- var top = showType == 1 || showType == 3 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1926
- $("#".concat(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal")).animate({
1927
- scrollTop: top
1928
- }, 0);
1929
- }, 100);
1930
- } catch (error) {}
1944
+ var timer = setTimeout(function() {
1945
+ var index = historyMessageListRef.current.findIndex(function(x) {
1946
+ return x.id === id;
1947
+ });
1948
+ // console.log("scrollTo", id, index, historyMessageListRef.current);
1949
+ if (index > -1) {
1950
+ historyMessageListVirtuosoRef.current.scrollToIndex({
1951
+ index: index,
1952
+ align: "start",
1953
+ behavior: "auto"
1954
+ });
1955
+ }
1931
1956
  setLoading(false);
1932
- }
1957
+ clearTimeout(timer);
1958
+ }, 10);
1933
1959
  };
1934
1960
  //重置底部输入框高度
1935
1961
  var resettingBottomHei = function() {
@@ -2153,6 +2179,7 @@ var CustomerService = function(props) {
2153
2179
  if (ctrl && ctrl.current) {
2154
2180
  ctrl.current.abort();
2155
2181
  }
2182
+ finishedRef.current = true;
2156
2183
  setFinished(true);
2157
2184
  } catch (error) {}
2158
2185
  setTimeout(function() {
@@ -2181,161 +2208,412 @@ var CustomerService = function(props) {
2181
2208
  };
2182
2209
  //渲染问答
2183
2210
  var renderQuestion = function() {
2184
- // if (historyMessageList.length > 0) {
2185
- return /*#__PURE__*/ _jsx("ul", {
2186
- className: styles.message_con,
2187
- children: historyMessageList.map(function(item, i) {
2188
- var timeObj = parseDate(item.createdAt);
2189
- // console.log(item.message);
2190
- var message = item.message;
2191
- var li;
2192
- // 是否需要显示日期
2193
- var itemIndex = historyMessageList.findIndex(function(ite) {
2194
- return ite.id === item.id;
2195
- });
2196
- var time = "";
2197
- if (historyMessageList.length > 1) {
2198
- if (itemIndex <= 0) {
2199
- //第一项
2211
+ var itemContent = function itemContent(index, item) {
2212
+ var _historyMessageList_findIndex;
2213
+ var i = (_historyMessageList_findIndex = historyMessageList.findIndex(function(x) {
2214
+ return x.id == item.id;
2215
+ })) !== null && _historyMessageList_findIndex !== void 0 ? _historyMessageList_findIndex : index;
2216
+ var timeObj = parseDate(item.createdAt);
2217
+ // console.log(item.message);
2218
+ var message = item.message;
2219
+ var li;
2220
+ // 是否需要显示日期
2221
+ var itemIndex = historyMessageList.findIndex(function(ite) {
2222
+ return ite.id === item.id;
2223
+ });
2224
+ var time = "";
2225
+ if (historyMessageList.length > 1) {
2226
+ if (itemIndex <= 0) {
2227
+ //第一项
2228
+ time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
2229
+ } else {
2230
+ //非第一项 与上一项进行对比
2231
+ var beforeTime = historyMessageList[itemIndex - 1].createdAt;
2232
+ //判断与上一条数据 是否跨天
2233
+ var beforeTimeObj = parseDate(beforeTime);
2234
+ var beforeTimeStr = "".concat(beforeTimeObj.year, "-").concat(beforeTimeObj.month, "-").concat(beforeTimeObj.day);
2235
+ var curTimeStr = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day);
2236
+ if (beforeTimeStr !== curTimeStr) {
2200
2237
  time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
2201
2238
  } else {
2202
- //非第一项 与上一项进行对比
2203
- var beforeTime = historyMessageList[itemIndex - 1].createdAt;
2204
- //判断与上一条数据 是否跨天
2205
- var beforeTimeObj = parseDate(beforeTime);
2206
- var beforeTimeStr = "".concat(beforeTimeObj.year, "-").concat(beforeTimeObj.month, "-").concat(beforeTimeObj.day);
2207
- var curTimeStr = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day);
2208
- if (beforeTimeStr !== curTimeStr) {
2209
- time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
2210
- } else {
2211
- //没有跨天 判断是否相隔超过10分钟
2212
- if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
2213
- time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
2214
- }
2239
+ //没有跨天 判断是否相隔超过10分钟
2240
+ if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
2241
+ time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
2215
2242
  }
2216
2243
  }
2217
2244
  }
2218
- var dataTime = time;
2219
- // let code = message.split("```");
2220
- // code = code[1];
2221
- // console.log(code,888888888);
2222
- if (lastId == item.id && keyWordProblem != "") {
2223
- //点击历史记录时,找到关键字,防止关键字和标签名重复
2224
- // let key_sign = 'sign_'+new Date().getTime();+'sign';
2225
- // message = message.replaceAll(keyWordProblem, (e:any) => {
2226
- // return key_sign;
2227
- // });
2228
- // message = remarkable.render(message);
2229
- // message = message.replaceAll(key_sign, (e:any) => {
2230
- // return `<span class=${styles.sign}>${keyWordProblem}</span>`;
2231
- // });
2232
- message = remarkReplaceKey(message, keyWordProblem);
2233
- } else {
2234
- message = remarkable.render(message);
2235
- }
2236
- var position = 0;
2237
- message = message.replaceAll(new RegExp("<pre", "ig"), function(i, index) {
2238
- position++;
2239
- var text = "<p class='".concat(styles.copyCode, " copyCodeFun' data-id=").concat(item.id, " data-position=").concat(position, ">\n <span class='").concat(styles.icon, ' copy\' >\n <svg\n width="1em"\n height="1em"\n viewBox="0 0 14 14"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n xmlns="http://www.w3.org/2000/svg"\n >\n <g clip-path="url(#clip0_518_8403)">\n <path\n 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"\n />\n </g>\n <defs>\n <clipPath id="clip0_518_8403">\n <rect width="16" height="16" />\n </clipPath>\n </defs>\n </svg>\n </span>\n <span class=\'').concat(styles.icon, ' copy_success_flag\'>\n <svg\n width="1em"\n height="1em"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n viewBox="0 0 12 7"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path d="M11.2242 0.375687C11.4586 0.610002 11.4586 0.989901 11.2242 1.22422L4.82424 7.62422C4.58992 7.85853 4.21003 7.85853 3.97571 7.62422L0.775712 4.42422C0.541397 4.1899 0.541397 3.81 0.775712 3.57569C1.01003 3.34137 1.38993 3.34137 1.62424 3.57569L4.39998 6.35142L10.3757 0.375687C10.61 0.141373 10.9899 0.141373 11.2242 0.375687Z" />\n </svg>\n </span><span class="copyCode">复制代码</span></p><pre');
2240
- return text;
2241
- });
2242
- if (item.sender == mid) {
2243
- //只有引用和复制功能
2244
- li = /*#__PURE__*/ _jsxs(_Fragment, {
2245
- children: [
2246
- dataTime ? /*#__PURE__*/ _jsx("li", {
2247
- className: styles.time,
2248
- children: dataTime
2249
- }) : "",
2250
- /*#__PURE__*/ _jsxs("li", {
2251
- className: styles.left,
2252
- id: lastId == item.id ? "li_flag" : "",
2253
- children: [
2254
- /*#__PURE__*/ _jsx("div", {
2255
- className: styles.main,
2256
- children: /*#__PURE__*/ _jsxs("div", {
2257
- className: styles.main_content,
2258
- children: [
2259
- /*#__PURE__*/ _jsxs("div", {
2260
- className: styles.main_content_flag,
2261
- children: [
2262
- /*#__PURE__*/ _jsx("div", {
2263
- className: styles.operate_modal,
2264
- children: /*#__PURE__*/ _jsxs("p", {
2265
- className: styles.operate,
2266
- children: [
2267
- /*#__PURE__*/ _jsx("i", {
2268
- className: "yinyong_quote1",
2269
- onClick: function() {
2270
- setCitationContent({
2271
- content: item.message,
2272
- id: item.id,
2273
- imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ""
2245
+ }
2246
+ var dataTime = time;
2247
+ // let code = message.split("```");
2248
+ // code = code[1];
2249
+ // console.log(code,888888888);
2250
+ if (lastId == item.id && keyWordProblem != "") {
2251
+ //点击历史记录时,找到关键字,防止关键字和标签名重复
2252
+ // let key_sign = 'sign_'+new Date().getTime();+'sign';
2253
+ // message = message.replaceAll(keyWordProblem, (e:any) => {
2254
+ // return key_sign;
2255
+ // });
2256
+ // message = remarkable.render(message);
2257
+ // message = message.replaceAll(key_sign, (e:any) => {
2258
+ // return `<span class=${styles.sign}>${keyWordProblem}</span>`;
2259
+ // });
2260
+ message = remarkReplaceKey(message, keyWordProblem);
2261
+ } else {
2262
+ message = remarkable.render(message);
2263
+ }
2264
+ var position = 0;
2265
+ message = message.replaceAll(new RegExp("<pre", "ig"), function(i, index) {
2266
+ position++;
2267
+ var text = "<p class='".concat(styles.copyCode, " copyCodeFun' data-id=").concat(item.id, " data-position=").concat(position, ">\n <span class='").concat(styles.icon, ' copy\' >\n <svg\n width="1em"\n height="1em"\n viewBox="0 0 14 14"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n xmlns="http://www.w3.org/2000/svg"\n >\n <g clip-path="url(#clip0_518_8403)">\n <path\n 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"\n />\n </g>\n <defs>\n <clipPath id="clip0_518_8403">\n <rect width="16" height="16" />\n </clipPath>\n </defs>\n </svg>\n </span>\n <span class=\'').concat(styles.icon, ' copy_success_flag\'>\n <svg\n width="1em"\n height="1em"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n viewBox="0 0 12 7"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path d="M11.2242 0.375687C11.4586 0.610002 11.4586 0.989901 11.2242 1.22422L4.82424 7.62422C4.58992 7.85853 4.21003 7.85853 3.97571 7.62422L0.775712 4.42422C0.541397 4.1899 0.541397 3.81 0.775712 3.57569C1.01003 3.34137 1.38993 3.34137 1.62424 3.57569L4.39998 6.35142L10.3757 0.375687C10.61 0.141373 10.9899 0.141373 11.2242 0.375687Z" />\n </svg>\n </span><span class="copyCode">复制代码</span></p><pre');
2268
+ return text;
2269
+ });
2270
+ if (item.sender == mid) {
2271
+ //只有引用和复制功能
2272
+ li = /*#__PURE__*/ _jsxs(_Fragment, {
2273
+ children: [
2274
+ dataTime ? /*#__PURE__*/ _jsx("li", {
2275
+ className: "".concat(styles.itemcontent, " ").concat(styles.time),
2276
+ children: dataTime
2277
+ }) : "",
2278
+ /*#__PURE__*/ _jsxs("li", {
2279
+ className: "".concat(styles.itemcontent, " ").concat(styles.left),
2280
+ id: lastId == item.id ? "li_flag" : "",
2281
+ children: [
2282
+ /*#__PURE__*/ _jsx("div", {
2283
+ className: styles.main,
2284
+ children: /*#__PURE__*/ _jsxs("div", {
2285
+ className: styles.main_content,
2286
+ children: [
2287
+ /*#__PURE__*/ _jsxs("div", {
2288
+ className: styles.main_content_flag,
2289
+ children: [
2290
+ /*#__PURE__*/ _jsx("div", {
2291
+ className: styles.operate_modal,
2292
+ children: /*#__PURE__*/ _jsxs("p", {
2293
+ className: styles.operate,
2294
+ children: [
2295
+ /*#__PURE__*/ _jsx("i", {
2296
+ className: "yinyong_quote1",
2297
+ onClick: function() {
2298
+ setCitationContent({
2299
+ content: item.message,
2300
+ id: item.id,
2301
+ imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ""
2302
+ });
2303
+ resettingBottomHei();
2304
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
2305
+ },
2306
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
2307
+ }),
2308
+ copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
2309
+ return list == item.id;
2310
+ }) ? /*#__PURE__*/ _jsx("i", {
2311
+ className: "tongyong-xuanzhongdui",
2312
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
2313
+ }) : /*#__PURE__*/ _jsx("i", {
2314
+ className: "fuzhi21",
2315
+ onClick: function() {
2316
+ var bol = copyText(item.message);
2317
+ if (bol) {
2318
+ var obj = copyTextOBJ;
2319
+ obj = obj.filter(function(list) {
2320
+ return list != item.id;
2274
2321
  });
2275
- resettingBottomHei();
2276
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
2277
- },
2278
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
2322
+ obj.push(item.id);
2323
+ setCopyTextObj(obj);
2324
+ }
2325
+ setTimeout(function() {
2326
+ var obj = copyTextOBJ;
2327
+ obj = obj.filter(function(list) {
2328
+ return list != item.id;
2329
+ });
2330
+ setCopyTextObj(obj);
2331
+ }, 3000);
2332
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
2333
+ },
2334
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
2335
+ })
2336
+ ]
2337
+ })
2338
+ }),
2339
+ /*#__PURE__*/ _jsxs("div", {
2340
+ className: styles.content,
2341
+ children: [
2342
+ /*#__PURE__*/ _jsx("p", {
2343
+ dangerouslySetInnerHTML: {
2344
+ __html: message
2345
+ },
2346
+ className: styles.content_child
2347
+ }),
2348
+ !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2349
+ className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2350
+ children: [
2351
+ /*#__PURE__*/ _jsx("img", {
2352
+ src: JSON.parse(item.extraInfo)[0].value
2279
2353
  }),
2280
- copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
2281
- return list == item.id;
2282
- }) ? /*#__PURE__*/ _jsx("i", {
2283
- className: "tongyong-xuanzhongdui",
2284
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
2285
- }) : /*#__PURE__*/ _jsx("i", {
2286
- className: "fuzhi21",
2287
- onClick: function() {
2288
- var bol = copyText(item.message);
2289
- if (bol) {
2290
- var obj = copyTextOBJ;
2291
- obj = obj.filter(function(list) {
2292
- return list != item.id;
2293
- });
2294
- obj.push(item.id);
2295
- setCopyTextObj(obj);
2354
+ /*#__PURE__*/ _jsx("div", {
2355
+ className: styles.mask_zoom,
2356
+ children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2357
+ onClick: function() {
2358
+ setViewBase64(JSON.parse(item.extraInfo)[0].value);
2359
+ setVisible(true);
2296
2360
  }
2297
- setTimeout(function() {
2298
- var obj = copyTextOBJ;
2299
- obj = obj.filter(function(list) {
2300
- return list != item.id;
2301
- });
2302
- setCopyTextObj(obj);
2303
- }, 3000);
2304
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
2305
- },
2306
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
2361
+ })
2307
2362
  })
2308
2363
  ]
2309
2364
  })
2365
+ ]
2366
+ })
2367
+ ]
2368
+ }),
2369
+ //引用消息
2370
+ item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
2371
+ className: styles.citation_content,
2372
+ children: [
2373
+ getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2374
+ overlayClassName: styles.popover_main_content,
2375
+ title: item.quotedMessage,
2376
+ placement: "leftTop",
2377
+ children: /*#__PURE__*/ _jsxs("p", {
2378
+ className: styles.text_exceed,
2379
+ children: [
2380
+ item.quotedMessage,
2381
+ /*#__PURE__*/ _jsx(RightOutlined, {})
2382
+ ]
2383
+ })
2384
+ }) : /*#__PURE__*/ _jsx("p", {
2385
+ children: item.quotedMessage
2386
+ }),
2387
+ item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2388
+ className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2389
+ children: [
2390
+ /*#__PURE__*/ _jsx("img", {
2391
+ src: JSON.parse(item.extraInfo)[0].value
2392
+ }),
2393
+ /*#__PURE__*/ _jsx("div", {
2394
+ className: styles.mask_zoom,
2395
+ children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2396
+ onClick: function() {
2397
+ setViewBase64(JSON.parse(item.extraInfo)[0].value);
2398
+ setVisible(true);
2399
+ }
2400
+ })
2401
+ })
2402
+ ]
2403
+ })
2404
+ ]
2405
+ })
2406
+ ]
2407
+ })
2408
+ }),
2409
+ (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2410
+ className: styles.head_sculpture,
2411
+ style: {
2412
+ marginLeft: "12px"
2413
+ },
2414
+ children: /*#__PURE__*/ _jsx("img", {
2415
+ src: userData.avatar
2416
+ })
2417
+ })
2418
+ ]
2419
+ }, item.id)
2420
+ ]
2421
+ });
2422
+ } else {
2423
+ //获取用户头像
2424
+ var headImg = "";
2425
+ var chatWindow = [];
2426
+ var isAiChatWindow;
2427
+ chatWindow = contactsList.filter(function(item) {
2428
+ return item.roomId == roomId;
2429
+ });
2430
+ if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
2431
+ headImg = chatWindow[0].headImg;
2432
+ }
2433
+ // console.log(chatWindow,'chatWindowchatWindow')
2434
+ //是否在智能客服窗口
2435
+ isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
2436
+ var header = 2; //代表是ai头像
2437
+ if (isAiChatWindow && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
2438
+ //使用AI头像
2439
+ header = 1;
2440
+ }
2441
+ li = /*#__PURE__*/ _jsxs(_Fragment, {
2442
+ children: [
2443
+ dataTime ? /*#__PURE__*/ _jsx("li", {
2444
+ className: "".concat(styles.itemcontent, " ").concat(styles.time),
2445
+ children: dataTime
2446
+ }) : "",
2447
+ /*#__PURE__*/ _jsxs("li", {
2448
+ className: "".concat(styles.itemcontent, " ").concat(styles.right),
2449
+ id: lastId == item.id ? "li_flag" : item.id,
2450
+ children: [
2451
+ (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2452
+ className: styles.head_sculpture,
2453
+ style: {
2454
+ marginRight: "12px"
2455
+ },
2456
+ children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
2457
+ src: knowledge_icon
2458
+ }) : /*#__PURE__*/ _jsx("img", {
2459
+ src: headImg
2460
+ })
2461
+ }),
2462
+ /*#__PURE__*/ _jsx("div", {
2463
+ className: styles.main,
2464
+ children: /*#__PURE__*/ _jsx("div", {
2465
+ className: styles.main_content,
2466
+ children: /*#__PURE__*/ _jsxs("div", {
2467
+ className: styles.main_content_flag,
2468
+ onMouseEnter: function() {
2469
+ // onMouseEnter方法内:判断回答内容的气泡是否在可视区域内,动态判断点赞按钮显示的上下位置
2470
+ var isSmall = showType == 1 || showType == 3;
2471
+ var container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
2472
+ console.log("onMouseEnter1", container);
2473
+ if (container) {
2474
+ var dom = container.querySelector('[id="'.concat(item.id, '"]'));
2475
+ console.log("onMouseEnter2", dom);
2476
+ if (dom) {
2477
+ // const con_h=document.getElementById('chat_content').clientHeight-24;//滚动区域的高度
2478
+ var con_h = container.clientHeight - (isSmall ? 24 : 0); //滚动区域的高度;
2479
+ var rectY = dom.getBoundingClientRect().y - 48;
2480
+ var h = dom.clientHeight + (isSmall ? 24 : 0); //当前元素高度
2481
+ var topDom = dom.getElementsByClassName(styles.operate_modal_showtop)[0];
2482
+ var bottomDom = dom.getElementsByClassName(styles.operate_modal_showbottom)[0];
2483
+ console.log("onMouseEnter3", topDom, bottomDom);
2484
+ console.log("onMouseEnter4", {
2485
+ h: h,
2486
+ con_h: con_h,
2487
+ rectY: rectY,
2488
+ topDom: topDom,
2489
+ bottomDom: bottomDom
2490
+ });
2491
+ if (topDom && bottomDom) {
2492
+ if (rectY > 0) {
2493
+ //显示上边
2494
+ topDom.style.cssText = "visibility: visible";
2495
+ bottomDom.style.cssText = "visibility: hidden;";
2496
+ // 上下都能显示时,显示到下边
2497
+ if (h < con_h - rectY) {
2498
+ console.log("上下都能显示时,显示到下边");
2499
+ topDom.style.cssText = "visibility: hidden;";
2500
+ bottomDom.style.cssText = "visibility: visible";
2501
+ }
2502
+ } else {
2503
+ // 上下都不显示,下边的放到页的最上边
2504
+ if (h > con_h && h - con_h > Math.abs(rectY)) {
2505
+ console.log("上下都不显示");
2506
+ topDom.style.cssText = "visibility: hidden;";
2507
+ bottomDom.style.cssText = "top:".concat(-(h + rectY - 51 - (isSmall ? 0 : 58)), "px;visibility: visible;");
2508
+ } else {
2509
+ console.log("12312312");
2510
+ //显示下边
2511
+ topDom.style.cssText = "visibility: hidden;";
2512
+ bottomDom.style.cssText = "visibility: visible";
2513
+ }
2514
+ }
2515
+ }
2516
+ }
2517
+ }
2518
+ },
2519
+ onMouseLeave: function() {
2520
+ var isSmall = showType == 1 || showType == 3;
2521
+ var container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
2522
+ if (container) {
2523
+ var dom = container.querySelector('[id="'.concat(item.id, '"]'));
2524
+ if (dom) {
2525
+ var topDom = dom.getElementsByClassName(styles.operate_modal_showtop)[0];
2526
+ var bottomDom = dom.getElementsByClassName(styles.operate_modal_showbottom)[0];
2527
+ if (topDom) {
2528
+ topDom.style.cssText = "visibility: hidden;";
2529
+ }
2530
+ if (bottomDom) {
2531
+ bottomDom.style.cssText = "visibility: hidden;";
2532
+ }
2533
+ }
2534
+ }
2535
+ },
2536
+ children: [
2537
+ /*#__PURE__*/ _jsx("div", {
2538
+ className: "".concat(styles.operate_modal, " ").concat(styles.operate_modal_showtop),
2539
+ children: // 不是最后一行,
2540
+ historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
2541
+ }),
2542
+ /*#__PURE__*/ _jsxs("div", {
2543
+ className: styles.content,
2544
+ children: [
2545
+ item.message != "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsx("p", {
2546
+ dangerouslySetInnerHTML: {
2547
+ __html: message
2548
+ },
2549
+ className: styles.content_child
2310
2550
  }),
2311
- /*#__PURE__*/ _jsxs("div", {
2312
- className: styles.content,
2551
+ item.message == "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsxs("p", {
2313
2552
  children: [
2314
- /*#__PURE__*/ _jsx("p", {
2315
- dangerouslySetInnerHTML: {
2316
- __html: message
2553
+ "AI助手繁忙,请稍后再提问或",
2554
+ /*#__PURE__*/ _jsx("span", {
2555
+ className: styles.find_teacher_con,
2556
+ onClick: function() {
2557
+ var extraInfo = historyMessageList[i - 1].extraInfo;
2558
+ var url = "";
2559
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2560
+ url = JSON.parse(extraInfo)[0].value;
2561
+ }
2562
+ setProblem({
2563
+ question: historyMessageList[i - 1].message,
2564
+ url: url
2565
+ });
2566
+ setShowTeacherList(true);
2317
2567
  },
2318
- className: styles.content_child
2568
+ children: "召唤老师回答"
2569
+ })
2570
+ ]
2571
+ }),
2572
+ !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2573
+ className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2574
+ children: [
2575
+ /*#__PURE__*/ _jsx("img", {
2576
+ src: JSON.parse(item.extraInfo)[0].value
2319
2577
  }),
2320
- !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2321
- className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2322
- children: [
2323
- /*#__PURE__*/ _jsx("img", {
2324
- src: JSON.parse(item.extraInfo)[0].value
2325
- }),
2326
- /*#__PURE__*/ _jsx("div", {
2327
- className: styles.mask_zoom,
2328
- children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2329
- onClick: function() {
2330
- setViewBase64(JSON.parse(item.extraInfo)[0].value);
2331
- setVisible(true);
2332
- }
2333
- })
2578
+ /*#__PURE__*/ _jsx("div", {
2579
+ className: styles.mask_zoom,
2580
+ children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2581
+ onClick: function() {
2582
+ setViewBase64(JSON.parse(item.extraInfo)[0].value);
2583
+ setVisible(true);
2584
+ }
2585
+ })
2586
+ })
2587
+ ]
2588
+ }),
2589
+ item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsxs("ul", {
2590
+ className: "".concat(styles.association_problem, " ").concat(item.message == "抱歉,我暂时无法回答这样的问题。" ? styles.association_problem_flag : ""),
2591
+ children: [
2592
+ item.message == "抱歉,我暂时无法回答这样的问题。" && /*#__PURE__*/ _jsx("li", {
2593
+ className: styles.related_issues_flag,
2594
+ children: /*#__PURE__*/ _jsx("span", {
2595
+ children: "相关问题"
2596
+ })
2597
+ }),
2598
+ JSON.parse(item.extraInfo).map(function(list, index) {
2599
+ return /*#__PURE__*/ _jsx("li", {
2600
+ onClick: function() {
2601
+ sendMessage(list, 1);
2602
+ setBottomRecommendationQuestions([]);
2603
+ resettingBottomHei();
2604
+ },
2605
+ children: item.message == "抱歉,我暂时无法回答这样的问题。" ? list.question : /*#__PURE__*/ _jsxs(_Fragment, {
2606
+ children: [
2607
+ JSON.parse(item.extraInfo).length > 1 ? index + 1 + "." : "",
2608
+ list.question
2609
+ ]
2334
2610
  })
2335
- ]
2611
+ }, i + "_" + index + "_" + list.value);
2336
2612
  })
2337
2613
  ]
2338
- })
2614
+ }),
2615
+ //findTeacher//是否在召唤老师过程中,是否是最后一条消息
2616
+ !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != "123456_date" && renderLastOperateBtn(item, isAiChatWindow, i)
2339
2617
  ]
2340
2618
  }),
2341
2619
  //引用消息
@@ -2345,7 +2623,7 @@ var CustomerService = function(props) {
2345
2623
  getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2346
2624
  overlayClassName: styles.popover_main_content,
2347
2625
  title: item.quotedMessage,
2348
- placement: "leftTop",
2626
+ placement: "rightTop",
2349
2627
  children: /*#__PURE__*/ _jsxs("p", {
2350
2628
  className: styles.text_exceed,
2351
2629
  children: [
@@ -2374,250 +2652,106 @@ var CustomerService = function(props) {
2374
2652
  ]
2375
2653
  })
2376
2654
  ]
2655
+ }),
2656
+ historyMessageList.length - 1 !== i && /*#__PURE__*/ _jsx("div", {
2657
+ className: "".concat(styles.operate_modal, " ").concat(styles.bottom, " ").concat(styles.operate_modal_showbottom),
2658
+ children: // 不是最后一行,
2659
+ renderOperateBtn(item, isAiChatWindow, i)
2377
2660
  })
2378
2661
  ]
2379
2662
  })
2380
- }),
2381
- (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2382
- className: styles.head_sculpture,
2383
- style: {
2384
- marginLeft: "12px"
2385
- },
2386
- children: /*#__PURE__*/ _jsx("img", {
2387
- src: userData.avatar
2388
- })
2389
2663
  })
2390
- ]
2391
- }, item.id)
2392
- ]
2393
- });
2394
- } else {
2395
- //获取用户头像
2396
- var headImg = "";
2397
- var chatWindow = [];
2398
- var isAiChatWindow;
2399
- chatWindow = contactsList.filter(function(item) {
2400
- return item.roomId == roomId;
2401
- });
2402
- if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
2403
- headImg = chatWindow[0].headImg;
2664
+ })
2665
+ ]
2666
+ }, item.id)
2667
+ ]
2668
+ });
2669
+ }
2670
+ return /*#__PURE__*/ _jsx(React.Fragment, {
2671
+ children: li
2672
+ }, item.id);
2673
+ };
2674
+ return /*#__PURE__*/ _jsx("ul", {
2675
+ className: styles.message_con,
2676
+ style: {
2677
+ height: historyMessageListVirtuosoHeight
2678
+ },
2679
+ children: /*#__PURE__*/ _jsx(Virtuoso, {
2680
+ ref: historyMessageListVirtuosoRef,
2681
+ data: historyMessageList,
2682
+ itemContent: itemContent,
2683
+ totalCount: historyMessageList.length,
2684
+ style: {
2685
+ height: "100%"
2686
+ },
2687
+ // initialTopMostItemIndex={isPositionState? { index: "LAST", align: "end" }:undefined}
2688
+ startReached: function() {
2689
+ if (pageCount > pageNum && pageCount > 0) {
2690
+ var number = pageNum + 1;
2691
+ setPageNum(function(pageNum) {
2692
+ return pageNum + 1;
2693
+ });
2694
+ setLoading(true);
2695
+ listTimer.current = setTimeout(function() {
2696
+ getHistoryMessage(number, 2);
2697
+ }, 1000);
2404
2698
  }
2405
- // console.log(chatWindow,'chatWindowchatWindow')
2406
- //是否在智能客服窗口
2407
- isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
2408
- var header = 2; //代表是ai头像
2409
- if (isAiChatWindow && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
2410
- //使用AI头像
2411
- header = 1;
2699
+ },
2700
+ endReached: function() {
2701
+ if (pageNumHistory > 1) {
2702
+ var number = pageNumHistory - 1;
2703
+ setPageNumHistory(number);
2704
+ clearTimeout(listTimer.current);
2705
+ listTimer.current = setTimeout(function() {
2706
+ if (number > 0) {
2707
+ setBottomLoading(true);
2708
+ getHistoryMessage(number, 4);
2709
+ setLastId("");
2710
+ } else {
2711
+ setPageNumHistory(0);
2712
+ }
2713
+ }, 1000);
2714
+ }
2715
+ },
2716
+ context: {
2717
+ loading: loading
2718
+ },
2719
+ firstItemIndex: firstItemIndex,
2720
+ increaseViewportBy: 200,
2721
+ overscan: 10,
2722
+ logLevel: 0,
2723
+ onScroll: function(e) {
2724
+ //生成答案过程中
2725
+ if (!finishedRef.current) {
2726
+ var _container, _container1, _container2;
2727
+ var container = e.target;
2728
+ var _container_scrollTop;
2729
+ var scrollTop = (_container_scrollTop = (_container = container) === null || _container === void 0 ? void 0 : _container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0;
2730
+ var _container_clientHeight;
2731
+ var clientHeight = (_container_clientHeight = (_container1 = container) === null || _container1 === void 0 ? void 0 : _container1.clientHeight) !== null && _container_clientHeight !== void 0 ? _container_clientHeight : 0;
2732
+ var _container_scrollHeight;
2733
+ var scrollHeight = (_container_scrollHeight = (_container2 = container) === null || _container2 === void 0 ? void 0 : _container2.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0;
2734
+ var distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
2735
+ if (distanceFromBottom > 10) {
2736
+ // 距离底部超过10像素才认为是主动向上滚动
2737
+ isPosition.current = false;
2738
+ setIsPositionState(false);
2739
+ } else if (distanceFromBottom < 10) {
2740
+ // 距离底部很近时恢复自动滚动
2741
+ isPosition.current = true;
2742
+ setIsPositionState(true);
2743
+ }
2744
+ console.log("Scroll-onScroll", {
2745
+ container: container,
2746
+ scrollTop: scrollTop,
2747
+ clientHeight: clientHeight,
2748
+ scrollHeight: scrollHeight,
2749
+ isPosition: isPosition.current
2750
+ });
2412
2751
  }
2413
- li = /*#__PURE__*/ _jsxs(_Fragment, {
2414
- children: [
2415
- dataTime ? /*#__PURE__*/ _jsx("li", {
2416
- className: styles.time,
2417
- children: dataTime
2418
- }) : "",
2419
- /*#__PURE__*/ _jsxs("li", {
2420
- className: styles.right,
2421
- id: lastId == item.id ? "li_flag" : item.id,
2422
- children: [
2423
- (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2424
- className: styles.head_sculpture,
2425
- style: {
2426
- marginRight: "12px"
2427
- },
2428
- children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
2429
- src: knowledge_icon
2430
- }) : /*#__PURE__*/ _jsx("img", {
2431
- src: headImg
2432
- })
2433
- }),
2434
- /*#__PURE__*/ _jsx("div", {
2435
- className: styles.main,
2436
- children: /*#__PURE__*/ _jsx("div", {
2437
- className: styles.main_content,
2438
- children: /*#__PURE__*/ _jsxs("div", {
2439
- className: styles.main_content_flag,
2440
- onMouseEnter: function() {
2441
- var isSmall = showType == 1 || showType == 3;
2442
- var container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
2443
- if (container) {
2444
- var dom = container.querySelector('[id="'.concat(item.id, '"]'));
2445
- if (dom) {
2446
- // const con_h=document.getElementById('chat_content').clientHeight-24;//滚动区域的高度
2447
- var con_h = container.clientHeight - (isSmall ? 24 : 0); //滚动区域的高度;
2448
- var rectY = dom.getBoundingClientRect().y - 48;
2449
- var h = dom.clientHeight + (isSmall ? 24 : 0); //当前元素高度
2450
- var topDom = dom.getElementsByClassName("operate_modal_showtop")[0];
2451
- var bottomDom = dom.getElementsByClassName("operate_modal_showbottom")[0];
2452
- // console.log({h,con_h,rectY,topDom,bottomDom})
2453
- if (topDom && bottomDom) {
2454
- if (rectY > 0) {
2455
- topDom.style.cssText = "";
2456
- bottomDom.style.cssText = "visibility: hidden;";
2457
- // 上下都能显示时,显示到下边
2458
- if (h < con_h - rectY) {
2459
- console.log("上下都能显示时,显示到下边");
2460
- topDom.style.cssText = "visibility: hidden;";
2461
- bottomDom.style.cssText = "";
2462
- }
2463
- } else {
2464
- // 上下都不显示
2465
- if (h > con_h && h - con_h > Math.abs(rectY)) {
2466
- console.log("上下都不显示");
2467
- topDom.style.cssText = "visibility: hidden;";
2468
- bottomDom.style.cssText = "top:".concat(-(h + rectY - 51 - (isSmall ? 0 : 58)), "px;");
2469
- } else {
2470
- console.log("12312312");
2471
- topDom.style.cssText = "visibility: hidden;";
2472
- bottomDom.style.cssText = "";
2473
- }
2474
- }
2475
- }
2476
- }
2477
- }
2478
- },
2479
- children: [
2480
- /*#__PURE__*/ _jsx("div", {
2481
- className: "".concat(styles.operate_modal, " operate_modal_showtop"),
2482
- children: // 不是最后一行,
2483
- historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
2484
- }),
2485
- /*#__PURE__*/ _jsxs("div", {
2486
- className: styles.content,
2487
- children: [
2488
- item.message != "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsx("p", {
2489
- dangerouslySetInnerHTML: {
2490
- __html: message
2491
- },
2492
- className: styles.content_child
2493
- }),
2494
- item.message == "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsxs("p", {
2495
- children: [
2496
- "AI助手繁忙,请稍后再提问或",
2497
- /*#__PURE__*/ _jsx("span", {
2498
- className: styles.find_teacher_con,
2499
- onClick: function() {
2500
- var extraInfo = historyMessageList[i - 1].extraInfo;
2501
- var url = "";
2502
- if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2503
- url = JSON.parse(extraInfo)[0].value;
2504
- }
2505
- setProblem({
2506
- question: historyMessageList[i - 1].message,
2507
- url: url
2508
- });
2509
- setShowTeacherList(true);
2510
- },
2511
- children: "召唤老师回答"
2512
- })
2513
- ]
2514
- }),
2515
- !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2516
- className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2517
- children: [
2518
- /*#__PURE__*/ _jsx("img", {
2519
- src: JSON.parse(item.extraInfo)[0].value
2520
- }),
2521
- /*#__PURE__*/ _jsx("div", {
2522
- className: styles.mask_zoom,
2523
- children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2524
- onClick: function() {
2525
- setViewBase64(JSON.parse(item.extraInfo)[0].value);
2526
- setVisible(true);
2527
- }
2528
- })
2529
- })
2530
- ]
2531
- }),
2532
- item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsxs("ul", {
2533
- className: "".concat(styles.association_problem, " ").concat(item.message == "抱歉,我暂时无法回答这样的问题。" ? styles.association_problem_flag : ""),
2534
- children: [
2535
- item.message == "抱歉,我暂时无法回答这样的问题。" && /*#__PURE__*/ _jsx("li", {
2536
- className: styles.related_issues_flag,
2537
- children: /*#__PURE__*/ _jsx("span", {
2538
- children: "相关问题"
2539
- })
2540
- }),
2541
- JSON.parse(item.extraInfo).map(function(list, index) {
2542
- return /*#__PURE__*/ _jsx("li", {
2543
- onClick: function() {
2544
- sendMessage(list, 1);
2545
- setBottomRecommendationQuestions([]);
2546
- resettingBottomHei();
2547
- },
2548
- children: item.message == "抱歉,我暂时无法回答这样的问题。" ? list.question : /*#__PURE__*/ _jsxs(_Fragment, {
2549
- children: [
2550
- JSON.parse(item.extraInfo).length > 1 ? index + 1 + "." : "",
2551
- list.question
2552
- ]
2553
- })
2554
- }, i + "_" + index + "_" + list.value);
2555
- })
2556
- ]
2557
- }),
2558
- //findTeacher//是否在召唤老师过程中,是否是最后一条消息
2559
- !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != "123456_date" && renderLastOperateBtn(item, isAiChatWindow, i)
2560
- ]
2561
- }),
2562
- //引用消息
2563
- item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
2564
- className: styles.citation_content,
2565
- children: [
2566
- getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2567
- overlayClassName: styles.popover_main_content,
2568
- title: item.quotedMessage,
2569
- placement: "rightTop",
2570
- children: /*#__PURE__*/ _jsxs("p", {
2571
- className: styles.text_exceed,
2572
- children: [
2573
- item.quotedMessage,
2574
- /*#__PURE__*/ _jsx(RightOutlined, {})
2575
- ]
2576
- })
2577
- }) : /*#__PURE__*/ _jsx("p", {
2578
- children: item.quotedMessage
2579
- }),
2580
- item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2581
- className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2582
- children: [
2583
- /*#__PURE__*/ _jsx("img", {
2584
- src: JSON.parse(item.extraInfo)[0].value
2585
- }),
2586
- /*#__PURE__*/ _jsx("div", {
2587
- className: styles.mask_zoom,
2588
- children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2589
- onClick: function() {
2590
- setViewBase64(JSON.parse(item.extraInfo)[0].value);
2591
- setVisible(true);
2592
- }
2593
- })
2594
- })
2595
- ]
2596
- })
2597
- ]
2598
- }),
2599
- historyMessageList.length - 1 !== i && /*#__PURE__*/ _jsx("div", {
2600
- className: "".concat(styles.operate_modal, " ").concat(styles.bottom, " operate_modal_showbottom"),
2601
- children: // 不是最后一行,
2602
- renderOperateBtn(item, isAiChatWindow, i)
2603
- })
2604
- ]
2605
- })
2606
- })
2607
- })
2608
- ]
2609
- }, item.id)
2610
- ]
2611
- });
2612
2752
  }
2613
- return /*#__PURE__*/ _jsx(React.Fragment, {
2614
- children: li
2615
- }, item.id);
2616
2753
  })
2617
2754
  });
2618
- // } else {
2619
- // return "";
2620
- // }
2621
2755
  };
2622
2756
  //渲染相关操作按钮 header == 1 ai ,== 2 知识库
2623
2757
  var renderOperateBtn = function(item, isAiChatWindow, i) {
@@ -2636,7 +2770,7 @@ var CustomerService = function(props) {
2636
2770
  }) && /*#__PURE__*/ _jsx("span", {
2637
2771
  className: styles.ask_question,
2638
2772
  onClick: function() {
2639
- console.log(historyMessageList[i - 1], 4444444);
2773
+ // console.log(historyMessageList[i - 1], 4444444);
2640
2774
  var extraInfo = historyMessageList[i - 1].extraInfo;
2641
2775
  var url = "";
2642
2776
  if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
@@ -2755,12 +2889,12 @@ var CustomerService = function(props) {
2755
2889
  }
2756
2890
  //1、是否显示停止生成按钮 finished 是否生产完成
2757
2891
  var showStopBtn = false;
2758
- if (!finishedRef.current && item.sender == "AI" && item.extraInfo == null) {
2892
+ if (!finished && item.sender == "AI" && item.extraInfo == null) {
2759
2893
  showStopBtn = true;
2760
2894
  }
2761
2895
  //2、是否展示重新生成按钮
2762
2896
  var regenerationBtn = false;
2763
- if (finishedRef.current && item.sender == "AI" && item.extraInfo == null) {
2897
+ if (finished && item.sender == "AI" && item.extraInfo == null) {
2764
2898
  regenerationBtn = true;
2765
2899
  }
2766
2900
  //3、是否显示召唤老师回答按钮
@@ -2785,16 +2919,14 @@ var CustomerService = function(props) {
2785
2919
  }
2786
2920
  } catch (error) {}
2787
2921
  clearTimeout(receiveMessageTimer.current);
2922
+ clearTimeout(renderAiAnswerTimer.current);
2788
2923
  setHistoryMessageList(function(historyMessageList) {
2789
2924
  return historyMessageList.filter(function(item) {
2790
2925
  return item.id != "123456";
2791
2926
  });
2792
2927
  });
2793
- // setFinished(true);
2794
- setFinished(function(prevData) {
2795
- finishedRef.current = true;
2796
- return finishedRef.current;
2797
- });
2928
+ finishedRef.current = true;
2929
+ setFinished(true);
2798
2930
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
2799
2931
  }
2800
2932
  }),
@@ -2807,16 +2939,14 @@ var CustomerService = function(props) {
2807
2939
  }
2808
2940
  } catch (error) {}
2809
2941
  clearTimeout(receiveMessageTimer.current);
2942
+ clearTimeout(renderAiAnswerTimer.current);
2810
2943
  setHistoryMessageList(function(historyMessageList) {
2811
2944
  return historyMessageList.filter(function(item) {
2812
2945
  return item.id != "123456";
2813
2946
  });
2814
2947
  });
2815
- // setFinished(true);
2816
- setFinished(function(prevData) {
2817
- finishedRef.current = true;
2818
- return finishedRef.current;
2819
- });
2948
+ finishedRef.current = true;
2949
+ setFinished(true);
2820
2950
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
2821
2951
  },
2822
2952
  children: "停止生成"
@@ -2849,6 +2979,7 @@ var CustomerService = function(props) {
2849
2979
  children: [
2850
2980
  regenerationBtn && /*#__PURE__*/ _jsx("i", {
2851
2981
  onClick: function() {
2982
+ finishedRef.current = false;
2852
2983
  setFinished(false);
2853
2984
  aiSendQuestions(2, {
2854
2985
  roomId: roomId,
@@ -2913,7 +3044,7 @@ var CustomerService = function(props) {
2913
3044
  if (!isAiChatWindow) return;
2914
3045
  //只有最后一条回答,支持发送点赞或踩
2915
3046
  if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
2916
- console.log("判断是AI还是智能问答", item);
3047
+ // console.log("判断是AI还是智能问答", item);
2917
3048
  if (!item.extraInfo && item.sender == "AI") {
2918
3049
  aiSendQuestions(1, {
2919
3050
  roomId: roomId,
@@ -2923,7 +3054,7 @@ var CustomerService = function(props) {
2923
3054
  generateUpvoteOrDownvoteMessage: true
2924
3055
  }, 1);
2925
3056
  } else {
2926
- console.log("AI回答2255555");
3057
+ // console.log("AI回答2255555");
2927
3058
  sendGreetingMessage(2);
2928
3059
  }
2929
3060
  }
@@ -2937,10 +3068,10 @@ var CustomerService = function(props) {
2937
3068
  //老师的聊天窗口中不需要点赞和踩消息
2938
3069
  if (!isAiChatWindow) return;
2939
3070
  //只有最后一条回答,支持发送点赞或踩
2940
- console.log(item, "dlfkvmdflkv");
3071
+ // console.log(item, "dlfkvmdflkv");
2941
3072
  if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
2942
3073
  if (!item.extraInfo && item.sender == "AI") {
2943
- console.log("AI回答2222");
3074
+ // console.log("AI回答2222");
2944
3075
  //AI回答
2945
3076
  aiSendQuestions(1, {
2946
3077
  roomId: roomId,
@@ -3122,7 +3253,8 @@ var CustomerService = function(props) {
3122
3253
  },
3123
3254
  children: [
3124
3255
  /*#__PURE__*/ _jsx(CustomWenhaoRound, {}),
3125
- "总结图片内容 "
3256
+ "总结图片内容",
3257
+ " "
3126
3258
  ]
3127
3259
  })
3128
3260
  ]
@@ -3172,6 +3304,7 @@ var CustomerService = function(props) {
3172
3304
  if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
3173
3305
  sendToTeacher(2);
3174
3306
  } else {
3307
+ finishedRef.current = false;
3175
3308
  setFinished(false);
3176
3309
  setQuestionsList([]);
3177
3310
  sendMessage("", 0);