bhd-components 0.7.19 → 0.7.21

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.
@@ -5,7 +5,7 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
5
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
6
6
  import React, { useEffect, useState, useRef } from "react";
7
7
  import { Modal, Drawer, Input, Tooltip } from "antd";
8
- import { ViewImage } from "bhd-components";
8
+ import ViewImage from "../viewImage";
9
9
  // import html2canvas from "html2canvas";
10
10
  import cssStyle from "./index.module.less";
11
11
  import cssStyleOnline from "./index2.module.less";
@@ -18,6 +18,7 @@ import { CloseOutlined, RightOutlined, ZoomInOutlined } from "@ant-design/icons"
18
18
  import HistoryFun from "./historyFun";
19
19
  import ContactsList from "./contactsList";
20
20
  import ScreenshotTool from "./screenshotTool";
21
+ import TeacherList from "./teacherList";
21
22
  import { parseDate } from "../utils/Date";
22
23
  import { Remarkable } from "remarkable";
23
24
  import hljs from "highlight.js";
@@ -54,20 +55,21 @@ var CustomerService = function(props) {
54
55
  var _useState17 = _sliced_to_array(useState(45), 2), buttomHei = _useState17[0], setButtomHei = _useState17[1]; //底部输入框的高度
55
56
  var _useState18 = _sliced_to_array(useState(false), 2), showHistory = _useState18[0], setShowHistory = _useState18[1]; //是否显示历史记录
56
57
  var _useState19 = _sliced_to_array(useState(false), 2), showContacts = _useState19[0], setShowContacts = _useState19[1]; //是否显示老师列表
57
- var _useState20 = _sliced_to_array(useState(-1), 2), showType = _useState20[0], setShowType = _useState20[1]; //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
58
- var _useState21 = _sliced_to_array(useState(-1), 2), answerMode = _useState21[0], setAnswerMode = _useState21[1]; //设置回答模式。1,召唤老师回答
59
- var _useState22 = _sliced_to_array(useState([]), 2), teacherList = _useState22[0], setTeacherList = _useState22[1]; //老师列表
60
- var _useState23 = _sliced_to_array(useState({}), 2), problem = _useState23[0], setProblem = _useState23[1]; //召唤老师回答的问题
61
- var _useState24 = _sliced_to_array(useState([]), 2), contactsList = _useState24[0], setContactsList = _useState24[1]; //老师列表
62
- var _useState25 = _sliced_to_array(useState([]), 2), chatObj = _useState25[0], setChatObj = _useState25[1]; //聊天记录id保存,用来在实验报告中记录
63
- var _useState26 = _sliced_to_array(useState(""), 2), keyWordProblem = _useState26[0], setKeyWordProblem = _useState26[1]; //历史记录搜索的内容
64
- var _useState27 = _sliced_to_array(useState(""), 2), imgBese64 = _useState27[0], setImgBese64 = _useState27[1]; //屏幕截图
65
- var _useState28 = _sliced_to_array(useState(""), 2), screenshotBese64 = _useState28[0], setScreenshotBese64 = _useState28[1]; //bese64图片
66
- var _useState29 = _sliced_to_array(useState(""), 2), viewBase64 = _useState29[0], setViewBase64 = _useState29[1]; //图片预览
67
- var _useState30 = _sliced_to_array(useState(false), 2), visible = _useState30[0], setVisible = _useState30[1]; //是否显示图片预览
68
- var _useState31 = _sliced_to_array(useState([]), 2), bottomRecommendationQuestions = _useState31[0], setBottomRecommendationQuestions = _useState31[1]; //底部推荐问题
69
- var _useState32 = _sliced_to_array(useState(false), 2), showScreenshot = _useState32[0], setShowScreenshot = _useState32[1]; //是否显示截图 主要用于newlabo页面
70
- var _useState33 = _sliced_to_array(useState(-1), 2), saveShowType = _useState33[0], setSaveShowType = _useState33[1]; //保存截图时的状态
58
+ var _useState20 = _sliced_to_array(useState([]), 2), contactsList = _useState20[0], setContactsList = _useState20[1]; //老师列表
59
+ var _useState21 = _sliced_to_array(useState(-1), 2), showType = _useState21[0], setShowType = _useState21[1]; //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
60
+ // const [answerMode, setAnswerMode] = useState(-1); //设置回答模式。1,召唤老师回答
61
+ // const [teacherList, setTeacherList] = useState([]); //老师列表
62
+ var _useState22 = _sliced_to_array(useState({}), 2), problem = _useState22[0], setProblem = _useState22[1]; //召唤老师回答的问题
63
+ var _useState23 = _sliced_to_array(useState([]), 2), chatObj = _useState23[0], setChatObj = _useState23[1]; //聊天记录id保存,用来在实验报告中记录
64
+ var _useState24 = _sliced_to_array(useState(""), 2), keyWordProblem = _useState24[0], setKeyWordProblem = _useState24[1]; //历史记录搜索的内容
65
+ var _useState25 = _sliced_to_array(useState(""), 2), imgBese64 = _useState25[0], setImgBese64 = _useState25[1]; //屏幕截图
66
+ var _useState26 = _sliced_to_array(useState(""), 2), screenshotBese64 = _useState26[0], setScreenshotBese64 = _useState26[1]; //bese64图片
67
+ var _useState27 = _sliced_to_array(useState(""), 2), viewBase64 = _useState27[0], setViewBase64 = _useState27[1]; //图片预览
68
+ var _useState28 = _sliced_to_array(useState(false), 2), visible = _useState28[0], setVisible = _useState28[1]; //是否显示图片预览
69
+ var _useState29 = _sliced_to_array(useState([]), 2), bottomRecommendationQuestions = _useState29[0], setBottomRecommendationQuestions = _useState29[1]; //底部推荐问题
70
+ var _useState30 = _sliced_to_array(useState(false), 2), showScreenshot = _useState30[0], setShowScreenshot = _useState30[1]; //是否显示截图 主要用于newlabo页面
71
+ var _useState31 = _sliced_to_array(useState(-1), 2), saveShowType = _useState31[0], setSaveShowType = _useState31[1]; //保存截图时的状态
72
+ var _useState32 = _sliced_to_array(useState(false), 2), showTeacherList = _useState32[0], setShowTeacherList = _useState32[1]; //是否显示召唤老师列表
71
73
  var timer = useRef(null); //文本框输入时
72
74
  var receiveMessageTimer = useRef(null); //接收ai发回的消息
73
75
  // let voiceCountdownTimer = useRef(null); //语音录制倒计时
@@ -81,6 +83,7 @@ var CustomerService = function(props) {
81
83
  var recommendeQuestionID = useRef([]); //推荐问题id
82
84
  var videoHotQuestionsList = useRef([]); //视频热门问题
83
85
  var newHotQuestionsList = useRef([]); //视频热门问题
86
+ var newShowType = useRef(false);
84
87
  var mid = props.userData.mid;
85
88
  var remarkable = new Remarkable({
86
89
  highlight: function highlight(str, lang) {
@@ -154,6 +157,7 @@ var CustomerService = function(props) {
154
157
  //|| showScreenshot
155
158
  if (showType == 5 || showScreenshot) {
156
159
  try {
160
+ newShowType.current = true;
157
161
  setImgBese64("");
158
162
  // let dom = document.getElementById(screenshotAreaId);
159
163
  html2canvas(screenshotAreaId, {
@@ -313,10 +317,10 @@ var CustomerService = function(props) {
313
317
  var watchTime = params.videoProgress;
314
318
  var courseId = getQuery("yc_id");
315
319
  var sectionId = params.VideoBriefSummaryId;
316
- // let courseId="31007",
317
- // sectionId= "446168",
318
- // videoId= "71399",
319
- // watchTime= 527
320
+ // let courseId="20899",
321
+ // sectionId= "462368",
322
+ // videoId= "29832",
323
+ // watchTime= 753
320
324
  if (videoId && courseId && sectionId) {
321
325
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
322
326
  "recommendedQuestions": [],
@@ -336,16 +340,26 @@ var CustomerService = function(props) {
336
340
  var questionsList = null;
337
341
  if (data.length > 0) {
338
342
  questionsList = data.map(function(item, index) {
339
- return {
340
- key: "messageSource",
341
- value: item.id,
342
- question: item.question,
343
- answer: item.answer
344
- };
343
+ if (userData.modules.some(function(item) {
344
+ return item.short == "AIservice";
345
+ }) || item.answer) {
346
+ return {
347
+ key: "messageSource",
348
+ value: item.id,
349
+ question: item.question,
350
+ answer: item.answer
351
+ };
352
+ } else {
353
+ return null;
354
+ }
355
+ });
356
+ questionsList = questionsList.filter(function(i) {
357
+ return i != null;
345
358
  });
346
359
  recommendeQuestionID.current = data.map(function(item) {
347
360
  return item.id;
348
361
  });
362
+ console.log(recommendeQuestionID.current, 4444444);
349
363
  }
350
364
  console.log("dflkvmdfklvdf欢迎语", data);
351
365
  var obj = {
@@ -549,6 +563,7 @@ var CustomerService = function(props) {
549
563
  };
550
564
  //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
551
565
  var sendToTeacher = function(type) {
566
+ var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
552
567
  console.log("消息发送给老师111");
553
568
  var obj = {};
554
569
  if (type == 1) {
@@ -558,8 +573,11 @@ var CustomerService = function(props) {
558
573
  recevier: chatWith.uid,
559
574
  message: problem.question
560
575
  };
576
+ if (problem.url) {
577
+ obj.image = problem.url;
578
+ }
561
579
  setProblem({});
562
- } else if (type == 2) {
580
+ } else if (type == 2 || type == 3) {
563
581
  var list = contactsList.filter(function(item) {
564
582
  return item.roomId == roomId;
565
583
  });
@@ -571,9 +589,13 @@ var CustomerService = function(props) {
571
589
  roomId: roomId,
572
590
  sender: mid,
573
591
  recevier: recevier,
574
- message: keyWord,
592
+ message: type == 2 ? keyWord : message,
575
593
  quotedMessage: citationContent.content || ""
576
594
  };
595
+ if (screenshotBese64) {
596
+ obj.image = screenshotBese64;
597
+ setScreenshotBese64("");
598
+ }
577
599
  }
578
600
  http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
579
601
  if (res.data.id) {
@@ -584,7 +606,13 @@ var CustomerService = function(props) {
584
606
  id: res.data.id,
585
607
  upvoted: false,
586
608
  downvoted: false,
587
- createdAt: getDataTime(-1)
609
+ createdAt: getDataTime(-1),
610
+ extraInfo: obj.image ? JSON.stringify([
611
+ {
612
+ key: "imageUrl",
613
+ value: obj.image
614
+ }
615
+ ]) : null
588
616
  }));
589
617
  return newHistoryMessageList;
590
618
  });
@@ -1237,8 +1265,9 @@ var CustomerService = function(props) {
1237
1265
  roomMessage.current = setTimeout(function() {
1238
1266
  getRoomidHistoryMessage(totalNumber, rid);
1239
1267
  }, 5000);
1240
- if (rid == "") return;
1241
- // console.log(roomList,2222222);
1268
+ // console.log(showType, imgBese64,showScreenshot,newShowType.current,9999999);
1269
+ //newShowType.current 截图中,不循环
1270
+ if (rid == "" || newShowType.current) return;
1242
1271
  return http.get("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), {
1243
1272
  params: {
1244
1273
  roomId: rid,
@@ -1495,19 +1524,6 @@ var CustomerService = function(props) {
1495
1524
  }
1496
1525
  }
1497
1526
  };
1498
- //获取老师列表
1499
- var getTeacherList = function(keyWord) {
1500
- http.get("".concat(urllocation, "/chat-service/public/v1.0/teachers"), {
1501
- params: {
1502
- name: keyWord
1503
- }
1504
- }).then(function(res) {
1505
- console.log(res);
1506
- if (res.data) {
1507
- setTeacherList(res.data.teachers);
1508
- }
1509
- });
1510
- };
1511
1527
  //获取聊天室列表
1512
1528
  var roomsListTimer = function() {
1513
1529
  if (chatRoomList != null) clearTimeout(chatRoomList.current);
@@ -2041,7 +2057,7 @@ var CustomerService = function(props) {
2041
2057
  ]
2042
2058
  })
2043
2059
  }),
2044
- showType == 2 || showType == 4 ? /*#__PURE__*/ _jsx("div", {
2060
+ (showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
2045
2061
  className: styles.head_sculpture,
2046
2062
  style: {
2047
2063
  marginLeft: "12px"
@@ -2049,7 +2065,7 @@ var CustomerService = function(props) {
2049
2065
  children: /*#__PURE__*/ _jsx("img", {
2050
2066
  src: userData.avatar
2051
2067
  })
2052
- }) : ""
2068
+ })
2053
2069
  ]
2054
2070
  }, item.id)
2055
2071
  ]
@@ -2161,28 +2177,7 @@ var CustomerService = function(props) {
2161
2177
  ]
2162
2178
  }),
2163
2179
  //findTeacher//是否在召唤老师过程中,是否是最后一条消息
2164
- !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != "123456_date" && renderLastOperateBtn(item, isAiChatWindow, i),
2165
- //召唤老师回答按钮
2166
- isAiChatWindow && item.findTeacher && userData.modules.some(function(item) {
2167
- return item.short == "TeacherAnswer";
2168
- }) && /*#__PURE__*/ _jsx("div", {
2169
- className: "".concat(styles.operate_modal_bottom, " "),
2170
- children: /*#__PURE__*/ _jsx("p", {
2171
- className: styles.stop_findTeacher,
2172
- children: /*#__PURE__*/ _jsx("span", {
2173
- onClick: function() {
2174
- setAnswerMode(-1);
2175
- setTeacherList([]);
2176
- setHistoryMessageList(function(historyMessageList) {
2177
- return historyMessageList.filter(function(item) {
2178
- return item.id != "-1";
2179
- });
2180
- });
2181
- },
2182
- children: "停止召唤老师"
2183
- })
2184
- })
2185
- })
2180
+ !item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != "123456_date" && renderLastOperateBtn(item, isAiChatWindow, i)
2186
2181
  ]
2187
2182
  })
2188
2183
  ]
@@ -2228,52 +2223,26 @@ var CustomerService = function(props) {
2228
2223
  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") {
2229
2224
  return "";
2230
2225
  }
2231
- // console.log(historyMessageList,i,'sdcsd;sldcscsdsd')
2232
- //根据上一行数据,判断是否显示招唤老师按钮
2233
- var showTeacherBtn = true;
2234
- var previousLineData = historyMessageList[i - 1];
2235
- if (!previousLineData) {
2236
- showTeacherBtn = true;
2237
- } else if (!previousLineData.extraInfo) {
2238
- showTeacherBtn = true;
2239
- } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2240
- showTeacherBtn = false;
2241
- }
2242
2226
  return /*#__PURE__*/ _jsxs("p", {
2243
2227
  className: styles.operate,
2244
2228
  children: [
2245
2229
  // 不在智能客服窗口,并已经点击了召唤老师,并有召唤老师权限
2246
- isAiChatWindow && answerMode != 1 && userData.modules.some(function(item) {
2230
+ isAiChatWindow && userData.modules.some(function(item) {
2247
2231
  return item.short == "TeacherAnswer";
2248
- }) && showTeacherBtn && /*#__PURE__*/ _jsx("span", {
2232
+ }) && /*#__PURE__*/ _jsx("span", {
2249
2233
  className: styles.ask_question,
2250
2234
  onClick: function() {
2251
- setAnswerMode(1);
2235
+ console.log(historyMessageList[i - 1], 4444444);
2236
+ var extraInfo = historyMessageList[i - 1].extraInfo;
2237
+ var url = "";
2238
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2239
+ url = JSON.parse(extraInfo)[0].value;
2240
+ }
2252
2241
  setProblem({
2253
2242
  question: historyMessageList[i - 1].message,
2254
- user: problem.user
2255
- });
2256
- setHistoryMessageList(function(historyMessageList) {
2257
- var newHistoryMessageList = historyMessageList.concat({
2258
- id: -1,
2259
- roomId: roomId,
2260
- sender: "AI",
2261
- recevier: mid,
2262
- message: "请告诉我您要召唤的老师名字",
2263
- createdAt: getDataTime(-1),
2264
- findTeacher: true,
2265
- extraInfo: item.extraInfo == null ? null : JSON.stringify([
2266
- {
2267
- key: "questionId",
2268
- value: "questionId"
2269
- }
2270
- ])
2271
- });
2272
- return newHistoryMessageList;
2243
+ url: url
2273
2244
  });
2274
- setTimeout(function() {
2275
- scrollToBottom();
2276
- }, 200);
2245
+ setShowTeacherList(true);
2277
2246
  },
2278
2247
  children: "召唤老师回答"
2279
2248
  }),
@@ -2286,7 +2255,6 @@ var CustomerService = function(props) {
2286
2255
  });
2287
2256
  resettingBottomHei();
2288
2257
  onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
2289
- console.log("引用222222");
2290
2258
  },
2291
2259
  children: /*#__PURE__*/ _jsx(CustomQuote, {})
2292
2260
  }),
