bhd-components 0.5.7 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{535fc6c5.esm.es5.development.js → 4a44b71b.esm.es5.development.js} +98068 -25721
  2. package/dist/e7b4aef5.esm.es5.production.js +468 -0
  3. package/dist/index.esm.es5.development.css +8467 -0
  4. package/dist/index.esm.es5.development.js +5881 -0
  5. package/dist/index.esm.es5.production.css +1 -0
  6. package/dist/index.esm.es5.production.js +1 -0
  7. package/es2017/customerService/contactsList/index.d.ts +3 -2
  8. package/es2017/customerService/contactsList/index.js +93 -90
  9. package/es2017/customerService/contactsList/index.module.less +32 -13
  10. package/es2017/customerService/function.js +18 -13
  11. package/es2017/customerService/historyFun/index.d.ts +2 -1
  12. package/es2017/customerService/historyFun/index.js +121 -86
  13. package/es2017/customerService/historyFun/index.module.less +40 -6
  14. package/es2017/customerService/index.js +748 -567
  15. package/es2017/customerService/index.module.less +747 -684
  16. package/es2017/icons/components/custom-duihao.js +1 -1
  17. package/es2017/utils/Date.d.ts +9 -0
  18. package/es2017/utils/Date.js +18 -0
  19. package/esm/customerService/contactsList/index.d.ts +3 -2
  20. package/esm/customerService/contactsList/index.js +104 -97
  21. package/esm/customerService/contactsList/index.module.less +32 -13
  22. package/esm/customerService/function.js +18 -13
  23. package/esm/customerService/historyFun/index.d.ts +2 -1
  24. package/esm/customerService/historyFun/index.js +127 -94
  25. package/esm/customerService/historyFun/index.module.less +40 -6
  26. package/esm/customerService/index.js +813 -609
  27. package/esm/customerService/index.module.less +747 -684
  28. package/esm/icons/components/custom-duihao.js +1 -1
  29. package/esm/utils/Date.d.ts +9 -0
  30. package/esm/utils/Date.js +18 -0
  31. package/package.json +4 -3
  32. package/dist/1bddec89.esm.es5.production.js +0 -72
  33. package/dist/CustomerService.esm.es5.development.css +0 -2827
  34. package/dist/CustomerService.esm.es5.development.js +0 -3823
  35. package/dist/CustomerService.esm.es5.production.css +0 -1
  36. package/dist/CustomerService.esm.es5.production.js +0 -1
@@ -2,14 +2,14 @@
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
3
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
4
4
  import React, { useEffect, useState, useRef } from "react";
5
- import styles from "./index.module.less";
6
5
  import { Modal, Drawer, Input, Tooltip } from "antd";
6
+ import styles from "./index.module.less";
7
+ // const inOnline = process.env.NODE_TYPE === "online";
7
8
  import { CustomAiIcon, CustomRecord, CustomFullScreen, CustomExitFullScreen, CustomReloading, CustomCopy, CustomLike, CustomDislike, CustomQuote, CustomSending, CustomContacts, CustomDuihao, CustomSoundRecording, CustomRoundClose } from "../icons/index";
8
9
  import { CloseOutlined } from "@ant-design/icons";
9
10
  import HistoryFun from "./historyFun/index";
10
11
  import ContactsList from "./contactsList/index";
11
- // import { fetchEventSource } from "@microsoft/fetch-event-source";
12
- import dayjs from "dayjs";
12
+ import { parseDate } from "../utils/Date";
13
13
  import { Remarkable } from "remarkable";
14
14
  import hljs from "highlight.js";
15
15
  import "highlight.js/styles/default.css";
@@ -21,7 +21,6 @@ import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
21
21
  import { readMessage, getByteLen, serverUrl, copyText, getDataTime } from "./function"; //一些方法
