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.
@@ -105,9 +105,12 @@ const HistoryFun = (props)=>{
105
105
  number = index;
106
106
  }
107
107
  });
108
- const pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
108
+ let pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
109
+ if (number == 0) {
110
+ pageNumber = 1;
111
+ }
109
112
  console.log(roomId, pageNumber, id, receiver, "第几页第几页第几页第几页第几页第几页");
110
- loadSpecifiedData(roomId, pageNumber, id, receiver);
113
+ loadSpecifiedData(roomId, pageNumber, id, receiver, keyWordProblem);
111
114
  onClose();
112
115
  setKeyWordProblem("");
113
116
  setTotalData([]);
@@ -370,7 +373,7 @@ const HistoryFun = (props)=>{
370
373
  return /*#__PURE__*/ _jsxs(_Fragment, {
371
374
  children: [
372
375
  /*#__PURE__*/ _jsxs("div", {
373
- className: styles.list_summary,
376
+ className: `${styles.list_summary} ${item.show ? styles.list_summary_active : ""}`,
374
377
  id: item.roomId,
375
378
  onClick: ()=>{
376
379
  if (item.count == 1) {
@@ -54,6 +54,7 @@ const CustomerService = (props)=>{
54
54
  // const [roomList,setRoomList] = useState([]);//聊天列表
55
55
  const [contactsList, setContactsList] = useState([]); //老师列表
56
56
  const [chatObj, setChatObj] = useState([]); //聊天记录id保存,用来在实验报告中记录
57
+ const [keyWordProblem, setKeyWordProblem] = useState(""); //历史记录搜索的内容
57
58
  const timer = useRef(null); //文本框输入时
58
59
  let receiveMessageTimer = useRef(null); //接收ai发回的消息
59
60
  let voiceCountdownTimer = useRef(null); //语音录制倒计时
@@ -62,6 +63,8 @@ const CustomerService = (props)=>{
62
63
  let chatRoomList = useRef(null); //获取聊天室列表
63
64
  const ctrl = useRef(); //停止生成ai回答时使用
64
65
  let childRef = useRef(null); //获取子组件方法
66
+ let scrollTopHei = useRef(0);
67
+ let isPosition = useRef(true);
65
68
  const mid = props.userData.mid;
66
69
  const remarkable = new Remarkable({
67
70
  highlight: function(str, lang) {
@@ -128,6 +131,16 @@ const CustomerService = (props)=>{
128
131
  getHistoryMessage(number, 2);
129
132
  }, 1000);
130
133
  }
134
+ //生成答案过程中
135
+ if (!finished && scrollTopHei.current > scrollTop) {
136
+ // setIsPosition(false);
137
+ isPosition.current = false;
138
+ }
139
+ if (!finished && clientHeight + scrollTop >= scrollHeight) {
140
+ // console.log('到顶了111');
141
+ isPosition.current = true;
142
+ }
143
+ scrollTopHei.current = scrollTop;
131
144
  }
132
145
  const content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
133
146
  if (content) {
@@ -241,26 +254,48 @@ const CustomerService = (props)=>{
241
254
  let questionsList = [];
242
255
  let obj = {};
243
256
  if (type == 1) {
244
- questionsList = hotQuestionsList.map((item, index)=>{
245
- if (index < 3) {
246
- return {
247
- key: "messageSource",
248
- value: item.id,
249
- question: item.question,
250
- answer: item.answer
251
- };
252
- } else {
253
- return null;
254
- }
255
- });
256
- questionsList = questionsList.filter((i)=>i != null);
257
+ // questionsList = hotQuestionsList.map((item, index) => {
258
+ // if (index < 3) {
259
+ // return {
260
+ // key: "messageSource",
261
+ // value: item.id,
262
+ // question: item.question,
263
+ // answer: item.answer,
264
+ // };
265
+ // } else {
266
+ // return null;
267
+ // }
268
+ // });
269
+ // questionsList = questionsList.filter((i) => i != null);
257
270
  obj = {
258
271
  roomId: roomId,
259
272
  sender: "AI",
260
273
  recevier: mid,
261
- message: `Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?`,
262
- extraInfos: questionsList
274
+ message: `Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?`
263
275
  };
276
+ if (pageNumHistory <= 1) {
277
+ setHistoryMessageList((historyMessageList)=>{
278
+ let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
279
+ id: 'p' + new Date().getTime(),
280
+ upvoted: false,
281
+ downvoted: false,
282
+ quotedMessage: "",
283
+ createdAt: getDataTime(-1),
284
+ // extraInfo: JSON.stringify(obj.extraInfos),
285
+ extraInfo: JSON.stringify([
286
+ {
287
+ key: "messageSource",
288
+ value: "knowledgebase"
289
+ }
290
+ ])
291
+ }));
292
+ return newHistoryMessageList;
293
+ });
294
+ setTimeout(()=>{
295
+ scrollToBottom();
296
+ }, 100);
297
+ }
298
+ return;
264
299
  } else if (type == 2) {
265
300
  obj = {
266
301
  roomId: roomId,
@@ -335,6 +370,24 @@ const CustomerService = (props)=>{
335
370
  message: `猜你想问:`,
336
371
  extraInfos: questionsList
337
372
  };
373
+ if (pageNumHistory <= 1) {
374
+ setHistoryMessageList((historyMessageList)=>{
375
+ let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
376
+ id: 'p' + new Date().getTime(),
377
+ upvoted: false,
378
+ downvoted: false,
379
+ quotedMessage: "",
380
+ createdAt: getDataTime(-1),
381
+ extraInfo: JSON.stringify(obj.extraInfos)
382
+ }));
383
+ return newHistoryMessageList;
384
+ });
385
+ setTimeout(()=>{
386
+ scrollToBottom();
387
+ }, 100);
388
+ }
389
+ console.log('不记录1111111');
390
+ return;
338
391
  }
339
392
  setKeyWord("");
340
393
  setQuestionsList([]);
@@ -402,11 +455,13 @@ const CustomerService = (props)=>{
402
455
  }));
403
456
  return newHistoryMessageList;
404
457
  });
405
- if (!lastId) {
406
- setTimeout(()=>{
407
- scrollToBottom();
408
- }, 100);
409
- }
458
+ // console.log(lastId,'消息发送给老师111');
459
+ // if (!lastId) {
460
+ setTimeout(()=>{
461
+ console.log('滚动到底部');
462
+ scrollToBottom();
463
+ }, 100);
464
+ // }
410
465
  }
411
466
  //判断当前窗口是否是
412
467
  if (type == 1) {
@@ -721,11 +776,19 @@ const CustomerService = (props)=>{
721
776
  }
722
777
  if (msg.finished) {
723
778
  setFinished(true); //发送结束
779
+ // isPosition.current = true;
780
+ setTimeout(()=>{
781
+ isPosition.current = true;
782
+ }, 100);
724
783
  testLabQuestion(JSON.parse(data).message, content, "");
725
784
  }
726
785
  },
727
786
  onclose () {
728
787
  setFinished(true); //发送结束
788
+ // isPosition.current = true;
789
+ setTimeout(()=>{
790
+ isPosition.current = true;
791
+ }, 100);
729
792
  setHistoryMessageList((historyMessageList)=>{
730
793
  return historyMessageList.filter((item)=>item.id != "123456");
731
794
  });
@@ -789,7 +852,9 @@ const CustomerService = (props)=>{
789
852
  }
790
853
  });
791
854
  setTimeout(()=>{
792
- scrollToBottom();
855
+ if (isPosition.current) {
856
+ scrollToBottom();
857
+ }
793
858
  }, 10);
794
859
  };