@@ -2329,7 +2297,6 @@ var CustomerService = function(props) {
2329
2297
  if (!isAiChatWindow) return;
2330
2298
  //只有最后一条回答,支持发送点赞或踩
2331
2299
  if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
2332
- console.log("判断是AI还是智能问答", item);
2333
2300
  if (!item.extraInfo && item.sender == "AI") {
2334
2301
  aiSendQuestions(1, {
2335
2302
  roomId: roomId,
@@ -2339,7 +2306,6 @@ var CustomerService = function(props) {
2339
2306
  generateUpvoteOrDownvoteMessage: true
2340
2307
  }, 1);
2341
2308
  } else {
2342
- console.log("AI回答2255555");
2343
2309
  sendGreetingMessage(2);
2344
2310
  }
2345
2311
  }
@@ -2397,17 +2363,6 @@ var CustomerService = function(props) {
2397
2363
  if (!showStopBtn && isAiChatWindow && (extraInfo != undefined && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "questionId" || extraInfo == null)) {
2398
2364
  findTeacherBtn = true;
2399
2365
  }
2400
- //根据上一行数据,判断是否显示招唤老师按钮
2401
- var showTeacherBtn = true;
2402
- var previousLineData = historyMessageList[i - 1];
2403
- if (!previousLineData) {
2404
- showTeacherBtn = true;
2405
- } else if (!previousLineData.extraInfo) {
2406
- showTeacherBtn = true;
2407
- } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2408
- showTeacherBtn = false;
2409
- }
2410
- /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2411
2366
  return /*#__PURE__*/ _jsxs("div", {
2412
2367
  className: "".concat(styles.operate_modal_bottom),
2413
2368
  children: [
@@ -2458,35 +2413,19 @@ var CustomerService = function(props) {
2458
2413
  //在ai窗口并ai已经生成完答案
2459
2414
  findTeacherBtn && userData.modules.some(function(item) {
2460
2415
  return item.short == "TeacherAnswer";
2461
- }) && showTeacherBtn && /*#__PURE__*/ _jsx("span", {
2416
+ }) && /*#__PURE__*/ _jsx("span", {
2462
2417
  className: styles.find_teacher,
2463
2418
  onClick: function() {
2464
- setAnswerMode(1);
2419
+ var extraInfo = historyMessageList[i - 1].extraInfo;
2420
+ var url = "";
2421
+ if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
2422
+ url = JSON.parse(extraInfo)[0].value;
2423
+ }
2465
2424
  setProblem({
2466
2425
  question: historyMessageList[i - 1].message,
2467
- user: problem.user
2468
- });
2469
- setHistoryMessageList(function(historyMessageList) {
2470
- var newHistoryMessageList = historyMessageList.concat({
2471
- id: -1,
2472
- roomId: roomId,
2473
- sender: "AI",
2474
- recevier: mid,
2475
- message: "请告诉我您要召唤的老师名字",
2476
- createdAt: getDataTime(-1),
2477
- findTeacher: true,
2478
- extraInfo: item.extraInfo == null ? null : JSON.stringify([
2479
- {
2480
- key: "questionId",
2481
- value: "questionId"
2482
- }
2483
- ])
2484
- });
2485
- return newHistoryMessageList;
2426
+ url: url
2486
2427
  });
2487
- setTimeout(function() {
2488
- scrollToBottom();
2489
- }, 200);
2428
+ setShowTeacherList(true);
2490
2429
  },
2491
2430
  children: "召唤老师回答"
2492
2431
  })
@@ -2638,6 +2577,44 @@ var CustomerService = function(props) {
2638
2577
  }
2639
2578
  }
2640
2579
  };
2580
+ //发送截图信息
2581
+ var sendScreenshotData = function(message) {
2582
+ if (contactsList.length > 0 && contactsList[0].roomId == roomId) {
2583
+ setHistoryMessageList(function(historyMessageList) {
2584
+ var newHistoryMessageList = historyMessageList.concat({
2585
+ id: "p" + new Date().getTime(),
2586
+ roomId: roomId,
2587
+ sender: mid,
2588
+ recevier: "AI",
2589
+ message: message,
2590
+ createdAt: getDataTime(-1),
2591
+ extraInfo: JSON.stringify([
2592
+ {
2593
+ key: "imageUrl",
2594
+ value: screenshotBese64
2595
+ }
2596
+ ])
2597
+ });
2598
+ return newHistoryMessageList;
2599
+ });
2600
+ //ai窗口
2601
+ aiSendQuestions(3, {
2602
+ //相关数据
2603
+ roomId: roomId,
2604
+ message: message,
2605
+ image: screenshotBese64,
2606
+ quotedMessage: citationContent.content || "",
2607
+ regenerate: citationContent.content != "" ? false : true,
2608
+ generateUpvoteOrDownvoteMessage: false
2609
+ }, 1);
2610
+ setScreenshotBese64("");
2611
+ } else {
2612
+ //老师窗口
2613
+ sendToTeacher(3, message);
2614
+ }
2615
+ scrollToBottom();
2616
+ resettingBottomHei();
2617
+ };
2641
2618
  //渲染底部按钮
2642
2619
  var renderBottomAnt = function() {
2643
2620
  var placeholder = "";
@@ -2697,35 +2674,7 @@ var CustomerService = function(props) {
2697
2674
  children: [
2698
2675
  /*#__PURE__*/ _jsxs("p", {
2699
2676
  onClick: function() {
2700
- setHistoryMessageList(function(historyMessageList) {
2701
- var newHistoryMessageList = historyMessageList.concat({
2702
- id: "p" + new Date().getTime(),
2703
- roomId: roomId,
2704
- sender: mid,
2705
- recevier: "AI",
2706
- message: "讲解这张图片涉及到的知识内容",
2707
- createdAt: getDataTime(-1),
2708
- extraInfo: JSON.stringify([
2709
- {
2710
- key: "imageUrl",
2711
- value: screenshotBese64
2712
- }
2713
- ])
2714
- });
2715
- return newHistoryMessageList;
2716
- });
2717
- scrollToBottom();
2718
- aiSendQuestions(3, {
2719
- //相关数据
2720
- roomId: roomId,
2721
- message: "讲解这张图片涉及到的知识内容",
2722
- image: screenshotBese64,
2723
- quotedMessage: citationContent.content || "",
2724
- regenerate: citationContent.content != "" ? false : true,
2725
- generateUpvoteOrDownvoteMessage: false
2726
- }, 1);
2727
- setScreenshotBese64("");
2728
- resettingBottomHei();
2677
+ sendScreenshotData("讲解这张图片涉及到的知识内容");
2729
2678
  },
2730
2679
  children: [
2731
2680
  /*#__PURE__*/ _jsx(CustomKnowledgeContent, {}),
@@ -2735,35 +2684,7 @@ var CustomerService = function(props) {
2735
2684
  /*#__PURE__*/ _jsx("br", {}),
2736
2685
  /*#__PURE__*/ _jsxs("p", {
2737
2686
  onClick: function() {
2738
- setHistoryMessageList(function(historyMessageList) {
2739
- var newHistoryMessageList = historyMessageList.concat({
2740
- id: "p" + new Date().getTime(),
2741
- roomId: roomId,
2742
- sender: mid,
2743
- recevier: "AI",
2744
- message: "帮助我更深入地理解图片中的概念",
2745
- createdAt: getDataTime(-1),
2746
- extraInfo: JSON.stringify([
2747
- {
2748
- key: "imageUrl",
2749
- value: screenshotBese64
2750
- }
2751
- ])
2752
- });
2753
- return newHistoryMessageList;
2754
- });
2755
- scrollToBottom();
2756
- aiSendQuestions(3, {
2757
- //相关数据
2758
- roomId: roomId,
2759
- message: "帮助我更深入地理解图片中的概念",
2760
- image: screenshotBese64,
2761
- quotedMessage: citationContent.content || "",
2762
- regenerate: citationContent.content != "" ? false : true,
2763
- generateUpvoteOrDownvoteMessage: false
2764
- }, 1);
2765
- setScreenshotBese64("");
2766
- resettingBottomHei();
2687
+ sendScreenshotData("帮助我更深入地理解图片中的概念");
2767
2688
  },
2768
2689
  children: [
2769
2690
  /*#__PURE__*/ _jsx(CustomWenhaoRound, {}),
@@ -2785,22 +2706,14 @@ var CustomerService = function(props) {
2785
2706
  setKeyWord(e.target.value);
2786
2707
  if (e.target.value == "") {
2787
2708
  setQuestionsList([]);
2788
- setTeacherList([]);
2789
2709
  clearTimeout(timer.current);
2790
2710
  } else {
2791
2711
  clearTimeout(timer.current);
2792
2712
  timer.current = setTimeout(function() {
2793
- if (answerMode == 1) {
2794
- getTeacherList(String(e.target.value));
2713
+ if (config && config.type == "video") {
2714
+ getQuestiionsList(String(e.target.value), 3);
2795
2715
  } else {
2796
- var roomList = contactsList;
2797
- if (roomList.length > 0 && roomList[0].roomId != roomId) return;
2798
- console.log(props, 333333);
2799
- if (config && config.type == "video") {
2800
- getQuestiionsList(String(e.target.value), 3);
2801
- } else {
2802
- getQuestiionsList(String(e.target.value), 2);
2803
- }
2716
+ getQuestiionsList(String(e.target.value), 2);
2804
2717
  }
2805
2718
  }, 1000);
2806
2719
  }
@@ -2817,44 +2730,21 @@ var CustomerService = function(props) {
2817
2730
  setKeyWord("");
2818
2731
  setCitationContent({});
2819
2732
  setBottomRecommendationQuestions([]);
2820
- resettingBottomHei();
2821
- //查找是否是召唤老师回答并有相应的老师名称
2822
- if (answerMode == 1 && teacherList.length > 0) {
2823
- var list = teacherList.filter(function(v) {
2824
- return v.name == keyWord.trim();
2825
- });
2826
- if (list.length > 0) {
2827
- //直接进入召唤老师回答模式
2828
- enterTeacherChat(list[0]);
2829
- setButtomHei(45);
2830
- return;
2831
- }
2832
- }
2833
2733
  //跟老师对话
2834
- var roomList = contactsList;
2835
- if (roomList.length > 0 && roomList[0].roomId != roomId) {
2734
+ if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
2836
2735
  sendToTeacher(2);
2837
2736
  } else {
2838
2737
  setFinished(false);
2839
- clearTimeout(timer.current);
2840
2738
  setQuestionsList([]);
2841
- setAnswerMode(-1);
2842
- setTeacherList([]);
2843
- setTimeout(function() {
2844
- setQuestionsList([]);
2845
- setTeacherList([]);
2846
- clearTimeout(timer.current);
2847
- }, 200);
2848
- setHistoryMessageList(function(historyMessageList) {
2849
- return historyMessageList.filter(function(item) {
2850
- return item.id != "-1";
2851
- });
2852
- });
2853
2739
  sendMessage("", 0);
2854
2740
  }
2741
+ setTimeout(function() {
2742
+ setQuestionsList([]);
2743
+ clearTimeout(timer.current);
2744
+ }, 200);
2745
+ resettingBottomHei();
2855
2746
  setButtomHei(45);
2856
2747
  } else {
2857
- console.log("回车事件");
2858
2748
  resettingBottomHei();
2859
2749
  }
2860
2750
  },
@@ -2888,9 +2778,9 @@ var CustomerService = function(props) {
2888
2778
  })
2889
2779
  ]
2890
2780
  }),
2891
- userData.modules.some(function(item) {
2781
+ (userData.modules.some(function(item) {
2892
2782
  return item.short == "AIservice";
2893
- }) && contactsList.length > 0 && contactsList[0].roomId == roomId && /*#__PURE__*/ _jsx("p", {
2783
+ }) || contactsList.length > 0 && contactsList[0].roomId !== roomId) && /*#__PURE__*/ _jsx("p", {
2894
2784
  className: styles.screenshot,
2895
2785
  children: /*#__PURE__*/ _jsx("i", {
2896
2786
  className: "".concat(!finished ? styles.disabled : ""),
@@ -2917,40 +2807,20 @@ var CustomerService = function(props) {
2917
2807
  setCitationContent({});
2918
2808
  setButtomHei(45);
2919
2809
  if (keyWord.trim() != "") {
2920
- //查找是否是召唤老师回答并有相应的老师名称
2921
- if (answerMode == 1 && teacherList.length > 0) {
2922
- var list = teacherList.filter(function(v) {
2923
- return v.name == keyWord.trim();
2924
- });
2925
- if (list.length > 0) {
2926
- //直接进入召唤老师回答模式
2927
- enterTeacherChat(list[0]);
2928
- setButtomHei(45);
2929
- return;
2930
- }
2931
- }
2932
2810
  setKeyWord("");
2933
2811
  //跟老师对话
2934
- var roomList = contactsList;
2935
- if (roomList.length > 0 && roomList[0].roomId != roomId) {
2812
+ if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
2936
2813
  sendToTeacher(2);
2937
2814
  } else {
2938
2815
  clearTimeout(timer.current);
2939
2816
  setQuestionsList([]);
2940
- setAnswerMode(-1);
2941
- setTeacherList([]);
2942
- setTimeout(function() {
2943
- setQuestionsList([]);
2944
- setTeacherList([]);
2945
- clearTimeout(timer.current);
2946
- }, 200);
2947
- setHistoryMessageList(function(historyMessageList) {
2948
- return historyMessageList.filter(function(item) {
2949
- return item.id != "-1";
2950
- });
2951
- });
2952
2817
  sendMessage("", 0);
2953
2818
  }
2819
+ resettingBottomHei();
2820
+ setTimeout(function() {
2821
+ setQuestionsList([]);
2822
+ clearTimeout(timer.current);
2823
+ }, 200);
2954
2824
  onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
2955
2825
  }
2956
2826
  },
@@ -2962,15 +2832,12 @@ var CustomerService = function(props) {
2962
2832
  };
2963
2833
  //进入与老师的聊天
2964
2834
  var enterTeacherChat = function(item) {
2965
- setTeacherList([]);
2835
+ setShowTeacherList(false);
2966
2836
  //提问的问题
2967
- setProblem({
2837
+ setProblem(_object_spread_props(_object_spread({}, problem), {
2968
2838
  question: problem.question,
2969
2839
  user: item.uid
2970
- });
2971
- setKeyWord("");
2972
- //setUpdateRecords(true);
2973
- setAnswerMode(-1);
2840
+ }));
2974
2841
  setChatWith(item);
2975
2842
  var roomList = contactsList;
2976
2843
  var list = roomList.filter(function(e) {
@@ -2981,7 +2848,6 @@ var CustomerService = function(props) {
2981
2848
  setRoomId(list[0].roomId); //已有聊天室
2982
2849
  } else {
2983
2850
  createRooms(item.uid).then(function(res) {
2984
- // childRef.current.roomsListTimer();
2985
2851
  roomsListTimer();
2986
2852
  var id = res.data.id;
2987
2853
  setRoomId(id); //新的聊天室id
@@ -2990,60 +2856,29 @@ var CustomerService = function(props) {
2990
2856
  };
2991
2857
  //渲染联想问题及联想的老师名称
2992
2858
  var renderAssociationProblem = function() {
2993
- if (answerMode == 1) {
2994
- return /*#__PURE__*/ _jsx("div", {
2995
- className: "".concat(styles.issues_list, " ").concat(styles.issues_list_teacherList),
2996
- style: {
2997
- bottom: "".concat(buttomHei + 14, "px")
2998
- },
2999
- children: teacherList.map(function(item) {
3000
- var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3001
- var span = "";
3002
- //搜索内容是否有特殊字符
3003
- if (reg.test(keyWord)) {
3004
- span = item.name.replaceAll(keyWord, function(e) {
3005
- return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
3006
- });
3007
- } else {
3008
- span = item.name.replaceAll(new RegExp(keyWord, "ig"), function(i) {
3009
- // console.log(i,'skdcnsdjk')
3010
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
3011
- });
3012
- }
3013
- return /*#__PURE__*/ _jsx("p", {
3014
- className: styles.item,
3015
- children: /*#__PURE__*/ _jsx("span", {
3016
- onClick: function() {
3017
- enterTeacherChat(item);
3018
- },
3019
- dangerouslySetInnerHTML: {
3020
- __html: span
3021
- }
3022
- })
2859
+ return /*#__PURE__*/ _jsx("div", {
2860
+ className: styles.issues_list,
2861
+ style: {
2862
+ bottom: "".concat(buttomHei + 6, "px")
2863
+ },
2864
+ children: questionsList.map(function(item, i) {
2865
+ if (i > 4) return "";
2866
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2867
+ var span = "";
2868
+ //搜索内容是否有特殊字符
2869
+ if (reg.test(keyWord)) {
2870
+ span = item.question.replaceAll(keyWord, function(e) {
2871
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
3023
2872
  });
3024
- })
3025
- });
3026
- } else {
3027
- return /*#__PURE__*/ _jsx("div", {
3028
- className: styles.issues_list,
3029
- style: {
3030
- bottom: "".concat(buttomHei + 6, "px")
3031
- },
3032
- children: questionsList.map(function(item, i) {
3033
- if (i > 4) return "";
3034
- var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3035
- var span = "";
3036
- //搜索内容是否有特殊字符
3037
- if (reg.test(keyWord)) {
3038
- span = item.question.replaceAll(keyWord, function(e) {
3039
- return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
3040
- });
3041
- } else {
3042
- span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
3043
- // console.log(i,'skdcnsdjk')
3044
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
3045
- });
3046
- }
2873
+ } else {
2874
+ span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2875
+ // console.log(i,'skdcnsdjk')
2876
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2877
+ });
2878
+ }
2879
+ if (userData.modules.some(function(item) {
2880
+ return item.short == "AIservice";
2881
+ }) || item.answer) {
3047
2882
  return /*#__PURE__*/ _jsx("p", {
3048
2883
  className: styles.item,
3049
2884
  children: /*#__PURE__*/ _jsx("span", {
@@ -3057,9 +2892,11 @@ var CustomerService = function(props) {
3057
2892
  }
3058
2893
  })
3059
2894
  });
3060
- })
3061
- });
3062
- }
2895
+ } else {
2896
+ return null;
2897
+ }
2898
+ })
2899
+ });
3063
2900
  };
3064
2901
  //视频页面底部推荐问题
3065
2902
  var renderBottomAssociationProblem = function() {
@@ -3068,21 +2905,27 @@ var CustomerService = function(props) {
3068
2905
  className: styles.issues_list_flag,
3069
2906
  id: "BottomAssociationProblem",
3070
2907
  children: bottomRecommendationQuestions.map(function(item) {
3071
- return /*#__PURE__*/ _jsxs(_Fragment, {
3072
- children: [
3073
- /*#__PURE__*/ _jsx("p", {
3074
- onClick: function() {
3075
- sendMessage(item, 1);
3076
- if (config && config.type == "video") {
3077
- setBottomRecommendationQuestions([]);
3078
- resettingBottomHei();
3079
- }
3080
- },
3081
- children: item.question
3082
- }, item.id),
3083
- /*#__PURE__*/ _jsx("br", {})
3084
- ]
3085
- });
2908
+ if (userData.modules.some(function(item) {
2909
+ return item.short == "AIservice";
2910
+ }) || item.answer) {
2911
+ return /*#__PURE__*/ _jsxs(_Fragment, {
2912
+ children: [
2913
+ /*#__PURE__*/ _jsx("p", {
2914
+ onClick: function() {
2915
+ sendMessage(item, 1);
2916
+ if (config && config.type == "video") {
2917
+ setBottomRecommendationQuestions([]);
2918
+ resettingBottomHei();
2919
+ }
2920
+ },
2921
+ children: item.question
2922
+ }, item.id),
2923
+ /*#__PURE__*/ _jsx("br", {})
2924
+ ]
2925
+ });
2926
+ } else {
2927
+ return null;
2928
+ }
3086
2929
  })
3087
2930
  });
3088
2931
  } else {
@@ -3090,21 +2933,27 @@ var CustomerService = function(props) {
3090
2933
  className: styles.issues_list_flag,
3091
2934
  id: "BottomAssociationProblem_modal",
3092
2935
  children: bottomRecommendationQuestions.map(function(item) {
3093
- return /*#__PURE__*/ _jsxs(_Fragment, {
3094
- children: [
3095
- /*#__PURE__*/ _jsx("p", {
3096
- onClick: function() {
3097
- sendMessage(item, 1);
3098
- if (config && config.type == "video") {
3099
- setBottomRecommendationQuestions([]);
3100
- resettingBottomHei();
3101
- }
3102
- },
3103
- children: item.question
3104
- }, item.id),
3105
- /*#__PURE__*/ _jsx("br", {})
3106
- ]
3107
- });
2936
+ if (userData.modules.some(function(item) {
2937
+ return item.short == "AIservice";
2938
+ }) || item.answer) {
2939
+ return /*#__PURE__*/ _jsxs(_Fragment, {
2940
+ children: [
2941
+ /*#__PURE__*/ _jsx("p", {
2942
+ onClick: function() {
2943
+ sendMessage(item, 1);
2944
+ if (config && config.type == "video") {
2945
+ setBottomRecommendationQuestions([]);
2946
+ resettingBottomHei();
2947
+ }
2948
+ },
2949
+ children: item.question
2950
+ }, item.id),
2951
+ /*#__PURE__*/ _jsx("br", {})
2952
+ ]
2953
+ });
2954
+ } else {
2955
+ return null;
2956
+ }
3108
2957
  })
3109
2958
  });
3110
2959
  }
@@ -3223,6 +3072,16 @@ var CustomerService = function(props) {
3223
3072
  setShowHistory(false);
3224
3073
  },
3225
3074
  loadSpecifiedData: loadSpecifiedData
3075
+ }),
3076
+ showType == 1 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3077
+ type: showType,
3078
+ userData: userData,
3079
+ http: http,
3080
+ urllocation: urllocation,
3081
+ onClose: function() {
3082
+ setShowTeacherList(false);
3083
+ },
3084
+ enterTeacherChat: enterTeacherChat
3226
3085
  })
3227
3086
  ]
3228
3087
  }),
@@ -3310,6 +3169,16 @@ var CustomerService = function(props) {
3310
3169
  setShowHistory(false);
3311
3170
  },
3312
3171
  loadSpecifiedData: loadSpecifiedData
3172
+ }),
3173
+ showType == 2 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3174
+ type: showType,
3175
+ userData: userData,
3176
+ http: http,
3177
+ urllocation: urllocation,
3178
+ onClose: function() {
3179
+ setShowTeacherList(false);
3180
+ },
3181
+ enterTeacherChat: enterTeacherChat
3313
3182
  })
3314
3183
  ]
3315
3184
  })
@@ -3407,6 +3276,16 @@ var CustomerService = function(props) {
3407
3276
  },
3408
3277
  loadSpecifiedData: loadSpecifiedData
3409
3278
  }),
3279
+ showType == 3 && showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3280
+ type: showType,
3281
+ userData: userData,
3282
+ http: http,
3283
+ urllocation: urllocation,
3284
+ onClose: function() {
3285
+ setShowTeacherList(false);
3286
+ },
3287
+ enterTeacherChat: enterTeacherChat
3288
+ }),
3410
3289
  showType == 3 && /*#__PURE__*/ _jsx("div", {
3411
3290
  style: {
3412
3291
  display: "".concat(showType == 3 && showContacts && roomId != "" ? "block" : "none")
@@ -3514,6 +3393,16 @@ var CustomerService = function(props) {
3514
3393
  setShowHistory(false);
3515
3394
  },
3516
3395
  loadSpecifiedData: loadSpecifiedData
3396
+ }),
3397
+ showTeacherList && /*#__PURE__*/ _jsx(TeacherList, {
3398
+ type: showType,
3399
+ userData: userData,
3400
+ http: http,
3401
+ urllocation: urllocation,
3402
+ onClose: function() {
3403
+ setShowTeacherList(false);
3404
+ },
3405
+ enterTeacherChat: enterTeacherChat
3517
3406
  })
3518
3407
  ]
3519
3408
  })
@@ -3621,6 +3510,7 @@ var CustomerService = function(props) {
3621
3510
  (showType == 5 || showScreenshot) && imgBese64 && /*#__PURE__*/ _jsx(ScreenshotTool, {
3622
3511
  imgBese64: imgBese64,
3623
3512
  saveScreenshotBese64: function(base64) {
3513
+ newShowType.current = false;
3624
3514
  setScreenshotBese64(base64);
3625
3515
  if (saveShowType != -1) {
3626
3516
  setShowType(saveShowType);
@@ -3630,6 +3520,7 @@ var CustomerService = function(props) {
3630
3520
  setShowScreenshot(false);
3631
3521
  },
3632
3522
  cancelScreenshot: function() {
3523
+ newShowType.current = false;
3633
3524
  if (saveShowType != -1) {
3634
3525
  setShowType(saveShowType);
3635
3526
  } else {