22
22
  const CustomerService = (props)=>{
23
23
  let { userData , http , urllocation , onCancel , serverName , fetchEventSource , initShowType , onEvent , stepIds , stepId } = props;
24
- // urllocation = "/zhong";
25
24
  const [mid, setmid] = useState(props.userData.mid); //当前用户id
26
25
  const { bese64String , startRecord , stopRecord } = useMediaRecorder(); //语音转文字
27
26
  const [voiceRecordingStatus, setVoiceRecordingStatus] = useState(3); //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
@@ -34,8 +33,10 @@ const CustomerService = (props)=>{
34
33
  const [hotQuestionsList, setHotQuestionsList] = useState([]); //热门问题
35
34
  const [greetingMessage, setGreetingMessage] = useState(false); //聊天记录列表是否请求完成
36
35
  const [pageNum, setPageNum] = useState(1); //页码
36
+ const [pageNumHistory, setPageNumHistory] = useState(0); //用于搜索历史记录后的页码
37
37
  const [pageCount, setPageCount] = useState(0); //总页数
38
- const [loading, setLoading] = useState(false); //是否显示加载图标
38
+ const [loading, setLoading] = useState(false); //上拉显示加载图标
39
+ const [bottomLoading, setBottomLoading] = useState(false); //下拉显示加载图标
39
40
  const [finished, setFinished] = useState(true); //是否结束生成
40
41
  const [lastId, setLastId] = useState(""); //最后一条数据的id,可用于定位当前位置
41
42
  const [chatWith, setChatWith] = useState({}); //聊天的老师id或ai
@@ -53,7 +54,9 @@ const CustomerService = (props)=>{
53
54
  let receiveMessageTimer = useRef(null); //接收ai发回的消息
54
55
  let voiceCountdownTimer = useRef(null); //语音录制倒计时
55
56
  let listTimer = useRef(null); // 请求列表倒计时
57
+ let roomMessage = useRef(null); //循环当前页面的新消息
56
58
  const ctrl = useRef(); //停止生成ai回答时使用
59
+ let childRef = useRef(null); //获取子组件方法
57
60
  const remarkable = new Remarkable({
58
61
  highlight: function(str, lang) {
59
62
  if (lang && hljs.getLanguage(lang)) {
@@ -73,11 +76,11 @@ const CustomerService = (props)=>{
73
76
  clearTimeout(voiceCountdownTimer.current);
74
77
  clearTimeout(listTimer.current);
75
78
  clearTimeout(timer.current);
79
+ clearTimeout(roomMessage.current);
76
80
  };
77
81
  }, []);
78
82
  useEffect(()=>{
79
- // console.log("重新加载",pageCount);
80
- if (showType == 2 && !firstLoad && pageCount > 0) {
83
+ if (showType != 1 && !firstLoad && pageCount > 0) {
81
84
  setFirstLoad(true);
82
85
  setTimeout(()=>{
83
86
  scrollToBottom();
@@ -92,15 +95,18 @@ const CustomerService = (props)=>{
92
95
  //元素内部页面滚动到达底部
93
96
  if (e.target.clientHeight + e.target.scrollTop >= e.target.scrollHeight) {
94
97
  //console.log('元素内部页面滚动到达底部');
95
- if (pageNum > 1) {
96
- let number = pageNum - 1;
97
- setPageNum((pageNum)=>{
98
- return pageNum - 1;
99
- });
98
+ if (pageNumHistory > 1) {
99
+ console.log(pageNumHistory, 'pageNumpageNumpageNum');
100
+ let number = pageNumHistory - 1;
101
+ // setPageNum((pageNum) => {
102
+ // return pageNum - 1;
103
+ // });
104
+ setPageNumHistory(number);
100
105
  clearTimeout(listTimer.current);
106
+ setBottomLoading(true);
101
107
  listTimer.current = setTimeout(()=>{
102
108
  console.log("加载下一页", number);
103
- getHistoryMessage(number, 2);
109
+ getHistoryMessage(number, 4);
104
110
  }, 1000);
105
111
  }
106
112
  }
@@ -113,8 +119,8 @@ const CustomerService = (props)=>{
113
119
  });
114
120
  clearTimeout(listTimer.current);
115
121
  listTimer.current = setTimeout(()=>{
116
- console.log("加载下一页", number);
117
- getHistoryMessage(number, 0);
122
+ console.log("下拉加载下一页", number);
123
+ getHistoryMessage(number, 2);
118
124
  }, 1000);
119
125
  }
120
126
  }
@@ -140,9 +146,9 @@ const CustomerService = (props)=>{
140
146
  if (showType == 1) {
141
147
  dom.style.maxHeight = `${window.innerHeight - 60 - buttomHei}px`;
142
148
  } else if (showType == 3) {
143
- dom.style.maxHeight = `${window.innerHeight - 50 - buttomHei}px`;
149
+ dom.style.maxHeight = `${window.innerHeight - 114 - buttomHei}px`;
144
150
  } else {
145
- dom.style.maxHeight = `${window.innerHeight - 160 - 60 - buttomHei}px`;
151
+ dom.style.maxHeight = `${window.innerHeight - 160 - 62 - buttomHei}px`;
146
152
  }
147
153
  }
148
154
  }, [
@@ -150,12 +156,10 @@ const CustomerService = (props)=>{
150
156
  showType
151
157
  ]);
152
158
  useEffect(()=>{
153
- console.log(props, 'lsdkcmsdlcksd');
159
+ // console.log(props,'lsdkcmsdlcksd')
154
160
  getQuestiionsList("", 1);
155
161
  scrollToBottom();
156
- // less.modifyVars({ "@color-border-Tr": "#f4523b" });
157
- // console.log("9999999", less);
158
- // getRoomList();
162
+ // less.modifyVars({ "@color-border-Tr": "#f4523b" });
159
163
  setShowType(initShowType);
160
164
  }, [
161
165
  initShowType
@@ -163,38 +167,33 @@ const CustomerService = (props)=>{
163
167
  useEffect(()=>{
164
168
  // console.log(roomId,1111111)
165
169
  if (roomId != '') {
166
- // console.log(roomId,2222222)
167
- let num = pageNum != 1 ? pageNum : 1;
168
- getHistoryMessage(num, 0);
169
- scrollToBottom();
170
+ if (lastId == '') {
171
+ getHistoryMessage(pageNum, 2);
172
+ } else {
173
+ //查看历史记录,需要定位到当前记录
174
+ getHistoryMessage(pageNum, 1);
175
+ }
170
176
  }
171
177
  }, [
172
178
  roomId
173
179
  ]);
174
180
  useEffect(()=>{
175
- console.log(roomList, 'roomListroomListroomListroomListroomList');
176
- if (roomList.length > 0) {
177
- //切换到有聊天的窗口
178
- let message = roomList.filter((item)=>item.unreadCount > 0);
179
- if (message.length > 0) {
180
- setRoomId(message[0].roomId);
181
- readMessage(message[0].roomId, urllocation, userData, http);
182
- } else {
183
- setRoomId(roomList[0].roomId);
184
- }
185
- } else {
181
+ if (roomList.length == 0) {
186
182
  createRooms("AI").then((res)=>{
187
- // console.log(res.data,'dlfkvdlkfvmdf');
188
183
  setRoomId(res.data.id);
189
184
  setRoomList([
190
185
  {
191
186
  roomId: res.data.id,
192
187
  unreadCount: 0,
193
- uid: mid
188
+ uid: mid,
189
+ sender: 'AI'
194
190
  }
195
191
  ]);
196
192
  });
193
+ } else {
194
+ setRoomList(roomList);
197
195
  }
196
+ // recordRef.current.roomList=JSON.parse(JSON.stringify(roomList))
198
197
  }, [
199
198
  roomList
200
199
  ]);
@@ -211,7 +210,12 @@ const CustomerService = (props)=>{
211
210
  if (historyMessageList[historyMessageList.length - 1].extraInfo == null) {
212
211
  sendGreetingMessage(1);
213
212
  } else if (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo).length > 0 && (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].key == "questionId" || JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].value == "knowledgebase")) {
214
- console.log(JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo, "sdklsdksd"));
213
+ // console.log(
214
+ // JSON.parse(
215
+ // historyMessageList[historyMessageList.length - 1].extraInfo,
216
+ // "sdklsdksd"
217
+ // )
218
+ // );
215
219
  sendGreetingMessage(1);
216
220
  }
217
221
  } catch (error) {}
@@ -372,6 +376,7 @@ const CustomerService = (props)=>{
372
376
  recevier: chatWith.uid,
373
377
  message: problem.question
374
378
  };
379
+ setProblem({});
375
380
  } else if (type == 2) {
376
381
  let list = roomList.filter((item)=>item.roomId == roomId);
377
382
  let recevier = '';
@@ -382,7 +387,8 @@ const CustomerService = (props)=>{
382
387
  roomId: roomId,
383
388
  sender: mid,
384
389
  recevier: recevier,
385
- message: keyWord
390
+ message: keyWord,
391
+ quotedMessage: citationContent.content || ""
386
392
  };
387
393
  }
388
394
  http.post(`${urllocation}/chat-service/public/v1.0/chat-with-user/messages`, obj, {
@@ -397,26 +403,28 @@ const CustomerService = (props)=>{
397
403
  id: res.data.id,
398
404
  upvoted: false,
399
405
  downvoted: false,
400
- quotedMessage: "",
401
406
  createdAt: getDataTime(-1)
402
407
  }));
403
408
  return newHistoryMessageList;
404
409
  });
405
410
  scrollToBottom();
406
411
  //记录一个问题id,用于记录老师和学生之间的聊天保存到实验报告中
407
- if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
408
- // setChatObj({'roomId':roomId,'id':res.data.id});
409
- let obj = [
412
+ // if(stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)){
413
+ // setChatObj({'roomId':roomId,'id':res.data.id});
414
+ //判断当前窗口是否是
415
+ if (type == 1) {
416
+ let roomList = [
410
417
  {
411
418
  'roomId': roomId,
412
419
  'id': res.data.id
413
420
  }
414
421
  ];
415
422
  setChatObj((list)=>{
416
- let list2 = list.filter((item)=>item.id != obj[0].id);
417
- return list2.concat(obj);
423
+ let list2 = list.filter((item)=>item.id != roomList[0].id);
424
+ return list2.concat(roomList);
418
425
  });
419
426
  }
427
+ // }
420
428
  }
421
429
  }).catch((err)=>{
422
430
  console.log(err);
@@ -729,7 +737,6 @@ const CustomerService = (props)=>{
729
737
  }
730
738
  if (msg.finished) {
731
739
  setFinished(true); //发送结束
732
- console.log(content, JSON.parse(data), 'sdklcksdlcms');
733
740
  testLabQuestion(JSON.parse(data).message, content, '');
734
741
  }
735
742
  },
@@ -801,7 +808,7 @@ const CustomerService = (props)=>{
801
808
  };
802
809
  //问题记录到实验报告中
803
810
  const testLabQuestion = (title, content, teachId)=>{
804
- console.log(title, content, '记录到实验报告中');
811
+ // console.log(title,content,'记录到实验报告中')
805
812
  if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
806
813
  http.post(`${urllocation}/sandboxes/public/v1.0/labquestion`, {
807
814
  title: title,
@@ -814,6 +821,12 @@ const CustomerService = (props)=>{
814
821
  "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
815
822
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
816
823
  }
824
+ }).then(()=>{
825
+ console.log(roomId, chatObj, 'roomIdroomIdroomIdroomId');
826
+ setChatObj((list1)=>{
827
+ let list = list1.filter((e)=>e.roomId != roomId);
828
+ return list;
829
+ });
817
830
  });
818
831
  }
819
832
  };
@@ -848,14 +861,27 @@ const CustomerService = (props)=>{
848
861
  }
849
862
  });
850
863
  };
851
- //获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
852
- const getHistoryMessage = (pageNum, flag)=>{
853
- console.log(pageNum, flag, "重新加载数据2222");
854
- if (roomId == "") return;
864
+ //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
865
+ const getHistoryMessage = (pageNum, flag, id = "1")=>{
866
+ clearTimeout(roomMessage.current);
867
+ // flag == 1 时已经设置好了位置标记
868
+ let last_id = "";
869
+ if (flag == 2 && historyMessageList.length > 0) {
870
+ last_id = historyMessageList[0].id;
871
+ }
872
+ if (flag != 1 && last_id != "") {
873
+ setLastId(last_id);
874
+ }
875
+ //取消搜索页码标记
876
+ if (flag == 4 && pageNum == 1) {
877
+ setPageNumHistory(0);
878
+ }
879
+ let rid = flag == 3 ? id : roomId;
880
+ if (rid == "") return;
855
881
  return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
856
882
  params: {
857
- roomId: roomId,
858
- page: pageNum != undefined && pageNum != -1 ? pageNum : 1,
883
+ roomId: rid,
884
+ page: pageNum ? pageNum : 1,
859
885
  maxPageSize: 30,
860
886
  direction: "desc"
861
887
  },
@@ -864,129 +890,180 @@ const CustomerService = (props)=>{
864
890
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
865
891
  }
866
892
  }).then((res)=>{
893
+ let totalNumber = 0;
894
+ let roomList = [];
895
+ setRoomList((list)=>{
896
+ roomList = list;
897
+ return list;
898
+ });
867
899
  if (res.data.messages.length > 0) {
868
900
  clearTimeout(listTimer.current);
869
- let last_id = "";
870
901
  let total = res.data.total;
871
902
  let maxPageSize = 30;
872
903
  let dataList = res.data.messages.reverse();
873
904
  setPageCount(Math.ceil(total / maxPageSize));
874
905
  let newHistoryMessageList = [];
875
906
  setHistoryMessageList((historyMessageList)=>{
876
- if (flag != 1 && historyMessageList.length > 0) {
877
- if (flag == 2) {
878
- last_id = historyMessageList[historyMessageList.length - 1].id;
907
+ //获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
908
+ newHistoryMessageList = [];
909
+ if (flag == 1) {
910
+ newHistoryMessageList = dataList;
911
+ }
912
+ if (flag == 4) {
913
+ newHistoryMessageList = historyMessageList.concat(dataList); //下拉加载,向后追加内容
914
+ }
915
+ if (flag == 2) {
916
+ if (pageNum == 1) {
917
+ newHistoryMessageList = dataList;
879
918
  } else {
880
- last_id = historyMessageList[0].id;
919
+ newHistoryMessageList = dataList.concat(historyMessageList);
881
920
  }
882
921
  }
883
- newHistoryMessageList = [];
884
- //查找历史记录flag==1
885
- if (pageNum == 1 || flag == 1 || flag == 3) {
922
+ if (flag == 3) {
886
923
  newHistoryMessageList = dataList;
887
- } else if (flag == 2) {
888
- //下拉加载
889
- newHistoryMessageList = historyMessageList.concat(dataList);
890
- } else {
891
- newHistoryMessageList = dataList.concat(historyMessageList);
892
924
  }
925
+ //去重
893
926
  let res = new Map();
894
927
  newHistoryMessageList = newHistoryMessageList.filter((a)=>!res.has(a.id) && res.set(a.id, 1));
928
+ totalNumber = newHistoryMessageList.length;
895
929
  return newHistoryMessageList;
896
930
  });
897
931
  //如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
898
932
  try {
899
- if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4) && roomList.length > 0 && roomList[0].roomId != roomId) {
933
+ if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
900
934
  fildChatRecords(newHistoryMessageList);
901
935
  }
902
936
  } catch (error) {}
903
- if (flag != 1) {
904
- setLastId(last_id);
905
- }
906
- if (pageNum == 1 && flag != 1 || flag == 3) {
907
- scrollToBottom();
908
- } else {
909
- console.log("滚动到相应为止3333");
910
- scrollTo("li_flag");
937
+ if (flag != 4) {
938
+ if (pageNum == 1 && (flag == 2 || flag == 3)) {
939
+ scrollToBottom();
940
+ } else {
941
+ scrollTo("li_flag");
942
+ }
911
943
  }
944
+ setBottomLoading(false);
945
+ setLoading(false);
912
946
  setGreetingMessage(true);
913
947
  //召唤老师回答
914
- console.log(problem, 8888888);
915
948
  if (problem != undefined && problem.user != undefined && problem.question != undefined) {
916
- console.log(problem, 77777);
917
949
  sendToTeacher(1);
918
950
  }
919
951
  } else {
920
952
  setPageCount(0);
921
953
  setGreetingMessage(true);
954
+ setBottomLoading(false);
922
955
  setLoading(false);
923
956
  setHistoryMessageList([]);
924
957
  //召唤老师回答
925
- console.log(problem, 8888888);
926
958
  if (problem != undefined && problem.user != undefined && problem.question != undefined) {
927
- console.log(problem, 77777);
928
959
  sendToTeacher(1);
929
960
  }
930
961
  }
962
+ // console.log(roomList,rid,roomId,555555);
963
+ //不是ai窗口循环查询消息
964
+ let chatWindow = roomList.filter((item)=>item.roomId == rid);
965
+ let isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == 'AI' ? true : false;
966
+ if (!isAiChatWindow && roomList.length > 0) {
967
+ getRoomidHistoryMessage(totalNumber, rid);
968
+ }
931
969
  }).catch((res)=>{
932
970
  setLoading(false);
933
971
  });
934
972
  };
973
+ //用于循环新消息
974
+ const getRoomidHistoryMessage = (totalNumber, rid)=>{
975
+ clearTimeout(roomMessage.current);
976
+ roomMessage.current = setTimeout(()=>{
977
+ getRoomidHistoryMessage(totalNumber, rid);
978
+ }, 5000);
979
+ if (rid == '') return;
980
+ // console.log(roomList,2222222);
981
+ return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
982
+ params: {
983
+ roomId: rid,
984
+ page: 1,
985
+ maxPageSize: totalNumber < 30 ? 30 : totalNumber + 10,
986
+ direction: "desc"
987
+ },
988
+ headers: {
989
+ "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
990
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
991
+ }
992
+ }).then((res)=>{
993
+ let newHistoryMessageList = [];
994
+ if (res.data.messages.length > 0) {
995
+ let dataList = res.data.messages.reverse();
996
+ setHistoryMessageList((historyMessageList)=>{
997
+ newHistoryMessageList = dataList;
998
+ //去重
999
+ let res = new Map();
1000
+ newHistoryMessageList = newHistoryMessageList.filter((a)=>!res.has(a.id) && res.set(a.id, 1));
1001
+ return newHistoryMessageList;
1002
+ });
1003
+ if (dataList.length > totalNumber) {
1004
+ scrollToBottom();
1005
+ }
1006
+ }
1007
+ try {
1008
+ if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
1009
+ fildChatRecords(newHistoryMessageList);
1010
+ }
1011
+ } catch (error) {}
1012
+ });
1013
+ };
935
1014
  //在聊天对话框中查找需要记录的问题及答案
