bhd-components 0.5.7 → 0.5.8

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