bhd-components 0.6.8 → 0.7.1

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.
@@ -107,8 +107,11 @@ var HistoryFun = function(props) {
107
107
  }
108
108
  });
109
109
  var pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
110
+ if (number == 0) {
111
+ pageNumber = 1;
112
+ }
110
113
  console.log(roomId, pageNumber, id, receiver, "第几页第几页第几页第几页第几页第几页");
111
- loadSpecifiedData(roomId, pageNumber, id, receiver);
114
+ loadSpecifiedData(roomId, pageNumber, id, receiver, keyWordProblem);
112
115
  onClose();
113
116
  setKeyWordProblem("");
114
117
  setTotalData([]);
@@ -375,7 +378,7 @@ var HistoryFun = function(props) {
375
378
  return /*#__PURE__*/ _jsxs(_Fragment, {
376
379
  children: [
377
380
  /*#__PURE__*/ _jsxs("div", {
378
- className: styles.list_summary,
381
+ className: "".concat(styles.list_summary, " ").concat(item.show ? styles.list_summary_active : ""),
379
382
  id: item.roomId,
380
383
  onClick: function() {
381
384
  if (item.count == 1) {
@@ -55,6 +55,7 @@ var CustomerService = function(props) {
55
55
  // const [roomList,setRoomList] = useState([]);//聊天列表
56
56
  var _useState25 = _sliced_to_array(useState([]), 2), contactsList = _useState25[0], setContactsList = _useState25[1]; //老师列表
57
57
  var _useState26 = _sliced_to_array(useState([]), 2), chatObj = _useState26[0], setChatObj = _useState26[1]; //聊天记录id保存,用来在实验报告中记录
58
+ var _useState27 = _sliced_to_array(useState(""), 2), keyWordProblem = _useState27[0], setKeyWordProblem = _useState27[1]; //历史记录搜索的内容
58
59
  var timer = useRef(null); //文本框输入时
59
60
  var receiveMessageTimer = useRef(null); //接收ai发回的消息
60
61
  var voiceCountdownTimer = useRef(null); //语音录制倒计时
@@ -63,6 +64,8 @@ var CustomerService = function(props) {
63
64
  var chatRoomList = useRef(null); //获取聊天室列表
64
65
  var ctrl = useRef(); //停止生成ai回答时使用
65
66
  var childRef = useRef(null); //获取子组件方法
67
+ var scrollTopHei = useRef(0);
68
+ var isPosition = useRef(true);
66
69
  var mid = props.userData.mid;
67
70
  var remarkable = new Remarkable({
68
71
  highlight: function highlight(str, lang) {
@@ -123,6 +126,16 @@ var CustomerService = function(props) {
123
126
  getHistoryMessage(number1, 2);
124
127
  }, 1000);
125
128
  }
129
+ //生成答案过程中
130
+ if (!finished && scrollTopHei.current > scrollTop) {
131
+ // setIsPosition(false);
132
+ isPosition.current = false;
133
+ }
134
+ if (!finished && clientHeight + scrollTop >= scrollHeight) {
135
+ // console.log('到顶了111');
136
+ isPosition.current = true;
137
+ }
138
+ scrollTopHei.current = scrollTop;
126
139
  };
127
140
  if (showType != 1 && !firstLoad && pageCount > 0) {
128
141
  setFirstLoad(true);
@@ -242,28 +255,48 @@ var CustomerService = function(props) {
242
255
  var questionsList = [];
243
256
  var obj = {};
244
257
  if (type == 1) {
245
- questionsList = hotQuestionsList.map(function(item, index) {
246
- if (index < 3) {
247
- return {
248
- key: "messageSource",
249
- value: item.id,
250
- question: item.question,
251
- answer: item.answer
252
- };
253
- } else {
254
- return null;
255
- }
256
- });
257
- questionsList = questionsList.filter(function(i) {
258
- return i != null;
259
- });
258
+ // questionsList = hotQuestionsList.map((item, index) => {
259
+ // if (index < 3) {
260
+ // return {
261
+ // key: "messageSource",
262
+ // value: item.id,
263
+ // question: item.question,
264
+ // answer: item.answer,
265
+ // };
266
+ // } else {
267
+ // return null;
268
+ // }
269
+ // });
270
+ // questionsList = questionsList.filter((i) => i != null);
260
271
  obj = {
261
272
  roomId: roomId,
262
273
  sender: "AI",
263
274
  recevier: mid,
264
- message: "Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?",
265
- extraInfos: questionsList
275
+ message: "Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?"
266
276
  };
277
+ if (pageNumHistory <= 1) {
278
+ setHistoryMessageList(function(historyMessageList) {
279
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
280
+ id: "p" + new Date().getTime(),
281
+ upvoted: false,
282
+ downvoted: false,
283
+ quotedMessage: "",
284
+ createdAt: getDataTime(-1),
285
+ // extraInfo: JSON.stringify(obj.extraInfos),
286
+ extraInfo: JSON.stringify([
287
+ {
288
+ key: "messageSource",
289
+ value: "knowledgebase"
290
+ }
291
+ ])
292
+ }));
293
+ return newHistoryMessageList;
294
+ });
295
+ setTimeout(function() {
296
+ scrollToBottom();
297
+ }, 100);
298
+ }
299
+ return;
267
300
  } else if (type == 2) {
268
301
  obj = {
269
302
  roomId: roomId,
@@ -338,6 +371,24 @@ var CustomerService = function(props) {
338
371
  message: "猜你想问:",
339
372
  extraInfos: questionsList
340
373
  };
374
+ if (pageNumHistory <= 1) {
375
+ setHistoryMessageList(function(historyMessageList) {
376
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
377
+ id: "p" + new Date().getTime(),
378
+ upvoted: false,
379
+ downvoted: false,
380
+ quotedMessage: "",
381
+ createdAt: getDataTime(-1),
382
+ extraInfo: JSON.stringify(obj.extraInfos)
383
+ }));
384
+ return newHistoryMessageList;
385
+ });
386
+ setTimeout(function() {
387
+ scrollToBottom();
388
+ }, 100);
389
+ }
390
+ console.log("不记录1111111");
391
+ return;
341
392
  }
342
393
  setKeyWord("");
343
394
  setQuestionsList([]);
@@ -407,11 +458,13 @@ var CustomerService = function(props) {
407
458
  }));
408
459
  return newHistoryMessageList;
409
460
  });
410
- if (!lastId) {
411
- setTimeout(function() {
412
- scrollToBottom();
413
- }, 100);
414
- }
461
+ // console.log(lastId,'消息发送给老师111');
462
+ // if (!lastId) {
463
+ setTimeout(function() {
464
+ console.log("滚动到底部");
465
+ scrollToBottom();
466
+ }, 100);
467
+ // }
415
468
  }
416
469
  //判断当前窗口是否是
417
470
  if (type == 1) {
@@ -738,11 +791,19 @@ var CustomerService = function(props) {
738
791
  }
739
792
  if (msg.finished) {
740
793
  setFinished(true); //发送结束
794
+ // isPosition.current = true;
795
+ setTimeout(function() {
796
+ isPosition.current = true;
797
+ }, 100);
741
798
  testLabQuestion(JSON.parse(data).message, content, "");
742
799
  }
743
800
  },
744
801
  onclose: function onclose() {
745
802
  setFinished(true); //发送结束
803
+ // isPosition.current = true;
804
+ setTimeout(function() {
805
+ isPosition.current = true;
806
+ }, 100);
746
807
  setHistoryMessageList(function(historyMessageList) {
747
808
  return historyMessageList.filter(function(item) {
748
809
  return item.id != "123456";
@@ -808,7 +869,9 @@ var CustomerService = function(props) {
808
869
  }
809
870
  });
810
871
  setTimeout(function() {
811
- scrollToBottom();
872
+ if (isPosition.current) {
873
+ scrollToBottom();
874
+ }
812
875
  }, 10);
813
876
  };
814
877
  //问题记录到实验报告中
@@ -857,7 +920,7 @@ var CustomerService = function(props) {
857
920
  var getHistoryMessage = function(pageNum, flag) {
858
921
  var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1", raw_data = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
859
922
  clearTimeout(roomMessage.current);
860
- // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
923
+ console.log(pageNum, flag, "dkfjvndfjvndfkvdf");
861
924
  // flag == 1 时已经设置好了位置标记
862
925
  var last_id = "";
863
926
  if (flag == 2 && historyMessageList.length > 0) {
@@ -948,6 +1011,11 @@ var CustomerService = function(props) {
948
1011
  if (problem != undefined && problem.user != undefined && problem.question != undefined) {
949
1012
  sendToTeacher(1);
950
1013
  }
1014
+ // if(flag == 1){
1015
+ setTimeout(function() {
1016
+ setKeyWordProblem("");
1017
+ }, 3100);
1018
+ // }
951
1019
  } else {
952
1020
  setPageCount(0);
953
1021
  setGreetingMessage(true);
@@ -1525,6 +1593,16 @@ var CustomerService = function(props) {
1525
1593
  }
1526
1594
  }
1527
1595
  var dataTime = time;
1596
+ if (lastId == item.id && keyWordProblem != "") {
1597
+ message = remarkable.render(message);
1598
+ console.log(message, 444444);
1599
+ message = message.replaceAll(keyWordProblem, function(e) {
1600
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
1601
+ });
1602
+ console.log(message, 55555);
1603
+ } else {
1604
+ message = remarkable.render(message);
1605
+ }
1528
1606
  if (item.sender == mid) {
1529
1607
  //只有引用和复制功能
1530
1608
  li = /*#__PURE__*/ _jsxs(_Fragment, {
@@ -1597,7 +1675,7 @@ var CustomerService = function(props) {
1597
1675
  className: styles.content,
1598
1676
  children: /*#__PURE__*/ _jsx("p", {
1599
1677
  dangerouslySetInnerHTML: {
1600
- __html: remarkable.render(message)
1678
+ __html: message
1601
1679
  },
1602
1680
  className: styles.content_child
1603
1681
  })
@@ -1696,7 +1774,7 @@ var CustomerService = function(props) {
1696
1774
  children: [
1697
1775
  /*#__PURE__*/ _jsx("p", {
1698
1776
  dangerouslySetInnerHTML: {
1699
- __html: remarkable.render(message)
1777
+ __html: message
1700
1778
  },
1701
1779
  className: styles.content_child
1702
1780
  }),
@@ -1944,7 +2022,7 @@ var CustomerService = function(props) {
1944
2022
  return /*#__PURE__*/ _jsxs("div", {
1945
2023
  className: "".concat(styles.operate_modal_bottom),
1946
2024
  style: {
1947
- position: showStopBtn ? "sticky" : "relative"
2025
+ position: showStopBtn && isPosition.current ? "sticky" : "relative"
1948
2026
  },
1949
2027
  children: [
1950
2028
  /*#__PURE__*/ _jsxs("p", {
@@ -2227,6 +2305,11 @@ var CustomerService = function(props) {
2227
2305
  setQuestionsList([]);
2228
2306
  setAnswerMode(-1);
2229
2307
  setTeacherList([]);
2308
+ setTimeout(function() {
2309
+ setQuestionsList([]);
2310
+ setTeacherList([]);
2311
+ clearTimeout(timer.current);
2312
+ }, 200);
2230
2313
  setHistoryMessageList(function(historyMessageList) {
2231
2314
  return historyMessageList.filter(function(item) {
2232
2315
  return item.id != "-1";
@@ -2336,6 +2419,11 @@ var CustomerService = function(props) {
2336
2419
  setQuestionsList([]);
2337
2420
  setAnswerMode(-1);
2338
2421
  setTeacherList([]);
2422
+ setTimeout(function() {
2423
+ setQuestionsList([]);
2424
+ setTeacherList([]);
2425
+ clearTimeout(timer.current);
2426
+ }, 200);
2339
2427
  setHistoryMessageList(function(historyMessageList) {
2340
2428
  return historyMessageList.filter(function(item) {
2341
2429
  return item.id != "-1";
@@ -2453,11 +2541,14 @@ var CustomerService = function(props) {
2453
2541
  }
2454
2542
  };
2455
2543
  //加载指定数据,点击历史记录
2456
- var loadSpecifiedData = function(renewRoomId, page, id, receiver) {
2544
+ var loadSpecifiedData = function(renewRoomId, page, id, receiver, keyWordProblem) {
2457
2545
  // let renewRoomId = '4a615d7126b343f78d10dcb06dbc29b0';
2458
2546
  // let page = 1;
2459
2547
  // let id = '0e459f0a3a62438698f170b42b94d150';
2460
2548
  // let receiver = mid;
2549
+ if (keyWordProblem != "") {
2550
+ setKeyWordProblem(keyWordProblem);
2551
+ }
2461
2552
  if (page != 1) {
2462
2553
  setPageNumHistory(page);
2463
2554
  }
@@ -2521,6 +2612,9 @@ var CustomerService = function(props) {
2521
2612
  style: {
2522
2613
  maxHeight: "calc(100vh-".concat(buttomHei + 48, "px)")
2523
2614
  },
2615
+ onClick: function() {
2616
+ setKeyWordProblem("");
2617
+ },
2524
2618
  children: [
2525
2619
  loading ? /*#__PURE__*/ _jsx("div", {
2526
2620
  className: styles.loading,
@@ -2529,7 +2623,7 @@ var CustomerService = function(props) {
2529
2623
  alt: ""
2530
2624
  })
2531
2625
  }) : "",
2532
- renderQuestion(),
2626
+ keyWordProblem ? renderQuestion() : renderQuestion(),
2533
2627
  bottomLoading ? /*#__PURE__*/ _jsx("div", {
2534
2628
  className: styles.loading,
2535
2629
  children: /*#__PURE__*/ _jsx("img", {
@@ -2585,6 +2679,9 @@ var CustomerService = function(props) {
2585
2679
  }),
2586
2680
  /*#__PURE__*/ _jsxs("div", {
2587
2681
  className: "".concat(styles.Drawer_wrap_main),
2682
+ onClick: function() {
2683
+ setKeyWordProblem("");
2684
+ },
2588
2685
  children: [
2589
2686
  /*#__PURE__*/ _jsxs("div", {
2590
2687
  className: "".concat(styles.Drawer_main, " ChatWindow_Modal_history_list"),
@@ -2617,7 +2714,7 @@ var CustomerService = function(props) {
2617
2714
  alt: ""
2618
2715
  })
2619
2716
  }) : "",
2620
- renderQuestion()
2717
+ keyWordProblem ? renderQuestion() : renderQuestion()
2621
2718
  ]
2622
2719
  })
2623
2720
  ]
@@ -2651,6 +2748,9 @@ var CustomerService = function(props) {
2651
2748
  showType == 3 ? /*#__PURE__*/ _jsxs("div", {
2652
2749
  className: "".concat(styles.ChatWindow_Drawer),
2653
2750
  id: "",
2751
+ onClick: function() {
2752
+ setKeyWordProblem("");
2753
+ },
2654
2754
  children: [
2655
2755
  /*#__PURE__*/ _jsx("div", {
2656
2756
  className: "".concat(styles.header_wrap, " ").concat(styles.header_wrap_newlabo),
@@ -2711,7 +2811,7 @@ var CustomerService = function(props) {
2711
2811
  alt: ""
2712
2812
  })
2713
2813
  }) : "",
2714
- renderQuestion()
2814
+ keyWordProblem ? renderQuestion() : renderQuestion()
2715
2815
  ]
2716
2816
  }),
2717
2817
  /*#__PURE__*/ _jsxs("div", {
@@ -2788,6 +2888,9 @@ var CustomerService = function(props) {
2788
2888
  style: {
2789
2889
  maxHeight: "".concat(window.innerHeight - 148 - buttomHei, "px")
2790
2890
  },
2891
+ onClick: function() {
2892
+ setKeyWordProblem("");
2893
+ },
2791
2894
  children: [
2792
2895
  /*#__PURE__*/ _jsx(ContactsList, {
2793
2896
  type: 4,
@@ -2813,7 +2916,7 @@ var CustomerService = function(props) {
2813
2916
  alt: ""
2814
2917
  })
2815
2918
  }) : "",
2816
- renderQuestion()
2919
+ keyWordProblem ? renderQuestion() : renderQuestion()
2817
2920
  ]
2818
2921
  })
2819
2922
  ]
@@ -2905,7 +3008,7 @@ var CustomerService = function(props) {
2905
3008
  alt: ""
2906
3009
  })
2907
3010
  }) : "",
2908
- renderQuestion()
3011
+ keyWordProblem ? renderQuestion() : renderQuestion()
2909
3012
  ]
2910
3013
  }),
2911
3014
  /*#__PURE__*/ _jsxs("div", {
@@ -1,7 +1,6 @@
1
1
  @import "../theme/variable.less";
2
- // @color-data-visualization-01: @color-background-info-base;
3
- // @color-text-primary: @color-background-info-base;
4
- // @color-background-primary-weak-hover:@color-background-info-weak;
2
+
3
+ // @import "../common.module.less"
5
4
 
6
5
  .service_ChatWindow_Drawer,
7
6
  .ChatWindow_Modal {
@@ -151,6 +150,8 @@
151
150
  display: flex;
152
151
  flex-direction: column;
153
152
  align-items: flex-end;
153
+
154
+
154
155
  }
155
156
  }
156
157
  .right {
@@ -185,6 +186,7 @@
185
186
  .main_content_flag{
186
187
  width: 100%;
187
188
  }
189
+
188
190
  .main_content_flag:hover{
189
191
  .operate_modal {
190
192
  // display: block;
@@ -204,6 +206,7 @@
204
206
  line-height: 1;
205
207
  p{
206
208
  word-break: break-all;
209
+ white-space: break-spaces;
207
210
  }
208
211
  p,
209
212
  li {
@@ -217,6 +220,13 @@
217
220
  padding: 10px 0;
218
221
  }
219
222
  ol {
223
+ list-style: decimal;
224
+ padding-inline-start: 20px;
225
+
226
+ li{
227
+ list-style-type: auto;
228
+ }
229
+
220
230
  li p {
221
231
  padding: 4px 0;
222
232
  font-size: 14px;
@@ -235,6 +245,10 @@
235
245
  margin: 4px 0;
236
246
  }
237
247
  }
248
+ .sign{
249
+ background-color: #1890ff;
250
+ color: #fff;
251
+ }
238
252
  }
239
253
  .operate_modal {
240
254
  // display: none;
@@ -415,6 +429,7 @@
415
429
  font-weight: 400;
416
430
  line-height: 1.8;
417
431
  cursor: pointer;
432
+ list-style-type: none;
418
433
  }
419
434
  }
420
435
  .time {
@@ -1178,6 +1193,10 @@
1178
1193
  display: flex;
1179
1194
  align-items: center;
1180
1195
  border-bottom: 1px solid @color-border-secondary;
1196
+ cursor: pointer;
1197
+ &:hover{
1198
+ background-color: #EBEBEB;
1199
+ }
1181
1200
  .head_img{
1182
1201
  width: 36px;
1183
1202
  height: 36px;
@@ -1233,6 +1252,12 @@
1233
1252
  }
1234
1253
  }
1235
1254
  }
1255
+ .list_summary_active{
1256
+ background-color: @color-background-primary-weak;
1257
+ &:hover{
1258
+ background-color: @color-background-primary-weak;
1259
+ }
1260
+ }
1236
1261
 
1237
1262
  //详情
1238
1263
  .list_detail{
@@ -1263,11 +1288,10 @@
1263
1288
  display: flex;
1264
1289
  justify-content: space-between;
1265
1290
  align-items: center;
1266
- margin-bottom: 9px;
1291
+ margin-bottom: 4px;
1267
1292
  p {
1268
- color: @color-text-Tr;
1269
- font-size: 16px;
1270
- font-weight: 600;
1293
+ color: @color-text-Secondary-Tr;
1294
+ font-size: 14px;
1271
1295
  line-height: 1.5;
1272
1296
  }
1273
1297
  .time {
@@ -1282,12 +1306,12 @@
1282
1306
  line-height: 150%;
1283
1307
  overflow: hidden;
1284
1308
  text-overflow: ellipsis;
1285
- -webkit-box-orient: vertical;
1286
- -webkit-line-clamp: 2;
1287
- display: -webkit-box;
1309
+ // -webkit-box-orient: vertical;
1310
+ // -webkit-line-clamp: 2;
1311
+ // display: -webkit-box;
1288
1312
 
1289
- max-height: 40px;
1290
- word-break: break-all;
1313
+ max-height: 21px;
1314
+ white-space: nowrap;
1291
1315
  span {
1292
1316
  color: @color-text-primary;
1293
1317
  }