bhd-components 0.7.20 → 0.7.22

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.
@@ -3,7 +3,7 @@ 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
5
  import { Modal, Drawer, Input, Tooltip } from "antd";
6
- import { ViewImage } from "bhd-components";
6
+ import ViewImage from "../viewImage";
7
7
  // import html2canvas from "html2canvas";
8
8
  import cssStyle from "./index.module.less";
9
9
  import cssStyleOnline from "./index2.module.less";
@@ -16,6 +16,7 @@ import { CloseOutlined, RightOutlined, ZoomInOutlined } from "@ant-design/icons"
16
16
  import HistoryFun from "./historyFun";
17
17
  import ContactsList from "./contactsList";
18
18
  import ScreenshotTool from "./screenshotTool";
19
+ import TeacherList from "./teacherList";
19
20
  import { parseDate } from "../utils/Date";
20
21
  import { Remarkable } from "remarkable";
21
22
  import hljs from "highlight.js";
@@ -52,11 +53,11 @@ const CustomerService = (props)=>{
52
53
  const [buttomHei, setButtomHei] = useState(45); //底部输入框的高度
53
54
  const [showHistory, setShowHistory] = useState(false); //是否显示历史记录
54
55
  const [showContacts, setShowContacts] = useState(false); //是否显示老师列表
56
+ const [contactsList, setContactsList] = useState([]); //老师列表
55
57
  const [showType, setShowType] = useState(-1); //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
56
- const [answerMode, setAnswerMode] = useState(-1); //设置回答模式。1,召唤老师回答
57
- const [teacherList, setTeacherList] = useState([]); //老师列表
58
+ // const [answerMode, setAnswerMode] = useState(-1); //设置回答模式。1,召唤老师回答
59
+ // const [teacherList, setTeacherList] = useState([]); //老师列表
58
60
  const [problem, setProblem] = useState({}); //召唤老师回答的问题
59
- const [contactsList, setContactsList] = useState([]); //老师列表
60
61
  const [chatObj, setChatObj] = useState([]); //聊天记录id保存,用来在实验报告中记录
61
62
  const [keyWordProblem, setKeyWordProblem] = useState(""); //历史记录搜索的内容
62
63
  const [imgBese64, setImgBese64] = useState(""); //屏幕截图
@@ -66,6 +67,7 @@ const CustomerService = (props)=>{
66
67
  const [bottomRecommendationQuestions, setBottomRecommendationQuestions] = useState([]); //底部推荐问题
67
68
  const [showScreenshot, setShowScreenshot] = useState(false); //是否显示截图 主要用于newlabo页面
68
69
  const [saveShowType, setSaveShowType] = useState(-1); //保存截图时的状态
70
+ const [showTeacherList, setShowTeacherList] = useState(false); //是否显示召唤老师列表
69
71
  const timer = useRef(null); //文本框输入时
70
72
  let receiveMessageTimer = useRef(null); //接收ai发回的消息
71
73
  // let voiceCountdownTimer = useRef(null); //语音录制倒计时
@@ -79,6 +81,7 @@ const CustomerService = (props)=>{
79
81
  let recommendeQuestionID = useRef([]); //推荐问题id
80
82
  let videoHotQuestionsList = useRef([]); //视频热门问题
81
83
  let newHotQuestionsList = useRef([]); //视频热门问题
84
+ let newShowType = useRef(false);
82
85
  const mid = props.userData.mid;
83
86
  const remarkable = new Remarkable({
84
87
  highlight: function(str, lang) {
@@ -106,6 +109,7 @@ const CustomerService = (props)=>{
106
109
  //|| showScreenshot
107
110
  if (showType == 5 || showScreenshot) {
108
111
  try {
112
+ newShowType.current = true;
109
113
  setImgBese64('');
110
114
  // let dom = document.getElementById(screenshotAreaId);
111
115
  html2canvas(screenshotAreaId, {
@@ -122,6 +126,7 @@ const CustomerService = (props)=>{
122
126
  console.log(canvas, 99999);
123
127
  // var base64URL = canvas.toDataURL('image/jpeg')
124
128
  let base64URL = canvas.toDataURL("image/jpg", 1.0);
129
+ console.log(base64URL);
125
130
  setImgBese64(base64URL);
126
131
  });
127
132
  } catch (error) {
@@ -546,7 +551,7 @@ const CustomerService = (props)=>{
546
551
  });
547
552
  };
548
553
  //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
549
- const sendToTeacher = (type)=>{
554
+ const sendToTeacher = (type, message = '')=>{
550
555
  console.log("消息发送给老师111");
551
556
  let obj = {};
552
557
  if (type == 1) {
@@ -556,8 +561,11 @@ const CustomerService = (props)=>{
556
561
  recevier: chatWith.uid,
557
562
  message: problem.question
558
563
  };
564
+ if (problem.url) {
565
+ obj.image = problem.url;
566
+ }
559
567
  setProblem({});
560
- } else if (type == 2) {
568
+ } else if (type == 2 || type == 3) {
561
569
  let list = contactsList.filter((item)=>item.roomId == roomId);
562
570
  let recevier = "";
563
571
  if (list.length > 0) {
@@ -567,9 +575,13 @@ const CustomerService = (props)=>{
567
575
  roomId: roomId,
568
576
  sender: mid,
569
577
  recevier: recevier,
570
- message: keyWord,
578
+ message: type == 2 ? keyWord : message,
571
579
  quotedMessage: citationContent.content || ""
572
580
  };
581
+ if (screenshotBese64) {
582
+ obj.image = screenshotBese64;
583
+ setScreenshotBese64("");
584
+ }
573
585
  }
574
586
  http.post(`${urllocation}/chat-service/public/v1.0/chat-with-user/messages`, obj).then((res)=>{
575
587
  if (res.data.id) {
@@ -580,7 +592,13 @@ const CustomerService = (props)=>{
580
592
  id: res.data.id,
581
593
  upvoted: false,
582
594
  downvoted: false,
583
- createdAt: getDataTime(-1)
595
+ createdAt: getDataTime(-1),
596
+ extraInfo: obj.image ? JSON.stringify([
597
+ {
598
+ key: "imageUrl",
599
+ value: obj.image
600
+ }
601
+ ]) : null
584
602
  }));
585
603
  return newHistoryMessageList;
586
604
  });
@@ -780,11 +798,9 @@ const CustomerService = (props)=>{
780
798
  ctrl.current = new AbortController();
781
799
  clearTimeout(receiveMessageTimer.current);
782
800
  receiveMessageTimer.current = setTimeout(()=>{
783
- // setHistoryMessageList((historyMessageList) => {
784
- // return historyMessageList.filter(
785
- // (item) => item.id != "123456" && item.id != "654321"
786
- // );
787
- // });
801
+ setHistoryMessageList((historyMessageList)=>{
802
+ return historyMessageList.filter((item)=>item.id != "123456");
803
+ });
788
804
  setFinished(true);
789
805
  ctrl.current.abort();
790
806
  setHistoryMessageList((historyMessageList)=>{
@@ -792,7 +808,7 @@ const CustomerService = (props)=>{
792
808
  roomId: roomId,
793
809
  sender: "AI",
794
810
  recevier: mid,
795
- message: "网络异常,请稍后重试!",
811
+ message: "AI助手繁忙,请稍后再提问或",
796
812
  id: "123456",
797
813
  createdAt: getDataTime(-1),
798
814
  extraInfo: null
@@ -1177,11 +1193,9 @@ const CustomerService = (props)=>{
1177
1193
  if (problem != undefined && problem.user != undefined && problem.question != undefined) {
1178
1194
  sendToTeacher(1);
1179
1195
  }
1180
- // if(flag == 1){
1181
1196
  setTimeout(()=>{
1182
1197
  setKeyWordProblem('');
1183
1198
  }, 3100);
1184
- // }
1185
1199
  } else {
1186
1200
  setPageCount(0);
1187
1201
  setBottomLoading(false);
@@ -1211,8 +1225,9 @@ const CustomerService = (props)=>{
1211
1225
  roomMessage.current = setTimeout(()=>{
1212
1226
  getRoomidHistoryMessage(totalNumber, rid);
1213
1227
  }, 5000);
1214
- if (rid == "") return;
1215
- // console.log(roomList,2222222);
1228
+ // console.log(showType, imgBese64,showScreenshot,newShowType.current,9999999);
1229
+ //newShowType.current 截图中,不循环
1230
+ if (rid == "" || newShowType.current) return;
1216
1231
  return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
1217
1232
  params: {
1218
1233
  roomId: rid,
@@ -1470,19 +1485,6 @@ const CustomerService = (props)=>{
1470
1485
  }
1471
1486
  }
1472
1487
  };
1473
- //获取老师列表
1474
- const getTeacherList = (keyWord)=>{
1475
- http.get(`${urllocation}/chat-service/public/v1.0/teachers`, {
1476
- params: {
1477
- name: keyWord
1478
- }
1479
- }).then((res)=>{
1480
- console.log(res);
1481
- if (res.data) {
1482
- setTeacherList(res.data.teachers);
1483
- }
1484
- });
1485
- };
1486
1488
  //获取聊天室列表
1487
1489
  const roomsListTimer = ()=>{
1488
1490
  if (chatRoomList != null) clearTimeout(chatRoomList.current);
@@ -1865,18 +1867,22 @@ const CustomerService = (props)=>{
1865
1867
  // code = code[1];
1866
1868
  // console.log(code,888888888);
1867
1869
  if (lastId == item.id && keyWordProblem != '') {
1868
- message = remarkable.render(message);
1870
+ //点击历史记录时,找到关键字,防止关键字和标签名重复
1871
+ let key_sign = 'sign_' + new Date().getTime();
1872
+ +'sign';
1869
1873
  message = message.replaceAll(keyWordProblem, (e)=>{
1870
- return `<span class=${styles.sign}>${e}</span>`;
1874
+ return key_sign;
1875
+ });
1876
+ message = remarkable.render(message);
1877
+ message = message.replaceAll(key_sign, (e)=>{
1878
+ return `<span class=${styles.sign}>${keyWordProblem}</span>`;
1871
1879
  });
1872
1880
  } else {
1873
1881
  message = remarkable.render(message);
1874
1882
  }
1875
1883
  let position = 0;
1876
1884
  message = message.replaceAll(new RegExp(`<pre`, 'ig'), (i, index)=>{
1877
- //copyText(${item.message,2,position})
1878
1885
  position++;
1879
- // console.log(i,index,onClick={copyText} ,'skdcnsdjk')
1880
1886
  let text = `<p class='${styles.copyCode} copyCodeFun' data-id=${item.id} data-position=${position}>
1881
1887
  <span class='${styles.icon} copy' >
1882
1888
  <svg
@@ -2027,7 +2033,7 @@ const CustomerService = (props)=>{
2027
2033
  ]
2028
2034
  })
2029
2035
  }),
2030
- showType == 2 || showType == 4 ? /*#__PURE__*/ _jsx("div", {
2036
+ (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2031
2037
  className: styles.head_sculpture,
2032
2038
  style: {
2033
2039
  marginLeft: "12px"
@@ -2035,7 +2041,7 @@ const CustomerService = (props)=>{
2035
2041
  children: /*#__PURE__*/ _jsx("img", {
2036
2042
  src: userData.avatar
2037
2043
  })
2038
- }) : ""
2044
+ })
2039
2045
  ]
2040
2046
  }, item.id)
2041
2047
  ]
@@ -2094,12 +2100,33 @@ const CustomerService = (props)=>{
2094
2100
  /*#__PURE__*/ _jsxs("div", {
2095
2101
  className: styles.content,
2096
2102
  children: [
2097
- /*#__PURE__*/ _jsx("p", {
2103
+ item.message != 'AI助手繁忙,请稍后再提问或' && /*#__PURE__*/ _jsx("p", {
2098
2104
  dangerouslySetInnerHTML: {
2099
2105
  __html: message
2100
2106
  },
2101
2107
  className: styles.content_child
2102
2108
  }),
2109
+ item.message == 'AI助手繁忙,请稍后再提问或' && /*#__PURE__*/ _jsxs("p", {
2110
+ children: [
2111
+ "AI助手繁忙,请稍后再提问或",
2112
+ /*#__PURE__*/ _jsx("span", {
2113
+ className: styles.find_teacher_con,
2114
+ onClick: ()=>{
2115
+ let extraInfo = historyMessageList[i - 1].extraInfo;
2116
+ let url = '';
2117
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2118
+ url = JSON.parse(extraInfo)[0].value;
2119
+ }
2120
+ setProblem({
2121
+ question: historyMessageList[i - 1].message,
2122
+ url
2123
+ });
2124
+ setShowTeacherList(true);
2125
+ },
2126
+ children: "召唤老师回答"
2127
+ })
2128
+ ]
2129
+ }),
2103
2130
  item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2104
2131
  className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ''}`,
2105
2132
  children: [
@@ -2145,24 +2172,7 @@ const CustomerService = (props)=>{
2145
2172
  ]
2146
2173
  }),
2147
2174
  //findTeacher//是否在召唤老师过程中,是否是最后一条消息
2148
- !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != '123456_date' && renderLastOperateBtn(item, isAiChatWindow, i),
2149
- //召唤老师回答按钮
2150
- isAiChatWindow && item.findTeacher && userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("div", {
2151
- className: `${styles.operate_modal_bottom} `,
2152
- children: /*#__PURE__*/ _jsx("p", {
2153
- className: styles.stop_findTeacher,
2154
- children: /*#__PURE__*/ _jsx("span", {
2155
- onClick: ()=>{
2156
- setAnswerMode(-1);
2157
- setTeacherList([]);
2158
- setHistoryMessageList((historyMessageList)=>{
2159
- return historyMessageList.filter((item)=>item.id != "-1");
2160
- });
2161
- },
2162
- children: "停止召唤老师"
2163
- })
2164
- })
2165
- })
2175
+ !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != '123456_date' && renderLastOperateBtn(item, isAiChatWindow, i)
2166
2176
  ]
2167
2177
  })
2168
2178
  ]
@@ -2208,50 +2218,24 @@ const CustomerService = (props)=>{
2208
2218
  if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "messageSource" || extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "isVoteMessage") {
2209
2219
  return "";
2210
2220
  }
2211
- // console.log(historyMessageList,i,'sdcsd;sldcscsdsd')
2212
- //根据上一行数据,判断是否显示招唤老师按钮
2213
- let showTeacherBtn = true;
2214
- let previousLineData = historyMessageList[i - 1];
2215
- if (!previousLineData) {
2216
- showTeacherBtn = true;
2217
- } else if (!previousLineData.extraInfo) {
2218
- showTeacherBtn = true;
2219
- } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2220
- showTeacherBtn = false;
2221
- }
2222
2221
  return /*#__PURE__*/ _jsxs("p", {
2223
2222
  className: styles.operate,
2224
2223
  children: [
2225
2224
  // 不在智能客服窗口,并已经点击了召唤老师,并有召唤老师权限
2226
- isAiChatWindow && answerMode != 1 && userData.modules.some((item)=>item.short == "TeacherAnswer") && showTeacherBtn && /*#__PURE__*/ _jsx("span", {
2225
+ isAiChatWindow && userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("span", {
2227
2226
  className: styles.ask_question,
2228
2227
  onClick: ()=>{
2229
- setAnswerMode(1);
2228
+ console.log(historyMessageList[i - 1], 4444444);
2229
+ let extraInfo = historyMessageList[i - 1].extraInfo;
2230
+ let url = '';
2231
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2232
+ url = JSON.parse(extraInfo)[0].value;
2233
+ }
2230
2234
  setProblem({
2231
2235
  question: historyMessageList[i - 1].message,
2232
- user: problem.user
2236
+ url
2233
2237
  });
2234
- setHistoryMessageList((historyMessageList)=>{
2235
- let newHistoryMessageList = historyMessageList.concat({
2236
- id: -1,
2237
- roomId: roomId,
2238
- sender: "AI",
2239
- recevier: mid,
2240
- message: "请告诉我您要召唤的老师名字",
2241
- createdAt: getDataTime(-1),
2242
- findTeacher: true,
2243
- extraInfo: item.extraInfo == null ? null : JSON.stringify([
2244
- {
2245
- key: "questionId",
2246
- value: "questionId"
2247
- }
2248
- ])
2249
- });
2250
- return newHistoryMessageList;
2251
- });
2252
- setTimeout(()=>{
2253
- scrollToBottom();
2254
- }, 200);
2238
+ setShowTeacherList(true);
2255
2239
  },
2256
2240
  children: "召唤老师回答"
2257
2241
  }),
@@ -2264,7 +2248,6 @@ const CustomerService = (props)=>{
2264
2248
  });
2265
2249
  resettingBottomHei();
2266
2250
  onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
2267
- console.log("引用222222");
2268
2251
  },
2269
2252
  children: /*#__PURE__*/ _jsx(CustomQuote, {})
2270
2253
  }),
@@ -2301,7 +2284,6 @@ const CustomerService = (props)=>{
2301
2284
  if (!isAiChatWindow) return;
2302
2285
  //只有最后一条回答,支持发送点赞或踩
2303
2286
  if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
2304
- console.log("判断是AI还是智能问答", item);
2305
2287
  if (!item.extraInfo && item.sender == "AI") {
2306
2288
  aiSendQuestions(1, {
2307
2289
  roomId: roomId,
@@ -2311,7 +2293,6 @@ const CustomerService = (props)=>{
2311
2293
  generateUpvoteOrDownvoteMessage: true
2312
2294
  }, 1);
2313
2295
  } else {
2314
- console.log("AI回答2255555");
2315
2296
  sendGreetingMessage(2);
2316
2297
  }
2317
2298
  }
@@ -2369,17 +2350,6 @@ const CustomerService = (props)=>{
2369
2350
  if (!showStopBtn && isAiChatWindow && (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "questionId" || extraInfo == null)) {
2370
2351
  findTeacherBtn = true;
2371
2352
  }
2372
- //根据上一行数据,判断是否显示招唤老师按钮
2373
- let showTeacherBtn = true;
2374
- let previousLineData = historyMessageList[i - 1];
2375
- if (!previousLineData) {
2376
- showTeacherBtn = true;
2377
- } else if (!previousLineData.extraInfo) {
2378
- showTeacherBtn = true;
2379
- } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2380
- showTeacherBtn = false;
2381
- }
2382
- /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2383
2353
  return /*#__PURE__*/ _jsxs("div", {
2384
2354
  className: `${styles.operate_modal_bottom}`,
2385
2355
  children: [
@@ -2424,35 +2394,19 @@ const CustomerService = (props)=>{
2424
2394
  ]
2425
2395
  }),
2426
2396
  //在ai窗口并ai已经生成完答案
2427
- findTeacherBtn && userData.modules.some((item)=>item.short == "TeacherAnswer") && showTeacherBtn && /*#__PURE__*/ _jsx("span", {
2397
+ findTeacherBtn && userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("span", {
2428
2398
  className: styles.find_teacher,
2429
2399
  onClick: ()=>{
2430
- setAnswerMode(1);
2400
+ let extraInfo = historyMessageList[i - 1].extraInfo;
2401
+ let url = '';
2402
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2403
+ url = JSON.parse(extraInfo)[0].value;
2404
+ }
2431
2405
  setProblem({
2432
2406
  question: historyMessageList[i - 1].message,
2433
- user: problem.user
2434
- });
2435
- setHistoryMessageList((historyMessageList)=>{
2436
- let newHistoryMessageList = historyMessageList.concat({
2437
- id: -1,
2438
- roomId: roomId,
2439
- sender: "AI",
2440
- recevier: mid,
2441
- message: "请告诉我您要召唤的老师名字",
2442
- createdAt: getDataTime(-1),
2443
- findTeacher: true,
2444
- extraInfo: item.extraInfo == null ? null : JSON.stringify([
2445
- {
2446
- key: "questionId",
2447
- value: "questionId"
2448
- }
2449
- ])
2450
- });
2451
- return newHistoryMessageList;
2407
+ url
2452
2408
  });
2453
- setTimeout(()=>{
2454
- scrollToBottom();
2455
- }, 200);
2409
+ setShowTeacherList(true);
2456
2410
  },
2457
2411
  children: "召唤老师回答"
2458
2412
  })
@@ -2598,6 +2552,44 @@ const CustomerService = (props)=>{
2598
2552
  }
2599
2553
  }
2600
2554
  };
2555
+ //发送截图信息
2556
+ const sendScreenshotData = (message)=>{
2557
+ if (contactsList.length > 0 && contactsList[0].roomId == roomId) {
2558
+ setHistoryMessageList((historyMessageList)=>{
2559
+ let newHistoryMessageList = historyMessageList.concat({
2560
+ id: 'p' + new Date().getTime(),
2561
+ roomId: roomId,
2562
+ sender: mid,
2563
+ recevier: 'AI',
2564
+ message: message,
2565
+ createdAt: getDataTime(-1),
2566
+ extraInfo: JSON.stringify([
2567
+ {
2568
+ key: "imageUrl",
2569
+ value: screenshotBese64
2570
+ }
2571
+ ])
2572
+ });
2573
+ return newHistoryMessageList;
2574
+ });
2575
+ //ai窗口
2576
+ aiSendQuestions(3, {
2577
+ //相关数据
2578
+ roomId: roomId,
2579
+ message: message,
2580
+ image: screenshotBese64,
2581
+ quotedMessage: citationContent.content || "",
2582
+ regenerate: citationContent.content != "" ? false : true,
2583
+ generateUpvoteOrDownvoteMessage: false
2584
+ }, 1);
2585
+ setScreenshotBese64('');
2586
+ } else {
2587
+ //老师窗口
2588
+ sendToTeacher(3, message);
2589
+ }
2590
+ scrollToBottom();
2591
+ resettingBottomHei();
2592
+ };
2601
2593
  //渲染底部按钮
2602
2594
  const renderBottomAnt = ()=>{
2603
2595
  let placeholder = "";
@@ -2655,35 +2647,7 @@ const CustomerService = (props)=>{
2655
2647
  children: [
2656
2648
  /*#__PURE__*/ _jsxs("p", {
2657
2649
  onClick: ()=>{
2658
- setHistoryMessageList((historyMessageList)=>{
2659
- let newHistoryMessageList = historyMessageList.concat({
2660
- id: 'p' + new Date().getTime(),
2661
- roomId: roomId,
2662
- sender: mid,
2663
- recevier: 'AI',
2664
- message: "讲解这张图片涉及到的知识内容",
2665
- createdAt: getDataTime(-1),
2666
- extraInfo: JSON.stringify([
2667
- {
2668
- key: "imageUrl",
2669
- value: screenshotBese64
2670
- }
2671
- ])
2672
- });
2673
- return newHistoryMessageList;
2674
- });
2675
- scrollToBottom();
2676
- aiSendQuestions(3, {
2677
- //相关数据
2678
- roomId: roomId,
2679
- message: '讲解这张图片涉及到的知识内容',
2680
- image: screenshotBese64,
2681
- quotedMessage: citationContent.content || "",
2682
- regenerate: citationContent.content != "" ? false : true,
2683
- generateUpvoteOrDownvoteMessage: false
2684
- }, 1);
2685
- setScreenshotBese64('');
2686
- resettingBottomHei();
2650
+ sendScreenshotData('讲解这张图片涉及到的知识内容');
2687
2651
  },
2688
2652
  children: [
2689
2653
  /*#__PURE__*/ _jsx(CustomKnowledgeContent, {}),
@@ -2693,35 +2657,7 @@ const CustomerService = (props)=>{
2693
2657
  /*#__PURE__*/ _jsx("br", {}),
2694
2658
  /*#__PURE__*/ _jsxs("p", {
2695
2659
  onClick: ()=>{
2696
- setHistoryMessageList((historyMessageList)=>{
2697
- let newHistoryMessageList = historyMessageList.concat({
2698
- id: 'p' + new Date().getTime(),
2699
- roomId: roomId,
2700
- sender: mid,
2701
- recevier: 'AI',
2702
- message: "帮助我更深入地理解图片中的概念",
2703
- createdAt: getDataTime(-1),
2704
- extraInfo: JSON.stringify([
2705
- {
2706
- key: "imageUrl",
2707
- value: screenshotBese64
2708
- }
2709
- ])
2710
- });
2711
- return newHistoryMessageList;
2712
- });
2713
- scrollToBottom();
2714
- aiSendQuestions(3, {
2715
- //相关数据
2716
- roomId: roomId,
2717
- message: '帮助我更深入地理解图片中的概念',
2718
- image: screenshotBese64,
2719
- quotedMessage: citationContent.content || "",
2720
- regenerate: citationContent.content != "" ? false : true,
2721
- generateUpvoteOrDownvoteMessage: false
2722
- }, 1);
2723
- setScreenshotBese64('');
2724
- resettingBottomHei();
2660
+ sendScreenshotData('帮助我更深入地理解图片中的概念');
2725
2661
  },
2726
2662
  children: [
2727
2663
  /*#__PURE__*/ _jsx(CustomWenhaoRound, {}),
@@ -2743,22 +2679,14 @@ const CustomerService = (props)=>{
2743
2679
  setKeyWord(e.target.value);
2744
2680
  if (e.target.value == "") {
2745
2681
  setQuestionsList([]);
2746
- setTeacherList([]);
2747
2682
  clearTimeout(timer.current);
2748
2683
  } else {
2749
2684
  clearTimeout(timer.current);
2750
2685
  timer.current = setTimeout(()=>{
2751
- if (answerMode == 1) {
2752
- getTeacherList(String(e.target.value));
2686
+ if (config && config.type == 'video') {
2687
+ getQuestiionsList(String(e.target.value), 3);
2753
2688
  } else {
2754
- let roomList = contactsList;
2755
- if (roomList.length > 0 && roomList[0].roomId != roomId) return;
2756
- console.log(props, 333333);
2757
- if (config && config.type == 'video') {
2758
- getQuestiionsList(String(e.target.value), 3);
2759
- } else {
2760
- getQuestiionsList(String(e.target.value), 2);
2761
- }
2689
+ getQuestiionsList(String(e.target.value), 2);
2762
2690
  }
2763
2691
  }, 1000);
2764
2692
  }
@@ -2775,40 +2703,21 @@ const CustomerService = (props)=>{
2775
2703
  setKeyWord("");
2776
2704
  setCitationContent({});
2777
2705
  setBottomRecommendationQuestions([]);
2778
- resettingBottomHei();
2779
- //查找是否是召唤老师回答并有相应的老师名称
2780
- if (answerMode == 1 && teacherList.length > 0) {
2781
- let list = teacherList.filter((v)=>v.name == keyWord.trim());
2782
- if (list.length > 0) {
2783
- //直接进入召唤老师回答模式
2784
- enterTeacherChat(list[0]);
2785
- setButtomHei(45);
2786
- return;
2787
- }
2788
- }
2789
2706
  //跟老师对话
2790
- let roomList = contactsList;
2791
- if (roomList.length > 0 && roomList[0].roomId != roomId) {
2707
+ if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
2792
2708
  sendToTeacher(2);
2793
2709
  } else {
2794
2710
  setFinished(false);
2795
- clearTimeout(timer.current);
2796
2711
  setQuestionsList([]);
2797
- setAnswerMode(-1);
2798
- setTeacherList([]);
2799
- setTimeout(()=>{
2800
- setQuestionsList([]);
2801
- setTeacherList([]);
2802
- clearTimeout(timer.current);
2803
- }, 200);
2804
- setHistoryMessageList((historyMessageList)=>{
2805
- return historyMessageList.filter((item)=>item.id != "-1");
2806
- });
2807
2712
  sendMessage("", 0);
2808
2713
  }
2714
+ setTimeout(()=>{
2715
+ setQuestionsList([]);
2716
+ clearTimeout(timer.current);
2717
+ }, 200);
2718
+ resettingBottomHei();
2809
2719
  setButtomHei(45);
2810
2720
  } else {
2811
- console.log("回车事件");
2812
2721
  resettingBottomHei();
2813
2722
  }
2814
2723
  },
@@ -2842,7 +2751,7 @@ const CustomerService = (props)=>{
2842
2751
  })
2843
2752
  ]
2844
2753
  }),
2845
- userData.modules.some((item)=>item.short == "AIservice") && contactsList.length > 0 && contactsList[0].roomId == roomId && /*#__PURE__*/ _jsx("p", {
2754
+ (userData.modules.some((item)=>item.short == "AIservice") || contactsList.length > 0 && contactsList[0].roomId !== roomId) && /*#__PURE__*/ _jsx("p", {
2846
2755
  className: styles.screenshot,
2847
2756
  children: /*#__PURE__*/ _jsx("i", {
2848
2757
  className: `${!finished ? styles.disabled : ""}`,
@@ -2869,36 +2778,20 @@ const CustomerService = (props)=>{
2869
2778
  setCitationContent({});
2870
2779
  setButtomHei(45);
2871
2780
  if (keyWord.trim() != "") {
2872
- //查找是否是召唤老师回答并有相应的老师名称
2873
- if (answerMode == 1 && teacherList.length > 0) {
2874
- let list = teacherList.filter((v)=>v.name == keyWord.trim());
2875
- if (list.length > 0) {
2876
- //直接进入召唤老师回答模式
2877
- enterTeacherChat(list[0]);
2878
- setButtomHei(45);
2879
- return;
2880
- }
2881
- }
2882
2781
  setKeyWord("");
2883
2782
  //跟老师对话
2884
- let roomList = contactsList;
2885
- if (roomList.length > 0 && roomList[0].roomId != roomId) {
2783
+ if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
2886
2784
  sendToTeacher(2);
2887
2785
  } else {
2888
2786
  clearTimeout(timer.current);
2889
2787
  setQuestionsList([]);
2890
- setAnswerMode(-1);
2891
- setTeacherList([]);
2892
- setTimeout(()=>{
2893
- setQuestionsList([]);
2894
- setTeacherList([]);
2895
- clearTimeout(timer.current);
2896
- }, 200);
2897
- setHistoryMessageList((historyMessageList)=>{
2898
- return historyMessageList.filter((item)=>item.id != "-1");
2899
- });
2900
2788
  sendMessage("", 0);
2901
2789
  }
2790
+ resettingBottomHei();
2791
+ setTimeout(()=>{
2792
+ setQuestionsList([]);
2793
+ clearTimeout(timer.current);
2794
+ }, 200);
2902
2795
  onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
2903
2796
  }
2904
2797
  },
@@ -2910,15 +2803,12 @@ const CustomerService = (props)=>{
2910
2803
  };
2911
2804
  //进入与老师的聊天
2912
2805
  const enterTeacherChat = (item)=>{
2913
- setTeacherList([]);
2806
+ setShowTeacherList(false);
2914
2807
  //提问的问题
2915
- setProblem({
2808
+ setProblem(_object_spread_props(_object_spread({}, problem), {
2916
2809
  question: problem.question,
2917
2810
  user: item.uid
2918
- });
2919
- setKeyWord("");
2920
- //setUpdateRecords(true);
2921
- setAnswerMode(-1);
2811
+ }));
2922
2812
  setChatWith(item);
2923
2813
  let roomList = contactsList;
2924
2814
  let list = roomList.filter((e)=>e.sender == item.uid);
@@ -2927,7 +2817,6 @@ const CustomerService = (props)=>{
2927
2817
  setRoomId(list[0].roomId); //已有聊天室
2928
2818
  } else {
2929
2819
  createRooms(item.uid).then((res)=>{
2930
- // childRef.current.roomsListTimer();
2931
2820
  roomsListTimer();
2932
2821
  let id = res.data.id;
2933
2822
  setRoomId(id); //新的聊天室id
@@ -2936,80 +2825,45 @@ const CustomerService = (props)=>{
2936
2825
  };
2937
2826
  //渲染联想问题及联想的老师名称
2938
2827
  const renderAssociationProblem = ()=>{
2939
- if (answerMode == 1) {
2940
- return /*#__PURE__*/ _jsx("div", {
2941
- className: `${styles.issues_list} ${styles.issues_list_teacherList}`,
2942
- style: {
2943
- bottom: `${buttomHei + 14}px`
2944
- },
2945
- children: teacherList.map((item)=>{
2946
- let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2947
- let span = '';
2948
- //搜索内容是否有特殊字符
2949
- if (reg.test(keyWord)) {
2950
- span = item.name.replaceAll(keyWord, (e)=>{
2951
- return `<span class=${styles.sign}>${e}</span>`;
2952
- });
2953
- } else {
2954
- span = item.name.replaceAll(new RegExp(keyWord, "ig"), (i)=>{
2955
- // console.log(i,'skdcnsdjk')
2956
- return `<span class=${styles.sign}>${i}</span>`;
2957
- });
2958
- }
2828
+ return /*#__PURE__*/ _jsx("div", {
2829
+ className: styles.issues_list,
2830
+ style: {
2831
+ bottom: `${buttomHei + 6}px`
2832
+ },
2833
+ children: questionsList.map((item, i)=>{
2834
+ if (i > 4) return '';
2835
+ let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2836
+ let span = '';
2837
+ //搜索内容是否有特殊字符
2838
+ if (reg.test(keyWord)) {
2839
+ span = item.question.replaceAll(keyWord, (e)=>{
2840
+ return `<span class=${styles.sign}>${e}</span>`;
2841
+ });
2842
+ } else {
2843
+ span = item.question.replaceAll(new RegExp(keyWord, "ig"), (i)=>{
2844
+ // console.log(i,'skdcnsdjk')
2845
+ return `<span class=${styles.sign}>${i}</span>`;
2846
+ });
2847
+ }
2848
+ if (userData.modules.some((item)=>item.short == "AIservice") || item.answer) {
2959
2849
  return /*#__PURE__*/ _jsx("p", {
2960
2850
  className: styles.item,
2961
2851
  children: /*#__PURE__*/ _jsx("span", {
2962
2852
  onClick: ()=>{
2963
- enterTeacherChat(item);
2853
+ sendMessage(item, 2, 'AssociativeProblem');
2854
+ setKeyWord("");
2855
+ onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
2964
2856
  },
2965
2857
  dangerouslySetInnerHTML: {
2966
2858
  __html: span
2967
2859
  }
2968
2860
  })
2969
2861
  });
2970
- })
2971
- });
2972
- } else {
2973
- return /*#__PURE__*/ _jsx("div", {
2974
- className: styles.issues_list,
2975
- style: {
2976
- bottom: `${buttomHei + 6}px`
2977
- },
2978
- children: questionsList.map((item, i)=>{
2979
- if (i > 4) return '';
2980
- let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2981
- let span = '';
2982
- //搜索内容是否有特殊字符
2983
- if (reg.test(keyWord)) {
2984
- span = item.question.replaceAll(keyWord, (e)=>{
2985
- return `<span class=${styles.sign}>${e}</span>`;
2986
- });
2987
- } else {
2988
- span = item.question.replaceAll(new RegExp(keyWord, "ig"), (i)=>{
2989
- // console.log(i,'skdcnsdjk')
2990
- return `<span class=${styles.sign}>${i}</span>`;
2991
- });
2992
- }
2993
- if (userData.modules.some((item)=>item.short == "AIservice") || item.answer) {
2994
- return /*#__PURE__*/ _jsx("p", {
2995
- className: styles.item,
2996
- children: /*#__PURE__*/ _jsx("span", {
2997
- onClick: ()=>{
2998
- sendMessage(item, 2, 'AssociativeProblem');
2999
- setKeyWord("");
3000
- onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
3001
- },
3002
- dangerouslySetInnerHTML: {
3003
- __html: span
3004
- }
3005
- })
3006
- });
3007
- } else {
3008
- return null;
3009
- }
3010
- })
3011
- });
3012
- }
2862
+ } else {
2863
+ return null;
2864
+ }
2865
+ })
2866
+ });
3013
2867
  };
3014
2868
  //视频页面底部推荐问题
3015
2869
  const renderBottomAssociationProblem = ()=>{
@@ -3109,7 +2963,7 @@ const CustomerService = (props)=>{
3109
2963
  mask: false,
3110
2964
  rootClassName: styles.service_ChatWindow_Drawer,
3111
2965
  children: [
3112
- showType == 1 && /*#__PURE__*/ _jsx("div", {
2966
+ showType == 1 && !showScreenshot && /*#__PURE__*/ _jsx("div", {
3113
2967
  style: {
3114
2968
  display: `${showContacts && roomId != "" ? "block" : "none"}`
3115
2969
  },
@@ -3181,6 +3035,16 @@ const CustomerService = (props)=>{
3181
3035
  setShowHistory(false);
3182
3036
  },
3183
3037
  loadSpecifiedData: loadSpecifiedData
3038
+ }),
3039
+ showType == 1 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3040
+ type: showType,
3041
+ userData: userData,
3042
+ http: http,
3043
+ urllocation: urllocation,
3044
+ onClose: ()=>{
3045
+ setShowTeacherList(false);
3046
+ },
3047
+ enterTeacherChat: enterTeacherChat
3184
3048
  })
3185
3049
  ]
3186
3050
  }),
@@ -3268,6 +3132,16 @@ const CustomerService = (props)=>{
3268
3132
  setShowHistory(false);
3269
3133
  },
3270
3134
  loadSpecifiedData: loadSpecifiedData
3135
+ }),
3136
+ showType == 2 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3137
+ type: showType,
3138
+ userData: userData,
3139
+ http: http,
3140
+ urllocation: urllocation,
3141
+ onClose: ()=>{
3142
+ setShowTeacherList(false);
3143
+ },
3144
+ enterTeacherChat: enterTeacherChat
3271
3145
  })
3272
3146
  ]
3273
3147
  })
@@ -3365,6 +3239,16 @@ const CustomerService = (props)=>{
3365
3239
  },
3366
3240
  loadSpecifiedData: loadSpecifiedData
3367
3241
  }),
3242
+ showType == 3 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3243
+ type: showType,
3244
+ userData: userData,
3245
+ http: http,
3246
+ urllocation: urllocation,
3247
+ onClose: ()=>{
3248
+ setShowTeacherList(false);
3249
+ },
3250
+ enterTeacherChat: enterTeacherChat
3251
+ }),
3368
3252
  showType == 3 && /*#__PURE__*/ _jsx("div", {
3369
3253
  style: {
3370
3254
  display: `${showType == 3 && showContacts && roomId != "" ? "block" : "none"}`
@@ -3472,6 +3356,16 @@ const CustomerService = (props)=>{
3472
3356
  setShowHistory(false);
3473
3357
  },
3474
3358
  loadSpecifiedData: loadSpecifiedData
3359
+ }),
3360
+ showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3361
+ type: showType,
3362
+ userData: userData,
3363
+ http: http,
3364
+ urllocation: urllocation,
3365
+ onClose: ()=>{
3366
+ setShowTeacherList(false);
3367
+ },
3368
+ enterTeacherChat: enterTeacherChat
3475
3369
  })
3476
3370
  ]
3477
3371
  })
@@ -3579,6 +3473,7 @@ const CustomerService = (props)=>{
3579
3473
  (showType == 5 || showScreenshot) && imgBese64 && /*#__PURE__*/ _jsx(ScreenshotTool, {
3580
3474
  imgBese64: imgBese64,
3581
3475
  saveScreenshotBese64: (base64)=>{
3476
+ newShowType.current = false;
3582
3477
  setScreenshotBese64(base64);
3583
3478
  if (saveShowType != -1) {
3584
3479
  setShowType(saveShowType);
@@ -3588,6 +3483,7 @@ const CustomerService = (props)=>{
3588
3483
  setShowScreenshot(false);
3589
3484
  },
3590
3485
  cancelScreenshot: ()=>{
3486
+ newShowType.current = false;
3591
3487
  if (saveShowType != -1) {
3592
3488
  setShowType(saveShowType);
3593
3489
  } else {