795
860
  //问题记录到实验报告中
@@ -835,7 +900,7 @@ const CustomerService = (props)=>{
835
900
  //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
836
901
  const getHistoryMessage = (pageNum, flag, id = "1", raw_data = [])=>{
837
902
  clearTimeout(roomMessage.current);
838
- // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
903
+ console.log(pageNum, flag, 'dkfjvndfjvndfkvdf');
839
904
  // flag == 1 时已经设置好了位置标记
840
905
  let last_id = "";
841
906
  if (flag == 2 && historyMessageList.length > 0) {
@@ -924,6 +989,11 @@ const CustomerService = (props)=>{
924
989
  if (problem != undefined && problem.user != undefined && problem.question != undefined) {
925
990
  sendToTeacher(1);
926
991
  }
992
+ // if(flag == 1){
993
+ setTimeout(()=>{
994
+ setKeyWordProblem('');
995
+ }, 3100);
996
+ // }
927
997
  } else {
928
998
  setPageCount(0);
929
999
  setGreetingMessage(true);
@@ -1481,6 +1551,16 @@ const CustomerService = (props)=>{
1481
1551
  }
1482
1552
  }
1483
1553
  let dataTime = time;
1554
+ if (lastId == item.id && keyWordProblem != '') {
1555
+ message = remarkable.render(message);
1556
+ console.log(message, 444444);
1557
+ message = message.replaceAll(keyWordProblem, (e)=>{
1558
+ return `<span class=${styles.sign}>${e}</span>`;
1559
+ });
1560
+ console.log(message, 55555);
1561
+ } else {
1562
+ message = remarkable.render(message);
1563
+ }
1484
1564
  if (item.sender == mid) {
1485
1565
  //只有引用和复制功能
1486
1566
  li = /*#__PURE__*/ _jsxs(_Fragment, {
@@ -1547,7 +1627,7 @@ const CustomerService = (props)=>{
1547
1627
  className: styles.content,
1548
1628
  children: /*#__PURE__*/ _jsx("p", {
1549
1629
  dangerouslySetInnerHTML: {
1550
- __html: remarkable.render(message)
1630
+ __html: message
1551
1631
  },
1552
1632
  className: styles.content_child
1553
1633
  })
@@ -1644,7 +1724,7 @@ const CustomerService = (props)=>{
1644
1724
  children: [
1645
1725
  /*#__PURE__*/ _jsx("p", {
1646
1726
  dangerouslySetInnerHTML: {
1647
- __html: remarkable.render(message)
1727
+ __html: message
1648
1728
  },
1649
1729
  className: styles.content_child
1650
1730
  }),
@@ -1880,7 +1960,7 @@ const CustomerService = (props)=>{
1880
1960
  return /*#__PURE__*/ _jsxs("div", {
1881
1961
  className: `${styles.operate_modal_bottom}`,
1882
1962
  style: {
1883
- position: showStopBtn ? 'sticky' : 'relative'
1963
+ position: showStopBtn && isPosition.current ? 'sticky' : 'relative'
1884
1964
  },
1885
1965
  children: [
1886
1966
  /*#__PURE__*/ _jsxs("p", {
@@ -2147,6 +2227,11 @@ const CustomerService = (props)=>{
2147
2227
  setQuestionsList([]);
2148
2228
  setAnswerMode(-1);
2149
2229
  setTeacherList([]);
2230
+ setTimeout(()=>{
2231
+ setQuestionsList([]);
2232
+ setTeacherList([]);
2233
+ clearTimeout(timer.current);
2234
+ }, 200);
2150
2235
  setHistoryMessageList((historyMessageList)=>{
2151
2236
  return historyMessageList.filter((item)=>item.id != "-1");
2152
2237
  });
@@ -2250,6 +2335,11 @@ const CustomerService = (props)=>{
2250
2335
  setQuestionsList([]);
2251
2336
  setAnswerMode(-1);
2252
2337
  setTeacherList([]);
2338
+ setTimeout(()=>{
2339
+ setQuestionsList([]);
2340
+ setTeacherList([]);
2341
+ clearTimeout(timer.current);
2342
+ }, 200);
2253
2343
  setHistoryMessageList((historyMessageList)=>{
2254
2344
  return historyMessageList.filter((item)=>item.id != "-1");
2255
2345
  });
@@ -2363,11 +2453,14 @@ const CustomerService = (props)=>{
2363
2453
  }
2364
2454
  };
2365
2455
  //加载指定数据,点击历史记录
2366
- const loadSpecifiedData = (renewRoomId, page, id, receiver)=>{
2456
+ const loadSpecifiedData = (renewRoomId, page, id, receiver, keyWordProblem)=>{
2367
2457
  // let renewRoomId = '4a615d7126b343f78d10dcb06dbc29b0';
2368
2458
  // let page = 1;
2369
2459
  // let id = '0e459f0a3a62438698f170b42b94d150';
2370
2460
  // let receiver = mid;
2461
+ if (keyWordProblem != '') {
2462
+ setKeyWordProblem(keyWordProblem);
2463
+ }
2371
2464
  if (page != 1) {
2372
2465
  setPageNumHistory(page);
2373
2466
  }
@@ -2431,6 +2524,9 @@ const CustomerService = (props)=>{
2431
2524
  style: {
2432
2525
  maxHeight: `calc(100vh-${buttomHei + 48}px)`
2433
2526
  },
2527
+ onClick: ()=>{
2528
+ setKeyWordProblem('');
2529
+ },
2434
2530
  children: [
2435
2531
  loading ? /*#__PURE__*/ _jsx("div", {
2436
2532
  className: styles.loading,
@@ -2439,7 +2535,7 @@ const CustomerService = (props)=>{
2439
2535
  alt: ""
2440
2536
  })
2441
2537
  }) : "",
2442
- renderQuestion(),
2538
+ keyWordProblem ? renderQuestion() : renderQuestion(),
2443
2539
  bottomLoading ? /*#__PURE__*/ _jsx("div", {
2444
2540
  className: styles.loading,
2445
2541
  children: /*#__PURE__*/ _jsx("img", {
@@ -2495,6 +2591,9 @@ const CustomerService = (props)=>{
2495
2591
  }),
2496
2592
  /*#__PURE__*/ _jsxs("div", {
2497
2593
  className: `${styles.Drawer_wrap_main}`,
2594
+ onClick: ()=>{
2595
+ setKeyWordProblem('');
2596
+ },
2498
2597
  children: [
2499
2598
  /*#__PURE__*/ _jsxs("div", {
2500
2599
  className: `${styles.Drawer_main} ChatWindow_Modal_history_list`,
@@ -2527,7 +2626,7 @@ const CustomerService = (props)=>{
2527
2626
  alt: ""
2528
2627
  })
2529
2628
  }) : "",
2530
- renderQuestion()
2629
+ keyWordProblem ? renderQuestion() : renderQuestion()
2531
2630
  ]
2532
2631
  })
2533
2632
  ]
@@ -2561,6 +2660,9 @@ const CustomerService = (props)=>{
2561
2660
  showType == 3 ? /*#__PURE__*/ _jsxs("div", {
2562
2661
  className: `${styles.ChatWindow_Drawer}`,
2563
2662
  id: "",
2663
+ onClick: ()=>{
2664
+ setKeyWordProblem('');
2665
+ },
2564
2666
  children: [
2565
2667
  /*#__PURE__*/ _jsx("div", {
2566
2668
  className: `${styles.header_wrap} ${styles.header_wrap_newlabo}`,
@@ -2621,7 +2723,7 @@ const CustomerService = (props)=>{
2621
2723
  alt: ""
2622
2724
  })
2623
2725
  }) : "",
2624
- renderQuestion()
2726
+ keyWordProblem ? renderQuestion() : renderQuestion()
2625
2727
  ]
2626
2728
  }),
2627
2729
  /*#__PURE__*/ _jsxs("div", {
@@ -2698,6 +2800,9 @@ const CustomerService = (props)=>{
2698
2800
  style: {
2699
2801
  maxHeight: `${window.innerHeight - 148 - buttomHei}px`
2700
2802
  },
2803
+ onClick: ()=>{
2804
+ setKeyWordProblem('');
2805
+ },
2701
2806
  children: [
2702
2807
  /*#__PURE__*/ _jsx(ContactsList, {
2703
2808
  type: 4,
@@ -2723,7 +2828,7 @@ const CustomerService = (props)=>{
2723
2828
  alt: ""
2724
2829
  })
2725
2830
  }) : "",
2726
- renderQuestion()
2831
+ keyWordProblem ? renderQuestion() : renderQuestion()
2727
2832
  ]
2728
2833
  })
2729
2834
  ]
@@ -2815,7 +2920,7 @@ const CustomerService = (props)=>{
2815
2920
  alt: ""
2816
2921
  })
2817
2922
  }) : "",
2818
- renderQuestion()
2923
+ keyWordProblem ? renderQuestion() : renderQuestion()
2819
2924
  ]
2820
2925
  }),
2821
2926
  /*#__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
  }