936
1015
  const fildChatRecords = (newHistoryMessageList)=>{
937
1016
  //1、找到对应的聊天室
938
1017
  //2、找到与老师对话的新聊天
939
1018
  //3、保存聊天到实验报告
940
- console.log('查找聊天111', chatObj);
941
- let room = chatObj.filter((item)=>item.roomId == roomId);
942
- if (room.length > 0) {
943
- console.log(room, 'dfvdfvdfvdfv');
944
- let roomIDnumber = room[0].roomId;
945
- let chatID = room[0].id;
946
- let index = -1;
947
- newHistoryMessageList.forEach((item, i)=>{
948
- console.log(item, item.id, 'lskdcmsldksdcsdc');
949
- if (item.id == chatID) {
950
- index = i;
951
- return false;
952
- }
1019
+ // console.log('查找聊天111',chatObj,newHistoryMessageList);
1020
+ try {
1021
+ let chatObj = [];
1022
+ setChatObj((item)=>{
1023
+ chatObj = item;
1024
+ return item;
953
1025
  });
954
- //有新的消息
955
- if (index != -1) {
956
- let newMessage = newHistoryMessageList.slice(index);
957
- console.log(newMessage, '需要记录的聊天');
958
- //1、查找 sender发送者
959
- let objList = [];
960
- let obj = {};
961
- let position = -1;
962
- newMessage.map((item, i)=>{
963
- if (item.sender == mid && position != i) {
964
- objList.push(obj);
965
- obj = {};
966
- }
967
- //发送者
968
- if (item.sender == mid) {
969
- obj.title = item.message;
970
- position = i;
971
- }
972
- if (item.sender != mid) {
973
- obj.con = item.message;
974
- obj.teachId = item.receiver;
1026
+ // console.log(chatObj,555555);
1027
+ let room = chatObj.filter((item)=>item.roomId == roomId);
1028
+ if (room.length > 0) {
1029
+ // console.log(room,'dfvdfvdfvdfv')
1030
+ let chatID = room[0].id;
1031
+ console.log(chatID, 'chatIDchatIDchatID');
1032
+ let index = -1;
1033
+ newHistoryMessageList.forEach((item, i)=>{
1034
+ // console.log(item,item.id,'lskdcmsldksdcsdc')
1035
+ if (item.id == chatID) {
1036
+ index = i;
1037
+ return false;
975
1038
  }
976
1039
  });
977
- //需要保存的记录
978
- objList = objList.filter((item)=>item.title != undefined);
979
- objList.map((item)=>{
980
- //保存聊天记录
981
- testLabQuestion(item.title, item.con, item.teachId);
982
- //删除已经保存的记录
983
- setChatObj((list)=>{
984
- return list.filter((a)=>a.roomId != roomIDnumber);
1040
+ //有新的消息
1041
+ if (index != -1) {
1042
+ let newMessage = newHistoryMessageList.slice(index);
1043
+ console.log(newMessage, 'newMessagenewMessage');
1044
+ let result = [];
1045
+ newMessage.forEach((item, index)=>{
1046
+ let isQuestion = item.receiver !== mid //是否为问题
1047
+ ;
1048
+ if (isQuestion) {
1049
+ //问题
1050
+ if (newMessage[index + 1] && newMessage[index + 1].receiver === mid) {
1051
+ result.push({
1052
+ question: item.message,
1053
+ id: item.receiver,
1054
+ answer: newMessage[index + 1].message
1055
+ });
1056
+ return;
1057
+ }
1058
+ }
985
1059
  });
986
- });
987
- console.log(objList, 'sdkcjnsdkjcsd');
1060
+ console.log(result, '存储的消息');
1061
+ result.map((item)=>{
1062
+ testLabQuestion(item.question, item.answer, item.id);
1063
+ });
1064
+ }
988
1065
  }
989
- }
1066
+ } catch (error) {}
990
1067
  };
991
1068
  //点赞消息
992
1069
  const likeMessage = (id, state)=>{
@@ -1096,29 +1173,24 @@ const CustomerService = (props)=>{
1096
1173
  };
1097
1174
  //设置滚动条滚动到底部
1098
1175
  const scrollToBottom = ()=>{
1099
- console.log("滚动条滚动到底部");
1100
1176
  const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1101
1177
  if (container) {
1102
1178
  container.scrollTop = container.scrollHeight;
1103
1179
  }
1104
1180
  };
1105
1181
  const scrollTo = (id)=>{
1106
- console.log(id, "滚动到指定位置");
1107
1182
  const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1108
1183
  const container2 = document.getElementById(id);
1109
- // clearTimeout(listTimer.current)
1110
1184
  if (container && container2) {
1111
- // container.scrollTop = container2.scrollHeight;
1112
- // if(container2.scrollTop == 0){
1113
1185
  container.scrollTop = 60;
1114
- setTimeout(()=>{
1115
- let top = showType == 1 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1116
- $(`#${showType == 1 ? "chat_content" : "chat_content_modal"}`).animate({
1117
- scrollTop: top
1118
- }, 0);
1119
- }, 10);
1120
- // }
1121
- // clearTimeout(listTimer.current)
1186
+ try {
1187
+ setTimeout(()=>{
1188
+ let top = showType == 1 || showType == 3 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1189
+ $(`#${showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"}`).animate({
1190
+ scrollTop: top
1191
+ }, 0);
1192
+ }, 10);
1193
+ } catch (error) {}
1122
1194
  setLoading(false);
1123
1195
  }
1124
1196
  };
@@ -1139,6 +1211,15 @@ const CustomerService = (props)=>{
1139
1211
  };
1140
1212
  //渲染头部
1141
1213
  const renderHeader = ()=>{
1214
+ let list = roomList.filter((e)=>e.roomId == roomId);
1215
+ let title = '智能回答';
1216
+ if (list.length > 0 && list[0].name) {
1217
+ title = list[0].name;
1218
+ }
1219
+ let count = 0;
1220
+ roomList.map((item)=>{
1221
+ count = count + item.unreadCount;
1222
+ });
1142
1223
  if (showType == 4) {
1143
1224
  return /*#__PURE__*/ _jsxs("div", {
1144
1225
  className: styles.top,
@@ -1146,7 +1227,7 @@ const CustomerService = (props)=>{
1146
1227
  /*#__PURE__*/ _jsx("div", {
1147
1228
  className: styles.user,
1148
1229
  children: /*#__PURE__*/ _jsx("p", {
1149
- children: "智能回答"
1230
+ children: title
1150
1231
  })
1151
1232
  }),
1152
1233
  /*#__PURE__*/ _jsxs("div", {
@@ -1164,6 +1245,7 @@ const CustomerService = (props)=>{
1164
1245
  /*#__PURE__*/ _jsx("i", {
1165
1246
  onClick: ()=>{
1166
1247
  onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1248
+ setFirstLoad(false); //重启滚动条在最上方
1167
1249
  setShowType(3);
1168
1250
  },
1169
1251
  children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
@@ -1172,6 +1254,7 @@ const CustomerService = (props)=>{
1172
1254
  onClick: ()=>{
1173
1255
  onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1174
1256
  setShowType(3);
1257
+ setFirstLoad(false); //重启滚动条在最上方
1175
1258
  },
1176
1259
  children: /*#__PURE__*/ _jsx(CloseOutlined, {})
1177
1260
  })
@@ -1179,46 +1262,6 @@ const CustomerService = (props)=>{
1179
1262
  })
1180
1263
  ]
1181
1264
  });
1182
- } else if (showType == 3) {
1183
- return /*#__PURE__*/ _jsxs("div", {
1184
- className: styles.top,
1185
- children: [
1186
- /*#__PURE__*/ _jsx("div", {
1187
- className: styles.user,
1188
- children: /*#__PURE__*/ _jsx("p", {
1189
- children: "智能回答"
1190
- })
1191
- }),
1192
- /*#__PURE__*/ _jsxs("div", {
1193
- className: styles.operate,
1194
- children: [
1195
- /*#__PURE__*/ _jsx("i", {
1196
- onClick: ()=>{
1197
- setShowHistory(true);
1198
- },
1199
- children: /*#__PURE__*/ _jsx(CustomRecord, {})
1200
- }),
1201
- /*#__PURE__*/ _jsx("span", {
1202
- className: styles.line
1203
- }),
1204
- /*#__PURE__*/ _jsx("i", {
1205
- onClick: ()=>{
1206
- onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1207
- setShowType(4);
1208
- },
1209
- children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
1210
- }),
1211
- /*#__PURE__*/ _jsx("i", {
1212
- className: "lianxiren21",
1213
- onClick: ()=>{
1214
- setShowContacts(true);
1215
- },
1216
- children: /*#__PURE__*/ _jsx(CustomContacts, {})
1217
- })
1218
- ]
1219
- })
1220
- ]
1221
- });
1222
1265
  } else {
1223
1266
  return /*#__PURE__*/ _jsxs("div", {
1224
1267
  className: styles.top,
@@ -1227,14 +1270,20 @@ const CustomerService = (props)=>{
1227
1270
  className: styles.user,
1228
1271
  children: /*#__PURE__*/ _jsxs("p", {
1229
1272
  children: [
1230
- showType == 1 && /*#__PURE__*/ _jsx("i", {
1273
+ showType == 1 && /*#__PURE__*/ _jsxs("i", {
1231
1274
  className: "lianxiren21",
1232
1275
  onClick: ()=>{
1233
1276
  setShowContacts(true);
1234
1277
  },
1235
- children: /*#__PURE__*/ _jsx(CustomContacts, {})
1278
+ children: [
1279
+ /*#__PURE__*/ _jsx(CustomContacts, {}),
1280
+ count > 0 ? /*#__PURE__*/ _jsx("span", {
1281
+ className: styles.count,
1282
+ children: count > 99 ? '99+' : count
1283
+ }) : ''
1284
+ ]
1236
1285
  }),
1237
- "智能回答"
1286
+ title
1238
1287
  ]
1239
1288
  })
1240
1289
  }),
@@ -1256,6 +1305,7 @@ const CustomerService = (props)=>{
1256
1305
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1257
1306
  // switchDialogBox(3, true);
1258
1307
  setShowType(2);
1308
+ childRef.current.roomsListTimer();
1259
1309
  },
1260
1310
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
1261
1311
  }) : /*#__PURE__*/ _jsx("i", {
@@ -1280,20 +1330,30 @@ const CustomerService = (props)=>{
1280
1330
  const resettingBottomHei = ()=>{
1281
1331
  setTimeout(()=>{
1282
1332
  if (showType == 1 || showType == 3) {
1283
- let hei = document.getElementById("Drawer_buttom").offsetHeight;
1284
- setButtomHei(hei);
1333
+ if (document.getElementById("Drawer_buttom_modal")) {
1334
+ let hei = document.getElementById("Drawer_buttom").offsetHeight;
1335
+ setButtomHei(hei);
1336
+ }
1285
1337
  } else {
1286
- let hei = document.getElementById("Drawer_buttom_modal").offsetHeight;
1287
- setButtomHei(hei);
1338
+ if (document.getElementById("Drawer_buttom_modal")) {
1339
+ let hei = document.getElementById("Drawer_buttom_modal").offsetHeight;
1340
+ setButtomHei(hei);
1341
+ }
1288
1342
  }
1289
1343
  }, 50);
1290
1344
  };
1291
1345
  //切换聊天室 type == renew ,存在新消息
1292
1346
  const switchChatRoom = (id, type)=>{
1293
- if (type == "renew") {
1294
- getHistoryMessage(1, 3);
1295
- }
1347
+ setLastId("");
1348
+ setPageNum(1);
1349
+ setPageCount(0);
1296
1350
  setRoomId(id);
1351
+ //
1352
+ // if (type == "renew") {
1353
+ // getHistoryMessage(1, 3,id);
1354
+ // }else{
1355
+ // setRoomId(id);
1356
+ // }
1297
1357
  readMessage(id, urllocation, userData, http);
1298
1358
  };
1299
1359
  const saveContactsList = (list)=>{
@@ -1303,13 +1363,14 @@ const CustomerService = (props)=>{
1303
1363
  };
1304
1364
  //渲染问答
1305
1365
  const renderQuestion = ()=>{
1366
+ // 2023-12-01T14:34:07
1367
+ // console.log(lastId,'lastIdlastIdlastId')
1306
1368
  // console.log(mid, historyMessageList, "ddkfdscksdcs");
1307
1369
  if (historyMessageList.length > 0) {
1308
- // let historyData = "";
1309
- // let showData = true;
1310
1370
  return /*#__PURE__*/ _jsx("ul", {
1311
1371
  className: styles.message_con,
1312
1372
  children: historyMessageList.map((item, i)=>{
1373
+ let timeObj = parseDate(item.createdAt);
1313
1374
  // console.log(item.message);
1314
1375
  let message = item.message;
1315
1376
  let li;
@@ -1318,17 +1379,20 @@ const CustomerService = (props)=>{
1318
1379
  let time = "";
1319
1380
  if (itemIndex <= 0) {
1320
1381
  //第一项
1321
- time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1382
+ time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
1322
1383
  } else {
1323
1384
  //非第一项 与上一项进行对比
1324
1385
  let beforeTime = historyMessageList[itemIndex - 1].createdAt;
1325
1386
  //判断与上一条数据 是否跨天
1326
- if (dayjs(beforeTime).format("YYYY-MM-DD") !== dayjs(item.createdAt).format("YYYY-MM-DD")) {
1327
- time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1387
+ let beforeTimeObj = parseDate(beforeTime);
1388
+ let beforeTimeStr = `${beforeTimeObj.year}-${beforeTimeObj.month}-${beforeTimeObj.day}`;
1389
+ let curTimeStr = `${timeObj.year}-${timeObj.month}-${timeObj.day}`;
1390
+ if (beforeTimeStr !== curTimeStr) {
1391
+ time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
1328
1392
  } else {
1329
1393
  //没有跨天 判断是否相隔超过10分钟
1330
- if (dayjs(item.createdAt).valueOf() - dayjs(beforeTime).valueOf() > 10 * 60 * 1000) {
1331
- time = dayjs(item.createdAt).format("HH:mm");
1394
+ if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
1395
+ time = `${timeObj.minutes}:${timeObj.seconds}`;
1332
1396
  }
1333
1397
  }
1334
1398
  }
@@ -1345,80 +1409,81 @@ const CustomerService = (props)=>{
1345
1409
  className: styles.left,
1346
1410
  id: lastId == item.id ? "li_flag" : "",
1347
1411
  children: [
1348
- /*#__PURE__*/ _jsxs("div", {
1412
+ /*#__PURE__*/ _jsx("div", {
1349
1413
  className: styles.main,
1350
- children: [
1351
- /*#__PURE__*/ _jsxs("div", {
1352
- className: styles.main_content,
1353
- children: [
1354
- /*#__PURE__*/ _jsx("div", {
1355
- className: styles.operate_modal,
1414
+ children: /*#__PURE__*/ _jsxs("div", {
1415
+ className: styles.main_content,
1416
+ children: [
1417
+ /*#__PURE__*/ _jsx("div", {
1418
+ className: styles.operate_modal,
1419
+ children: /*#__PURE__*/ _jsxs("p", {
1420
+ className: styles.operate,
1421
+ children: [
1422
+ /*#__PURE__*/ _jsx("i", {
1423
+ className: "yinyong_quote1",
1424
+ onClick: ()=>{
1425
+ setCitationContent({
1426
+ content: item.message,
1427
+ id: item.id
1428
+ });
1429
+ resettingBottomHei();
1430
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1431
+ },
1432
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1433
+ }),
1434
+ copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1435
+ className: `tongyong-xuanzhongdui`,
1436
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1437
+ }) : /*#__PURE__*/ _jsx("i", {
1438
+ className: "fuzhi21",
1439
+ onClick: ()=>{
1440
+ let bol = copyText(item.message);
1441
+ if (bol) {
1442
+ let obj = copyTextOBJ;
1443
+ obj = obj.filter((list)=>list != item.id);
1444
+ obj.push(item.id);
1445
+ setCopyTextObj(obj);
1446
+ }
1447
+ setTimeout(()=>{
1448
+ let obj = copyTextOBJ;
1449
+ obj = obj.filter((list)=>list != item.id);
1450
+ setCopyTextObj(obj);
1451
+ }, 3000);
1452
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1453
+ },
1454
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1455
+ })
1456
+ ]
1457
+ })
1458
+ }),
1459
+ /*#__PURE__*/ _jsx("div", {
1460
+ className: styles.content,
1461
+ children: /*#__PURE__*/ _jsx("p", {
1462
+ dangerouslySetInnerHTML: {
1463
+ __html: remarkable.render(message)
1464
+ },
1465
+ className: styles.content_child
1466
+ })
1467
+ }),
1468
+ //引用消息
1469
+ item.quotedMessage && /*#__PURE__*/ _jsx("div", {
1470
+ className: styles.citation_content,
1471
+ children: getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
1472
+ overlayClassName: styles.popover_main_content,
1473
+ title: item.quotedMessage,
1474
+ placement: "leftTop",
1356
1475
  children: /*#__PURE__*/ _jsxs("p", {
1357
- className: styles.operate,
1358
1476
  children: [
1359
- /*#__PURE__*/ _jsx("i", {
1360
- className: "yinyong_quote1",
1361
- onClick: ()=>{
1362
- setCitationContent({
1363
- content: item.message,
1364
- id: item.id
1365
- });
1366
- resettingBottomHei();
1367
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1368
- },
1369
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
1370
- }),
1371
- copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1372
- className: `tongyong-xuanzhongdui`,
1373
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1374
- }) : /*#__PURE__*/ _jsx("i", {
1375
- className: "fuzhi21",
1376
- onClick: ()=>{
1377
- let bol = copyText(item.message);
1378
- if (bol) {
1379
- let obj = copyTextOBJ;
1380
- obj = obj.filter((list)=>list != item.id);
1381
- obj.push(item.id);
1382
- setCopyTextObj(obj);
1383
- }
1384
- setTimeout(()=>{
1385
- let obj = copyTextOBJ;
1386
- obj = obj.filter((list)=>list != item.id);
1387
- setCopyTextObj(obj);
1388
- }, 3000);
1389
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1390
- },
1391
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
1392
- })
1477
+ item.quotedMessage,
1478
+ ">"
1393
1479
  ]
1394
1480
  })
1395
- }),
1396
- /*#__PURE__*/ _jsx("div", {
1397
- className: styles.content,
1398
- children: /*#__PURE__*/ _jsx("p", {
1399
- dangerouslySetInnerHTML: {
1400
- __html: remarkable.render(message)
1401
- },
1402
- className: styles.content_child
1403
- })
1404
- })
1405
- ]
1406
- }),
1407
- //引用消息
1408
- item.quotedMessage != "" && item.quotedMessage != null && item.quotedMessage != undefined ? /*#__PURE__*/ _jsx("div", {
1409
- className: styles.citation_content,
1410
- children: getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
1411
- overlayClassName: styles.popover_main_content,
1412
- title: item.quotedMessage,
1413
- placement: "leftTop",
1414
- children: /*#__PURE__*/ _jsx("p", {
1481
+ }) : /*#__PURE__*/ _jsx("p", {
1415
1482
  children: item.quotedMessage
1416
1483
  })
1417
- }) : /*#__PURE__*/ _jsx("p", {
1418
- children: item.quotedMessage
1419
1484
  })
1420
- }) : ""
1421
- ]
1485
+ ]
1486
+ })
1422
1487
  }),
1423
1488
  showType == 2 || showType == 4 ? /*#__PURE__*/ _jsx("div", {
1424
1489
  className: styles.head_sculpture,
@@ -1441,7 +1506,12 @@ const CustomerService = (props)=>{
1441
1506
  headImg = chatWindow[0].headImg;
1442
1507
  }
1443
1508
  //是否在智能客服窗口
1444
- let isAiChatWindow = chatWindow[0].sender == 'AI' ? true : false;
1509
+ let isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == 'AI' ? true : false;
1510
+ let header = 2; //代表是ai头像
1511
+ if (isAiChatWindow && item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
1512
+ //使用AI头像
1513
+ header = 1;
1514
+ }
1445
1515
  li = /*#__PURE__*/ _jsxs(_Fragment, {
1446
1516
  children: [
1447
1517
  dataTime ? /*#__PURE__*/ _jsx("li", {
@@ -1452,12 +1522,12 @@ const CustomerService = (props)=>{
1452
1522
  className: styles.right,
1453
1523
  id: lastId == item.id ? "li_flag" : "",
1454
1524
  children: [
1455
- showType == 2 || showType == 4 && /*#__PURE__*/ _jsx("div", {
1525
+ (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
1456
1526
  className: styles.head_sculpture,
1457
1527
  style: {
1458
1528
  marginRight: "12px"
1459
1529
  },
1460
- children: isAiChatWindow ? item.extraInfo == null ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
1530
+ children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
1461
1531
  src: knowledge_icon
1462
1532
  }) : /*#__PURE__*/ _jsx("img", {
1463
1533
  src: headImg
@@ -1470,119 +1540,8 @@ const CustomerService = (props)=>{
1470
1540
  children: [
1471
1541
  /*#__PURE__*/ _jsx("div", {
1472
1542
  className: styles.operate_modal,
1473
- children: historyMessageList.length - 1 == i && item.extraInfo == null || item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs("p", {
1474
- className: styles.operate,
1475
- children: [
1476
- /*#__PURE__*/ _jsx("span", {
1477
- className: styles.ask_question,
1478
- onClick: ()=>{
1479
- setAnswerMode(1);
1480
- setProblem({
1481
- question: historyMessageList[i - 1].message,
1482
- user: problem.user
1483
- });
1484
- setHistoryMessageList((historyMessageList)=>{
1485
- let newHistoryMessageList = historyMessageList.concat({
1486
- id: -1,
1487
- roomId: roomId,
1488
- sender: "AI",
1489
- recevier: mid,
1490
- message: "请在输入框中输入您要召唤的老师的姓名",
1491
- createdAt: getDataTime(-1),
1492
- findTeacher: true
1493
- });
1494
- return newHistoryMessageList;
1495
- });
1496
- scrollToBottom();
1497
- },
1498
- children: "召唤老师回答"
1499
- }),
1500
- /*#__PURE__*/ _jsx("i", {
1501
- className: "yinyong_quote1",
1502
- onClick: ()=>{
1503
- setCitationContent({
1504
- content: item.message,
1505
- id: item.id
1506
- });
1507
- resettingBottomHei();
1508
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1509
- console.log("引用222222");
1510
- },
1511
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
1512
- }),
1513
- copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1514
- className: `tongyong-xuanzhongdui`,
1515
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1516
- }) : /*#__PURE__*/ _jsx("i", {
1517
- className: "fuzhi21",
1518
- onClick: ()=>{
1519
- let bol = copyText(item.message);
1520
- if (bol) {
1521
- let obj = copyTextOBJ;
1522
- obj = obj.filter((list)=>list != item.id);
1523
- obj.push(item.id);
1524
- setCopyTextObj(obj);
1525
- }
1526
- setTimeout(()=>{
1527
- let obj = copyTextOBJ;
1528
- obj = obj.filter((list)=>list != item.id);
1529
- setCopyTextObj(obj);
1530
- }, 3000);
1531
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1532
- },
1533
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
1534
- }),
1535
- /*#__PURE__*/ _jsx("span", {
1536
- children: "|"
1537
- }),
1538
- /*#__PURE__*/ _jsx("i", {
1539
- className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
1540
- onClick: ()=>{
1541
- likeMessage(item.id, item.upvoted);
1542
- console.log("判断是AI还是智能回答", item);
1543
- //只有最后一条回答,支持发送点赞或踩
1544
- if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1545
- console.log("判断是AI还是智能回答", item);
1546
- if (!item.extraInfo && item.sender == "AI") {
1547
- aiSendQuestions(1, {
1548
- roomId: roomId,
1549
- message: "你给出的答案我非常满意,赞!",
1550
- quotedMessage: "",
1551
- regenerate: false,
1552
- generateUpvoteOrDownvoteMessage: true
1553
- }, 1);
1554
- } else {
1555
- console.log("AI回答2255555");
1556
- sendGreetingMessage(2);
1557
- }
1558
- }
1559
- },
1560
- children: /*#__PURE__*/ _jsx(CustomLike, {})
1561
- }),
1562
- /*#__PURE__*/ _jsx("i", {
1563
- className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
1564
- onClick: ()=>{
1565
- disagreeMessage(item.id, item.downvoted);
1566
- //只有最后一条回答,支持发送点赞或踩
1567
- console.log(item, "dlfkvmdflkv");
1568
- if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1569
- if (!item.extraInfo && item.sender == "AI") {
1570
- aiSendQuestions(1, {
1571
- roomId: roomId,
1572
- message: "你给出的答案很糟糕,我不满意,踩!",
1573
- quotedMessage: "",
1574
- regenerate: false,
1575
- generateUpvoteOrDownvoteMessage: true
1576
- }, 1);
1577
- } else {
1578
- sendGreetingMessage(3);
1579
- }
1580
- }
1581
- },
1582
- children: /*#__PURE__*/ _jsx(CustomDislike, {})
1583
- })
1584
- ]
1585
- })
1543
+ children: // 不是最后一行,
1544
+ historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
1586
1545
  }),
1587
1546
  /*#__PURE__*/ _jsxs("div", {
1588
1547
  className: styles.content,
@@ -1593,7 +1552,7 @@ const CustomerService = (props)=>{
1593
1552
  },
1594
1553
  className: styles.content_child
1595
1554
  }),
1596
- item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" ? /*#__PURE__*/ _jsx("ul", {
1555
+ item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsx("ul", {
1597
1556
  className: styles.association_problem,
1598
1557
  children: JSON.parse(item.extraInfo).map((list, index)=>{
1599
1558
  return /*#__PURE__*/ _jsxs("li", {
@@ -1607,165 +1566,30 @@ const CustomerService = (props)=>{
1607
1566
  ]
1608
1567
  }, i + "_" + index + "_" + list.value);
1609
1568
  })
1610
- }) : ""
1569
+ })
1611
1570
  ]
1612
1571
  }),
1613
- !item.findTeacher && historyMessageList.length - 1 == i && item.extraInfo == null && item.id != "123456" ? /*#__PURE__*/ _jsx("div", {
1614
- className: `${styles.operate_modal_bottom}`,
1615
- children: item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs(_Fragment, {
1616
- children: [
1617
- /*#__PURE__*/ _jsx("p", {
1618
- className: styles.stop_generate,
1619
- children: !finished ? /*#__PURE__*/ _jsxs(_Fragment, {
1620
- children: [
1621
- /*#__PURE__*/ _jsx("span", {
1622
- onClick: ()=>{
1623
- // aiSendQuestions(3,{},1);
1624
- // if (type == 3) {
1625
- try {
1626
- if (ctrl && ctrl.current) {
1627
- ctrl.current.abort();
1628
- }
1629
- } catch (error) {}
1630
- clearTimeout(receiveMessageTimer.current);
1631
- setHistoryMessageList((historyMessageList)=>{
1632
- return historyMessageList.filter((item)=>item.id != "123456");
1633
- });
1634
- setFinished(true);
1635
- // return;
1636
- // }
1637
- onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1638
- }
1639
- }),
1640
- /*#__PURE__*/ _jsx("i", {
1641
- onClick: ()=>{
1642
- // aiSendQuestions(3,{},1);
1643
- try {
1644
- if (ctrl && ctrl.current) {
1645
- ctrl.current.abort();
1646
- }
1647
- } catch (error) {}
1648
- clearTimeout(receiveMessageTimer.current);
1649
- setHistoryMessageList((historyMessageList)=>{
1650
- return historyMessageList.filter((item)=>item.id != "123456");
1651
- });
1652
- setFinished(true);
1653
- onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1654
- },
1655
- children: "停止生成"
1656
- })
1657
- ]
1658
- }) : ""
1659
- }),
1660
- finished ? /*#__PURE__*/ _jsxs("p", {
1661
- className: `${styles.operate}`,
1662
- children: [
1663
- /*#__PURE__*/ _jsx("i", {
1664
- onClick: ()=>{
1665
- setFinished(false);
1666
- aiSendQuestions(2, {
1667
- roomId: roomId,
1668
- message: historyMessageList[i - 1].message,
1669
- quotedMessage: citationContent.content || "",
1670
- regenerate: true,
1671
- generateUpvoteOrDownvoteMessage: false
1672
- }, item.id);
1673
- onEvent(serverName + serverUrl(), "click_智能问答_重新生成", "提交");
1674
- },
1675
- children: /*#__PURE__*/ _jsx(CustomReloading, {})
1676
- }),
1677
- /*#__PURE__*/ _jsx("i", {
1678
- className: "yinyong_quote1",
1679
- onClick: ()=>{
1680
- setCitationContent({
1681
- content: item.message,
1682
- id: item.id
1683
- });
1684
- resettingBottomHei();
1685
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1686
- },
1687
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
1688
- }),
1689
- copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1690
- className: `tongyong-xuanzhongdui`,
1691
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1692
- }) : /*#__PURE__*/ _jsx("i", {
1693
- className: "fuzhi21",
1694
- onClick: ()=>{
1695
- let bol = copyText(item.message);
1696
- if (bol) {
1697
- let obj = copyTextOBJ;
1698
- obj = obj.filter((list)=>list != item.id);
1699
- obj.push(item.id);
1700
- setCopyTextObj(obj);
1701
- }
1702
- setTimeout(()=>{
1703
- let obj = copyTextOBJ;
1704
- obj = obj.filter((list)=>list != item.id);
1705
- setCopyTextObj(obj);
1706
- }, 3000);
1707
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1708
- },
1709
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
1710
- }),
1711
- /*#__PURE__*/ _jsx("span", {
1712
- children: "|"
1713
- }),
1714
- /*#__PURE__*/ _jsx("i", {
1715
- className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
1716
- onClick: ()=>{
1717
- likeMessage(item.id, item.upvoted);
1718
- console.log("判断是AI还是智能回答", item);
1719
- //只有最后一条回答,支持发送点赞或踩
1720
- if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1721
- console.log("判断是AI还是智能回答", item);
1722
- if (!item.extraInfo && item.sender == "AI") {
1723
- aiSendQuestions(1, {
1724
- roomId: roomId,
1725
- message: "你给出的答案我非常满意,赞!",
1726
- quotedMessage: "",
1727
- regenerate: false,
1728
- generateUpvoteOrDownvoteMessage: true
1729
- }, 1);
1730
- } else {
1731
- console.log("AI回答2255555");
1732
- sendGreetingMessage(2);
1733
- }
1734
- }
1735
- },
1736
- children: /*#__PURE__*/ _jsx(CustomLike, {})
1737
- }),
1738
- /*#__PURE__*/ _jsx("i", {
1739
- className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
1740
- onClick: ()=>{
1741
- disagreeMessage(item.id, item.downvoted);
1742
- //只有最后一条回答,支持发送点赞或踩
1743
- console.log(item, "dlfkvmdflkv");
1744
- if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1745
- if (!item.extraInfo && item.sender == "AI") {
1746
- console.log("AI回答2222");
1747
- //AI回答
1748
- aiSendQuestions(1, {
1749
- roomId: roomId,
1750
- message: "你给出的答案很糟糕,我不满意,踩!",
1751
- quotedMessage: "",
1752
- regenerate: false,
1753
- generateUpvoteOrDownvoteMessage: true
1754
- }, 1);
1755
- } else {
1756
- sendGreetingMessage(3);
1757
- }
1758
- }
1759
- },
1760
- children: /*#__PURE__*/ _jsx(CustomDislike, {})
1761
- })
1762
- ]
1763
- }) : ""
1764
- ]
1572
+ //引用消息
1573
+ item.quotedMessage && /*#__PURE__*/ _jsx("div", {
1574
+ className: styles.citation_content,
1575
+ children: getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
1576
+ overlayClassName: styles.popover_main_content,
1577
+ title: item.quotedMessage,
1578
+ placement: "leftTop",
1579
+ children: /*#__PURE__*/ _jsxs("p", {
1580
+ children: [
1581
+ item.quotedMessage,
1582
+ ">"
1583
+ ]
1584
+ })
1585
+ }) : /*#__PURE__*/ _jsx("p", {
1586
+ children: item.quotedMessage
1765
1587
  })
1766
- }) : "",
1588
+ }),
1589
+ //findTeacher//是否在召唤老师过程中,是否是最后一条消息
1590
+ !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && renderLastOperateBtn(item, isAiChatWindow, i),
1767
1591
  //召唤老师回答按钮
1768
- item.findTeacher ? /*#__PURE__*/ _jsx("div", {
1592
+ isAiChatWindow && item.findTeacher && userData.modules.some((item)=>item.short == "TeacherAnswer") ? /*#__PURE__*/ _jsx("div", {
1769
1593
  className: `${styles.operate_modal_bottom}`,
1770
1594
  children: /*#__PURE__*/ _jsx("p", {
1771
1595
  className: styles.stop_findTeacher,
@@ -1796,6 +1620,339 @@ const CustomerService = (props)=>{
1796
1620
  return "";
1797
1621
  }
1798
1622
  };
1623
+ //渲染相关操作按钮
1624
+ const renderOperateBtn = (item, isAiChatWindow, i)=>{
1625
+ //问候语及点赞下面不需要展示相关按钮
1626
+ let extraInfo = item.extraInfo;
1627
+ //JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
1628
+ if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'messageSource' || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'isVoteMessage') {
1629
+ return '';
1630
+ }
1631
+ return /*#__PURE__*/ _jsxs("p", {
1632
+ className: styles.operate,
1633
+ children: [
1634
+ // 不在智能客服窗口,并已经点击了召唤老师,并有召唤老师权限
1635
+ isAiChatWindow && answerMode != 1 && userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("span", {
1636
+ className: styles.ask_question,
1637
+ onClick: ()=>{
1638
+ setAnswerMode(1);
1639
+ setProblem({
1640
+ question: historyMessageList[i - 1].message,
1641
+ user: problem.user
1642
+ });
1643
+ setHistoryMessageList((historyMessageList)=>{
1644
+ let newHistoryMessageList = historyMessageList.concat({
1645
+ id: -1,
1646
+ roomId: roomId,
1647
+ sender: "AI",
1648
+ recevier: mid,
1649
+ message: "请告诉我您要召唤的老师名字",
1650
+ createdAt: getDataTime(-1),
1651
+ findTeacher: true
1652
+ });
1653
+ return newHistoryMessageList;
1654
+ });
1655
+ setTimeout(()=>{
1656
+ scrollToBottom();
1657
+ }, 200);
1658
+ },
1659
+ children: "召唤老师回答"
1660
+ }),
1661
+ /*#__PURE__*/ _jsx("i", {
1662
+ className: "yinyong_quote1",
1663
+ onClick: ()=>{
1664
+ setCitationContent({
1665
+ content: item.message,
1666
+ id: item.id
1667
+ });
1668
+ resettingBottomHei();
1669
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1670
+ console.log("引用222222");
1671
+ },
1672
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1673
+ }),
1674
+ copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1675
+ className: `tongyong-xuanzhongdui`,
1676
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1677
+ }) : /*#__PURE__*/ _jsx("i", {
1678
+ className: "fuzhi21",
1679
+ onClick: ()=>{
1680
+ let bol = copyText(item.message);
1681
+ if (bol) {
1682
+ let obj = copyTextOBJ;
1683
+ obj = obj.filter((list)=>list != item.id);
1684
+ obj.push(item.id);
1685
+ setCopyTextObj(obj);
1686
+ }
1687
+ setTimeout(()=>{
1688
+ let obj = copyTextOBJ;
1689
+ obj = obj.filter((list)=>list != item.id);
1690
+ setCopyTextObj(obj);
1691
+ }, 3000);
1692
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1693
+ },
1694
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1695
+ }),
1696
+ /*#__PURE__*/ _jsx("span", {
1697
+ children: "|"
1698
+ }),
1699
+ /*#__PURE__*/ _jsx("i", {
1700
+ className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
1701
+ onClick: ()=>{
1702
+ likeMessage(item.id, item.upvoted);
1703
+ //老师的聊天窗口中不需要点赞和踩消息
1704
+ if (!isAiChatWindow) return;
1705
+ //只有最后一条回答,支持发送点赞或踩
1706
+ if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1707
+ console.log("判断是AI还是智能回答", item);
1708
+ if (!item.extraInfo && item.sender == "AI") {
1709
+ aiSendQuestions(1, {
1710
+ roomId: roomId,
1711
+ message: "你给出的答案我非常满意,赞!",
1712
+ quotedMessage: "",
1713
+ regenerate: false,
1714
+ generateUpvoteOrDownvoteMessage: true
1715
+ }, 1);
1716
+ } else {
1717
+ console.log("AI回答2255555");
1718
+ sendGreetingMessage(2);
1719
+ }
1720
+ }
1721
+ },
1722
+ children: /*#__PURE__*/ _jsx(CustomLike, {})
1723
+ }),
1724
+ /*#__PURE__*/ _jsx("i", {
1725
+ className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
1726
+ onClick: ()=>{
1727
+ disagreeMessage(item.id, item.downvoted);
1728
+ //老师的聊天窗口中不需要点赞和踩消息
1729
+ if (!isAiChatWindow) return;
1730
+ //只有最后一条回答,支持发送点赞或踩
1731
+ if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1732
+ if (!item.extraInfo && item.sender == "AI") {
1733
+ aiSendQuestions(1, {
1734
+ roomId: roomId,
1735
+ message: "你给出的答案很糟糕,我不满意,踩!",
1736
+ quotedMessage: "",
1737
+ regenerate: false,
1738
+ generateUpvoteOrDownvoteMessage: true
1739
+ }, 1);
1740
+ } else {
1741
+ sendGreetingMessage(3);
1742
+ }
1743
+ }
1744
+ },
1745
+ children: /*#__PURE__*/ _jsx(CustomDislike, {})
1746
+ })
1747
+ ]
1748
+ });
1749
+ };
1750
+ //渲染最后一条的操作按钮
1751
+ const renderLastOperateBtn = (item, isAiChatWindow, i)=>{
1752
+ {}
1753
+ //问候语及点赞下面不需要展示相关按钮
1754
+ let extraInfo = item.extraInfo;
1755
+ //JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
1756
+ if (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'messageSource' || extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'isVoteMessage') {
1757
+ return '';
1758
+ }
1759
+ //1、是否显示停止生成按钮 finished 是否生产完成
1760
+ let showStopBtn = false;
1761
+ if (!finished && item.sender == 'AI' && item.extraInfo == null) {
1762
+ showStopBtn = true;
1763
+ }
1764
+ //2、是否展示重新生成按钮
1765
+ let regenerationBtn = false;
1766
+ if (finished && item.sender == 'AI' && item.extraInfo == null) {
1767
+ regenerationBtn = true;
1768
+ }
1769
+ //3、是否显示召唤老师回答按钮
1770
+ let findTeacherBtn = false;
1771
+ if (!showStopBtn && isAiChatWindow && (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == 'questionId' || extraInfo == null)) {
1772
+ findTeacherBtn = true;
1773
+ }
1774
+ return /*#__PURE__*/ _jsxs("div", {
1775
+ className: `${styles.operate_modal_bottom}`,
1776
+ children: [
1777
+ /*#__PURE__*/ _jsxs("p", {
1778
+ className: styles.stop_generate,
1779
+ children: [
1780
+ showStopBtn && /*#__PURE__*/ _jsxs(_Fragment, {
1781
+ children: [
1782
+ /*#__PURE__*/ _jsx("span", {
1783
+ className: styles.icon,
1784
+ onClick: ()=>{
1785
+ try {
1786
+ if (ctrl && ctrl.current) {
1787
+ ctrl.current.abort();
1788
+ }
1789
+ } catch (error) {}
1790
+ clearTimeout(receiveMessageTimer.current);
1791
+ setHistoryMessageList((historyMessageList)=>{
1792
+ return historyMessageList.filter((item)=>item.id != "123456");
1793
+ });
1794
+ setFinished(true);
1795
+ onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1796
+ }
1797
+ }),
1798
+ /*#__PURE__*/ _jsx("i", {
1799
+ onClick: ()=>{
1800
+ // aiSendQuestions(3,{},1);
1801
+ try {
1802
+ if (ctrl && ctrl.current) {
1803
+ ctrl.current.abort();
1804
+ }
1805
+ } catch (error) {}
1806
+ clearTimeout(receiveMessageTimer.current);
1807
+ setHistoryMessageList((historyMessageList)=>{
1808
+ return historyMessageList.filter((item)=>item.id != "123456");
1809
+ });
1810
+ setFinished(true);
1811
+ onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1812
+ },
1813
+ children: "停止生成"
1814
+ })
1815
+ ]
1816
+ }),
1817
+ //在ai窗口并ai已经生成完答案
1818
+ findTeacherBtn && /*#__PURE__*/ _jsx("span", {
1819
+ className: styles.find_teacher,
1820
+ onClick: ()=>{
1821
+ setAnswerMode(1);
1822
+ setProblem({
1823
+ question: historyMessageList[i - 1].message,
1824
+ user: problem.user
1825
+ });
1826
+ setHistoryMessageList((historyMessageList)=>{
1827
+ let newHistoryMessageList = historyMessageList.concat({
1828
+ id: -1,
1829
+ roomId: roomId,
1830
+ sender: "AI",
1831
+ recevier: mid,
1832
+ message: "请告诉我您要召唤的老师名字",
1833
+ createdAt: getDataTime(-1),
1834
+ findTeacher: true
1835
+ });
1836
+ return newHistoryMessageList;
1837
+ });
1838
+ setTimeout(()=>{
1839
+ scrollToBottom();
1840
+ }, 200);
1841
+ },
1842
+ children: "召唤老师回答"
1843
+ })
1844
+ ]
1845
+ }),
1846
+ /*#__PURE__*/ _jsxs("p", {
1847
+ className: `${styles.operate}`,
1848
+ children: [
1849
+ regenerationBtn && /*#__PURE__*/ _jsx("i", {
1850
+ onClick: ()=>{
1851
+ setFinished(false);
1852
+ aiSendQuestions(2, {
1853
+ roomId: roomId,
1854
+ message: historyMessageList[i - 1].message,
1855
+ quotedMessage: citationContent.content || "",
1856
+ regenerate: true,
1857
+ generateUpvoteOrDownvoteMessage: false
1858
+ }, item.id);
1859
+ onEvent(serverName + serverUrl(), "click_智能问答_重新生成", "提交");
1860
+ },
1861
+ children: /*#__PURE__*/ _jsx(CustomReloading, {})
1862
+ }),
1863
+ /*#__PURE__*/ _jsx("i", {
1864
+ className: "yinyong_quote1",
1865
+ onClick: ()=>{
1866
+ setCitationContent({
1867
+ content: item.message,
1868
+ id: item.id
1869
+ });
1870
+ resettingBottomHei();
1871
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1872
+ },
1873
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1874
+ }),
1875
+ copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
1876
+ className: `tongyong-xuanzhongdui`,
1877
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1878
+ }) : /*#__PURE__*/ _jsx("i", {
1879
+ className: "fuzhi21",
1880
+ onClick: ()=>{
1881
+ let bol = copyText(item.message);
1882
+ if (bol) {
1883
+ let obj = copyTextOBJ;
1884
+ obj = obj.filter((list)=>list != item.id);
1885
+ obj.push(item.id);
1886
+ setCopyTextObj(obj);
1887
+ }
1888
+ setTimeout(()=>{
1889
+ let obj = copyTextOBJ;
1890
+ obj = obj.filter((list)=>list != item.id);
1891
+ setCopyTextObj(obj);
1892
+ }, 3000);
1893
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1894
+ },
1895
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1896
+ }),
1897
+ /*#__PURE__*/ _jsx("span", {
1898
+ children: "|"
1899
+ }),
1900
+ /*#__PURE__*/ _jsx("i", {
1901
+ className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
1902
+ onClick: ()=>{
1903
+ likeMessage(item.id, item.upvoted);
1904
+ //老师的聊天窗口中不需要点赞和踩消息
1905
+ if (!isAiChatWindow) return;
1906
+ //只有最后一条回答,支持发送点赞或踩
1907
+ if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1908
+ console.log("判断是AI还是智能回答", item);
1909
+ if (!item.extraInfo && item.sender == "AI") {
1910
+ aiSendQuestions(1, {
1911
+ roomId: roomId,
1912
+ message: "你给出的答案我非常满意,赞!",
1913
+ quotedMessage: "",
1914
+ regenerate: false,
1915
+ generateUpvoteOrDownvoteMessage: true
1916
+ }, 1);
1917
+ } else {
1918
+ console.log("AI回答2255555");
1919
+ sendGreetingMessage(2);
1920
+ }
1921
+ }
1922
+ },
1923
+ children: /*#__PURE__*/ _jsx(CustomLike, {})
1924
+ }),
1925
+ /*#__PURE__*/ _jsx("i", {
1926
+ className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
1927
+ onClick: ()=>{
1928
+ disagreeMessage(item.id, item.downvoted);
1929
+ //老师的聊天窗口中不需要点赞和踩消息
1930
+ if (!isAiChatWindow) return;
1931
+ //只有最后一条回答,支持发送点赞或踩
1932
+ console.log(item, "dlfkvmdflkv");
1933
+ if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1934
+ if (!item.extraInfo && item.sender == "AI") {
1935
+ console.log("AI回答2222");
1936
+ //AI回答
1937
+ aiSendQuestions(1, {
1938
+ roomId: roomId,
1939
+ message: "你给出的答案很糟糕,我不满意,踩!",
1940
+ quotedMessage: "",
1941
+ regenerate: false,
1942
+ generateUpvoteOrDownvoteMessage: true
1943
+ }, 1);
1944
+ } else {
1945
+ sendGreetingMessage(3);
1946
+ }
1947
+ }
1948
+ },
1949
+ children: /*#__PURE__*/ _jsx(CustomDislike, {})
1950
+ })
1951
+ ]
1952
+ })
1953
+ ]
1954
+ });
1955
+ };
1799
1956
  //渲染底部按钮
1800
1957
  const renderBottomAnt = ()=>{
1801
1958
  let placeholder = "";
@@ -1832,6 +1989,7 @@ const CustomerService = (props)=>{
1832
1989
  setKeyWord(e.target.value);
1833
1990
  if (e.target.value == "") {
1834
1991
  setQuestionsList([]);
1992
+ setTeacherList([]);
1835
1993
  clearTimeout(timer.current);
1836
1994
  } else {
1837
1995
  clearTimeout(timer.current);
@@ -1847,7 +2005,7 @@ const CustomerService = (props)=>{
1847
2005
  },
1848
2006
  onPressEnter: (e)=>{
1849
2007
  // console.log('发送内容22222',props)
1850
- console.log(roomList, roomId, '发送内容22222wewewewewewewe');
2008
+ // console.log(roomList,roomId,'发送内容22222wewewewewewewe');
1851
2009
  if (!e.shiftKey && !e.altKey && !e.ctrlKey && keyWord.trim() != "") {
1852
2010
  e.stopPropagation();
1853
2011
  e.preventDefault();
@@ -1897,10 +2055,7 @@ const CustomerService = (props)=>{
1897
2055
  className: styles.voice,
1898
2056
  children: [
1899
2057
  voiceRecordingStatus == 1 || voiceRecordingStatus == 3 ? /*#__PURE__*/ _jsx("i", {
1900
- className: "yuyin-kai12",
1901
- style: {
1902
- color: disabled ? "rgba(0, 0, 0, 0.65)" : "rgba(0, 0, 0, 0.25)"
1903
- },
2058
+ className: `${!disabled ? styles.disabled : ''}`,
1904
2059
  onClick: ()=>{
1905
2060
  //开始录音
1906
2061
  if (!disabled) return;
@@ -1935,7 +2090,7 @@ const CustomerService = (props)=>{
1935
2090
  /*#__PURE__*/ _jsx("p", {
1936
2091
  className: `${styles.sending}`,
1937
2092
  children: /*#__PURE__*/ _jsx("i", {
1938
- className: `${!disabled ? styles.disabled : ''}`,
2093
+ className: `${!disabled || keyWord.trim() == '' ? styles.disabled : ''}`,
1939
2094
  onClick: ()=>{
1940
2095
  if (!disabled) return;
1941
2096
  setCitationContent({});
@@ -1983,10 +2138,16 @@ const CustomerService = (props)=>{
1983
2138
  //setUpdateRecords(true);
1984
2139
  setAnswerMode(-1);
1985
2140
  setChatWith(item);
1986
- createRooms(item.uid).then((res)=>{
1987
- let id = res.data.id;
1988
- setRoomId(id); //新的聊天室id
1989
- });
2141
+ let list = roomList.filter((e)=>e.sender == item.uid);
2142
+ if (list.length > 0) {
2143
+ setRoomId(list[0].roomId); //已有聊天室
2144
+ } else {
2145
+ createRooms(item.uid).then((res)=>{
2146
+ childRef.current.roomsListTimer();
2147
+ let id = res.data.id;
2148
+ setRoomId(id); //新的聊天室id
2149
+ });
2150
+ }
1990
2151
  },
1991
2152
  dangerouslySetInnerHTML: {
1992
2153
  __html: span
@@ -2002,7 +2163,6 @@ const CustomerService = (props)=>{
2002
2163
  bottom: `${buttomHei + 6}px`
2003
2164
  },
2004
2165
  children: questionsList.map((item)=>{
2005
- console.log(item, 44444444);
2006
2166
  let span = item.question.replaceAll(keyWord, ()=>{
2007
2167
  return `<span class=${styles.sign}>${keyWord}</span>`;
2008
2168
  });
@@ -2024,12 +2184,18 @@ const CustomerService = (props)=>{
2024
2184
  }
2025
2185
  };
2026
2186
  //加载指定数据,点击历史记录
2027
- const loadSpecifiedData = (renewRoomId, page, id)=>{
2187
+ const loadSpecifiedData = (renewRoomId, page, id, receiver)=>{
2188
+ if (page != 1) {
2189
+ setPageNumHistory(page);
2190
+ }
2191
+ createRooms(receiver);
2192
+ if (childRef.current) {
2193
+ childRef.current.roomsListTimer();
2194
+ }
2028
2195
  setPageNum(page);
2029
2196
  setLastId(id); //用于定位
2030
2197
  //如果是当前聊天室
2031
2198
  if (renewRoomId == roomId) {
2032
- console.log("当前聊天窗口111111");
2033
2199
  getHistoryMessage(page, 1);
2034
2200
  } else {
2035
2201
  setRoomId(renewRoomId);
@@ -2050,7 +2216,7 @@ const CustomerService = (props)=>{
2050
2216
  // maskClosable={false}
2051
2217
  rootClassName: styles.service_ChatWindow_Drawer,
2052
2218
  children: [
2053
- /*#__PURE__*/ _jsx("div", {
2219
+ showType == 1 && /*#__PURE__*/ _jsx("div", {
2054
2220
  style: {
2055
2221
  display: `${showContacts && roomId != "" ? "block" : "none"}`
2056
2222
  },
@@ -2065,7 +2231,8 @@ const CustomerService = (props)=>{
2065
2231
  },
2066
2232
  // roomIdAi={roomIdAi}
2067
2233
  switchChatRoom: switchChatRoom,
2068
- saveContactsList: saveContactsList
2234
+ saveContactsList: saveContactsList,
2235
+ ref: childRef
2069
2236
  })
2070
2237
  }),
2071
2238
  /*#__PURE__*/ _jsx("div", {
@@ -2086,7 +2253,14 @@ const CustomerService = (props)=>{
2086
2253
  alt: ""
2087
2254
  })
2088
2255
  }) : "",
2089
- renderQuestion()
2256
+ renderQuestion(),
2257
+ bottomLoading ? /*#__PURE__*/ _jsx("div", {
2258
+ className: styles.loading,
2259
+ children: /*#__PURE__*/ _jsx("img", {
2260
+ src: "/new_yun/images/loading_d.gif",
2261
+ alt: ""
2262
+ })
2263
+ }) : ""
2090
2264
  ]
2091
2265
  }),
2092
2266
  /*#__PURE__*/ _jsxs("div", {
@@ -2122,7 +2296,7 @@ const CustomerService = (props)=>{
2122
2296
  onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
2123
2297
  },
2124
2298
  centered: true,
2125
- width: 1014,
2299
+ width: window.innerWidth - 252 > 1214 ? window.innerWidth - 252 : 1214,
2126
2300
  height: window.innerHeight - 160,
2127
2301
  wrapClassName: styles.ChatWindow_Modal,
2128
2302
  footer: false,
@@ -2153,7 +2327,8 @@ const CustomerService = (props)=>{
2153
2327
  setShowContacts(false);
2154
2328
  },
2155
2329
  switchChatRoom: switchChatRoom,
2156
- saveContactsList: saveContactsList
2330
+ saveContactsList: saveContactsList,
2331
+ ref: childRef
2157
2332
  }),
2158
2333
  /*#__PURE__*/ _jsxs("div", {
2159
2334
  className: styles.chat_content,
@@ -2197,7 +2372,7 @@ const CustomerService = (props)=>{
2197
2372
  })
2198
2373
  ]
2199
2374
  }),
2200
- showType == 3 && /*#__PURE__*/ _jsxs("div", {
2375
+ showType == 3 ? /*#__PURE__*/ _jsxs("div", {
2201
2376
  className: `${styles.ChatWindow_Drawer}`,
2202
2377
  id: "",
2203
2378
  children: [
@@ -2209,7 +2384,7 @@ const CustomerService = (props)=>{
2209
2384
  /*#__PURE__*/ _jsx("div", {
2210
2385
  className: styles.user,
2211
2386
  children: /*#__PURE__*/ _jsx("p", {
2212
- children: "智能回答"
2387
+ children: roomList.filter((e)=>e.roomId == roomId).length > 0 && roomList.filter((e)=>e.roomId == roomId)[0].name != undefined ? roomList.filter((e)=>e.roomId == roomId)[0].name : '智能回答'
2213
2388
  })
2214
2389
  }),
2215
2390
  /*#__PURE__*/ _jsxs("div", {
@@ -2227,9 +2402,11 @@ const CustomerService = (props)=>{
2227
2402
  /*#__PURE__*/ _jsx("i", {
2228
2403
  onClick: ()=>{
2229
2404
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2405
+ setFirstLoad(false);
2230
2406
  setShowType(4);
2407
+ childRef.current.roomsListTimer();
2231
2408
  },
2232
- children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
2409
+ children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2233
2410
  }),
2234
2411
  /*#__PURE__*/ _jsx("i", {
2235
2412
  className: "lianxiren21",
@@ -2247,7 +2424,7 @@ const CustomerService = (props)=>{
2247
2424
  className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo}`,
2248
2425
  id: "chat_content",
2249
2426
  style: {
2250
- maxHeight: `calc(100vh-${100}-${buttomHei}px)`
2427
+ maxHeight: `${window.innerHeight - 110 - buttomHei}px)`
2251
2428
  },
2252
2429
  children: [
2253
2430
  loading ? /*#__PURE__*/ _jsx("div", {
@@ -2283,7 +2460,7 @@ const CustomerService = (props)=>{
2283
2460
  loadSpecifiedData: loadSpecifiedData,
2284
2461
  roomList: roomList
2285
2462
  }),
2286
- /*#__PURE__*/ _jsx("div", {
2463
+ showType == 3 && /*#__PURE__*/ _jsx("div", {
2287
2464
  style: {
2288
2465
  display: `${showType == 3 && showContacts && roomId != "" ? "block" : "none"}`
2289
2466
  },
@@ -2297,11 +2474,12 @@ const CustomerService = (props)=>{
2297
2474
  setShowContacts(false);
2298
2475
  },
2299
2476
  switchChatRoom: switchChatRoom,
2300
- saveContactsList: saveContactsList
2477
+ saveContactsList: saveContactsList,
2478
+ ref: childRef
2301
2479
  })
2302
2480
  })
2303
2481
  ]
2304
- }),
2482
+ }) : '',
2305
2483
  showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
2306
2484
  children: [
2307
2485
  /*#__PURE__*/ _jsxs(Modal, {
@@ -2312,7 +2490,7 @@ const CustomerService = (props)=>{
2312
2490
  onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
2313
2491
  },
2314
2492
  centered: true,
2315
- width: 1014,
2493
+ width: window.innerWidth - 252 > 1214 ? window.innerWidth - 252 : 1214,
2316
2494
  height: window.innerHeight - 160,
2317
2495
  wrapClassName: `${styles.ChatWindow_Modal}`,
2318
2496
  footer: false,
@@ -2343,7 +2521,8 @@ const CustomerService = (props)=>{
2343
2521
  setShowContacts(false);
2344
2522
  },
2345
2523
  switchChatRoom: switchChatRoom,
2346
- saveContactsList: saveContactsList
2524
+ saveContactsList: saveContactsList,
2525
+ ref: childRef
2347
2526
  }),
2348
2527
  /*#__PURE__*/ _jsxs("div", {
2349
2528
  className: styles.chat_content,
@@ -2399,7 +2578,7 @@ const CustomerService = (props)=>{
2399
2578
  /*#__PURE__*/ _jsx("div", {
2400
2579
  className: styles.user,
2401
2580
  children: /*#__PURE__*/ _jsx("p", {
2402
- children: "智能回答"
2581
+ children: roomList.filter((e)=>e.roomId == roomId).length > 0 && !roomList.filter((e)=>e.roomId == roomId)[0].name ? roomList.filter((e)=>e.roomId == roomId)[0].name : '智能回答'
2403
2582
  })
2404
2583
  }),
2405
2584
  /*#__PURE__*/ _jsxs("div", {
@@ -2418,8 +2597,9 @@ const CustomerService = (props)=>{
2418
2597
  onClick: ()=>{
2419
2598
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2420
2599
  setShowType(4);
2600
+ childRef.current.roomsListTimer();
2421
2601
  },
2422
- children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
2602
+ children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2423
2603
  }),
2424
2604
  /*#__PURE__*/ _jsx("i", {
2425
2605
  className: "lianxiren21",
@@ -2434,10 +2614,10 @@ const CustomerService = (props)=>{
2434
2614
  })
2435
2615
  }),
2436
2616
  /*#__PURE__*/ _jsxs("div", {
2437
- className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo}`,
2438
- id: "chat_content",
2617
+ className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo} ${styles.Drawer_main_newlabo_no_pic}`,
2618
+ id: "",
2439
2619
  style: {
2440
- maxHeight: `calc(100vh-${100}-${buttomHei}px)`
2620
+ maxHeight: `${window.innerHeight - 100 - buttomHei}px)`
2441
2621
  },
2442
2622
  children: [
2443
2623
  loading ? /*#__PURE__*/ _jsx("div", {
@@ -2475,7 +2655,8 @@ const CustomerService = (props)=>{
2475
2655
  setShowContacts(false);
2476
2656
  },
2477
2657
  switchChatRoom: switchChatRoom,
2478
- saveContactsList: saveContactsList
2658
+ saveContactsList: saveContactsList,
2659
+ ref: childRef
2479
2660
  })
2480
2661
  })
2481
2662
  ]