bhd-components 0.7.12 → 0.7.14

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.
@@ -78,6 +78,7 @@ const CustomerService = (props)=>{
78
78
  let isPosition = useRef(true);
79
79
  let recommendeQuestionID = useRef([]); //推荐问题id
80
80
  let videoHotQuestionsList = useRef([]); //视频热门问题
81
+ let newHotQuestionsList = useRef([]); //视频热门问题
81
82
  const mid = props.userData.mid;
82
83
  const remarkable = new Remarkable({
83
84
  highlight: function(str, lang) {
@@ -306,31 +307,76 @@ const CustomerService = (props)=>{
306
307
  } catch (error) {}
307
308
  }, 3000);
308
309
  };
309
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
310
- const sendGreetingMessage = (type)=>{
311
- let questionsList = [];
312
- let obj = {};
313
- if (type == 1) {
314
- console.log(hotQuestionsList, '33322221111');
315
- questionsList = hotQuestionsList.map((item, index)=>{
316
- if (index < 3) {
317
- return {
318
- key: "messageSource",
319
- value: item.id,
320
- question: item.question,
321
- answer: item.answer
310
+ //发送欢迎语,视频页面
311
+ const sendWelcomMessage = ()=>{
312
+ if (config.type == 'video') {
313
+ let params = config.params;
314
+ let videoId = params.videoId;
315
+ let watchTime = params.videoProgress;
316
+ let courseId = getQuery('yc_id');
317
+ let sectionId = params.VideoBriefSummaryId;
318
+ // let courseId="20899",
319
+ // sectionId= "462347",
320
+ // videoId= "29715",
321
+ // watchTime= 677
322
+ if (videoId && courseId && sectionId) {
323
+ http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
324
+ "recommendedQuestions": [],
325
+ "contexts": [
326
+ {
327
+ "type": "VIDEO",
328
+ "courseId": courseId,
329
+ "sectionId": sectionId,
330
+ "videoId": videoId,
331
+ "watchTime": watchTime
332
+ }
333
+ ],
334
+ "maximum": 3
335
+ }).then((res)=>{
336
+ let data = res.data.questions;
337
+ let questionsList = data.map((item, index)=>{
338
+ if (index < 3) {
339
+ return {
340
+ key: "messageSource",
341
+ value: item.id,
342
+ question: item.question,
343
+ answer: item.answer
344
+ };
345
+ } else {
346
+ return null;
347
+ }
348
+ });
349
+ let obj = {
350
+ roomId: roomId,
351
+ sender: "AI",
352
+ recevier: mid,
353
+ message: `Hi,我是智能学习助手,你遇到了什么问题?`,
354
+ extraInfos: questionsList.length > 0 ? questionsList : null
322
355
  };
323
- } else {
324
- return null;
325
- }
326
- });
327
- questionsList = questionsList.filter((i)=>i != null);
328
- obj = {
356
+ if (pageNumHistory <= 1) {
357
+ setHistoryMessageList((historyMessageList)=>{
358
+ let newHistoryMessageList = historyMessageList.filter((e)=>e.id != '123456_date');
359
+ newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
360
+ id: '123456_date',
361
+ upvoted: false,
362
+ downvoted: false,
363
+ quotedMessage: "",
364
+ createdAt: getDataTime(-1),
365
+ extraInfo: JSON.stringify(obj.extraInfos)
366
+ }));
367
+ return newHistoryMessageList;
368
+ });
369
+ scrollToBottom();
370
+ }
371
+ return;
372
+ }).catch(()=>{});
373
+ }
374
+ } else {
375
+ let obj = {
329
376
  roomId: roomId,
330
377
  sender: "AI",
331
378
  recevier: mid,
332
- message: `Hi,我是智能学习助手,你遇到了什么问题?`,
333
- extraInfos: questionsList
379
+ message: `Hi,我是智能学习助手,你遇到了什么问题?`
334
380
  };
335
381
  if (pageNumHistory <= 1) {
336
382
  setHistoryMessageList((historyMessageList)=>{
@@ -341,12 +387,84 @@ const CustomerService = (props)=>{
341
387
  downvoted: false,
342
388
  quotedMessage: "",
343
389
  createdAt: getDataTime(-1),
344
- extraInfo: JSON.stringify(obj.extraInfos)
390
+ // extraInfo: JSON.stringify(obj.extraInfos),
391
+ extraInfo: JSON.stringify([
392
+ {
393
+ key: "messageSource",
394
+ value: "knowledgebase"
395
+ }
396
+ ])
345
397
  }));
346
398
  return newHistoryMessageList;
347
399
  });
348
400
  scrollToBottom();
349
401
  }
402
+ }
403
+ };
404
+ //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
405
+ const sendGreetingMessage = (type)=>{
406
+ let questionsList = [];
407
+ let obj = {};
408
+ if (type == 1) {
409
+ sendWelcomMessage();
410
+ // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
411
+ // if(newHotQuestionsList.current.length > 0){
412
+ // questionsList = newHotQuestionsList.current.map((item, index) => {
413
+ // if (index < 3) {
414
+ // return {
415
+ // key: "messageSource",
416
+ // value: item.id,
417
+ // question: item.question,
418
+ // answer: item.answer,
419
+ // };
420
+ // } else {
421
+ // return null;
422
+ // }
423
+ // });
424
+ // }else{
425
+ // questionsList = hotQuestionsList.map((item, index) => {
426
+ // if (index < 3) {
427
+ // return {
428
+ // key: "messageSource",
429
+ // value: item.id,
430
+ // question: item.question,
431
+ // answer: item.answer,
432
+ // };
433
+ // } else {
434
+ // return null;
435
+ // }
436
+ // });
437
+ // }
438
+ // questionsList = questionsList.filter((i) => i != null);
439
+ // obj = {
440
+ // roomId: roomId,
441
+ // sender: "AI",
442
+ // recevier: mid,
443
+ // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
444
+ // extraInfos: questionsList,
445
+ // };
446
+ // if(pageNumHistory <= 1){
447
+ // setHistoryMessageList((historyMessageList) => {
448
+ // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
449
+ // newHistoryMessageList.push({
450
+ // ...obj,
451
+ // id: '123456_date',
452
+ // upvoted: false,
453
+ // downvoted: false,
454
+ // quotedMessage: "",
455
+ // createdAt: getDataTime(-1),
456
+ // extraInfo: JSON.stringify(obj.extraInfos),
457
+ // // extraInfo: JSON.stringify([
458
+ // // {
459
+ // // key: "messageSource",
460
+ // // value: "knowledgebase",
461
+ // // },
462
+ // // ]),
463
+ // });
464
+ // return newHistoryMessageList;
465
+ // });
466
+ // scrollToBottom();
467
+ // }
350
468
  return;
351
469
  } else if (type == 2) {
352
470
  obj = {
@@ -526,8 +644,8 @@ const CustomerService = (props)=>{
526
644
  });
527
645
  };
528
646
  //发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息,flag == 3 是针对视频页面点击底部推荐问题
529
- const sendMessage = (item, flag)=>{
530
- // console.log(item,flag,888888888);
647
+ const sendMessage = (item, flag, type = '')=>{
648
+ console.log(item, flag, 888888888);
531
649
  let questions = [];
532
650
  if (item && flag) {
533
651
  questions = [
@@ -587,7 +705,7 @@ const CustomerService = (props)=>{
587
705
  key: "questionId",
588
706
  value: flag == 1 ? questions.value : questions.id,
589
707
  answer: questions.answer
590
- });
708
+ }, type);
591
709
  setKeyWord("");
592
710
  setQuestionsList([]);
593
711
  setCitationContent({});
@@ -637,7 +755,7 @@ const CustomerService = (props)=>{
637
755
  }
638
756
  };
639
757
  //向知识库发送问题 或答案 type:1 发送问题 2 接受答案
640
- const sendingExistingIssues = (type, obj, questions)=>{
758
+ const sendingExistingIssues = (type, obj, questions, problemType)=>{
641
759
  if (pageNumHistory <= 1) {
642
760
  setHistoryMessageList((historyMessageList)=>{
643
761
  let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
@@ -688,10 +806,10 @@ const CustomerService = (props)=>{
688
806
  }
689
807
  ]
690
808
  };
691
- sendingExistingIssues(2, dataObj, "");
809
+ sendingExistingIssues(2, dataObj, "", problemType);
692
810
  testLabQuestion(obj.message, questions.answer, "");
693
811
  }
694
- if (type == 2 && config && config.type == 'video') {
812
+ if (type == 2 && config && config.type == 'video' && problemType != 'AssociativeProblem') {
695
813
  //先请求问题列表
696
814
  videoPageQuestiionsList(2);
697
815
  }
@@ -739,6 +857,7 @@ const CustomerService = (props)=>{
739
857
  obj.regenerate = false;
740
858
  }
741
859
  let data = JSON.stringify(obj);
860
+ let flagKeyWord = keyWord;
742
861
  setKeyWord("");
743
862
  setQuestionsList([]);
744
863
  setTimeout(()=>{
@@ -881,7 +1000,9 @@ const CustomerService = (props)=>{
881
1000
  }
882
1001
  if (msg.finished) {
883
1002
  setFinished(true); //发送结束
884
- videoPageQuestiionsList(2);
1003
+ if (!flagKeyWord) {
1004
+ videoPageQuestiionsList(2);
1005
+ }
885
1006
  // isPosition.current = true;
886
1007
  setTimeout(()=>{
887
1008
  isPosition.current = true;
@@ -946,7 +1067,7 @@ const CustomerService = (props)=>{
946
1067
  } else {
947
1068
  let newHistoryMessageList2 = list1.map((item)=>{
948
1069
  message = item.message + obj.message;
949
- let extraInfo = [];
1070
+ let extraInfo = null;
950
1071
  // message = '抱歉,我暂时无法回答这样的问题。'
951
1072
  if (message == '抱歉,我暂时无法回答这样的问题。') {
952
1073
  extraInfo = videoHotQuestionsList.current.map((str, index)=>{
@@ -1345,8 +1466,8 @@ const CustomerService = (props)=>{
1345
1466
  let sectionId = params.VideoBriefSummaryId;
1346
1467
  // let courseId="20899",
1347
1468
  // sectionId= "462347",
1348
- // videoId= "29707",
1349
- // watchTime= 262
1469
+ // videoId= "29715",
1470
+ // watchTime= 677
1350
1471
  if (videoId && courseId && sectionId) {
1351
1472
  console.log(recommendeQuestionID.current, 'recommendeQuestionID.current');
1352
1473
  http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
@@ -1374,6 +1495,7 @@ const CustomerService = (props)=>{
1374
1495
  setBottomRecommendationQuestions(data);
1375
1496
  } else {
1376
1497
  setHotQuestionsList(data);
1498
+ newHotQuestionsList.current = data;
1377
1499
  }
1378
1500
  // let ids:any[] = [];
1379
1501
  // data.map((str: { id: string; })=>{
@@ -2039,7 +2161,7 @@ const CustomerService = (props)=>{
2039
2161
  ]
2040
2162
  }),
2041
2163
  item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsxs("ul", {
2042
- className: `${styles.association_problem} ${item.message == '抱歉,我暂时无法回答这样的问题。' ? 'association_problem_flag' : ''}`,
2164
+ className: `${styles.association_problem} ${item.message == '抱歉,我暂时无法回答这样的问题。' ? styles.association_problem_flag : ''}`,
2043
2165
  children: [
2044
2166
  item.message == '抱歉,我暂时无法回答这样的问题。' && /*#__PURE__*/ _jsx("li", {
2045
2167
  className: styles.related_issues_flag,
@@ -2301,6 +2423,7 @@ const CustomerService = (props)=>{
2301
2423
  } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2302
2424
  showTeacherBtn = false;
2303
2425
  }
2426
+ console.log(showTeacherBtn, 'dlvkdfl');
2304
2427
  /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2305
2428
  return /*#__PURE__*/ _jsxs("div", {
2306
2429
  className: `${styles.operate_modal_bottom}`,
@@ -2684,6 +2807,8 @@ const CustomerService = (props)=>{
2684
2807
  }
2685
2808
  }, 1000);
2686
2809
  }
2810
+ setBottomRecommendationQuestions([]);
2811
+ resettingBottomHei();
2687
2812
  },
2688
2813
  onPressEnter: (e)=>{
2689
2814
  // console.log('发送内容22222',props)
@@ -2694,6 +2819,8 @@ const CustomerService = (props)=>{
2694
2819
  clearTimeout(timer.current);
2695
2820
  setKeyWord("");
2696
2821
  setCitationContent({});
2822
+ setBottomRecommendationQuestions([]);
2823
+ resettingBottomHei();
2697
2824
  //查找是否是召唤老师回答并有相应的老师名称
2698
2825
  if (answerMode == 1 && teacherList.length > 0) {
2699
2826
  let list = teacherList.filter((v)=>v.name == keyWord.trim());
@@ -2912,7 +3039,7 @@ const CustomerService = (props)=>{
2912
3039
  className: styles.item,
2913
3040
  children: /*#__PURE__*/ _jsx("span", {
2914
3041
  onClick: ()=>{
2915
- sendMessage(item, 2);
3042
+ sendMessage(item, 2, 'AssociativeProblem');
2916
3043
  setKeyWord("");
2917
3044
  onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
2918
3045
  },
@@ -630,6 +630,44 @@
630
630
  }
631
631
 
632
632
 
633
+ .association_problem_flag{
634
+
635
+ li{
636
+ padding-left: 30px;
637
+ position: relative;
638
+ &::after{
639
+ content: '';
640
+ width: 6px;
641
+ height: 6px;
642
+ border-radius: 50%;
643
+ background-color: rgba(217, 217, 217, 1);
644
+ display: block;
645
+ position: absolute;
646
+ top: 26px;
647
+ left: 10px;
648
+ }
649
+ }
650
+
651
+ li:first-child{
652
+ padding-left:0;
653
+ &::after{
654
+ display: none;
655
+ }
656
+ }
657
+
658
+ .related_issues_flag{
659
+ span{
660
+ color: #000;
661
+ font-weight: 600;
662
+ border-bottom: 6px solid @color-background-primary-weak-hover;
663
+ display: inline-block;
664
+ height: 22px;
665
+ }
666
+
667
+ }
668
+ }
669
+
670
+
633
671
  .img_con{
634
672
  width: 100%;
635
673
  text-align: center;
@@ -757,33 +795,6 @@
757
795
  }
758
796
  }
759
797
 
760
- .association_problem_flag{
761
- padding-left: 30px;
762
-
763
- li{
764
- position: relative;
765
- &::after{
766
- content: '';
767
- width: 6px;
768
- height: 6px;
769
- border-radius: 50%;
770
- background-color: rgba(217, 217, 217, 1);
771
- display: block;
772
- position: absolute;
773
- top: 12px;
774
- left: 12px;
775
- }
776
- }
777
- .related_issues_flag{
778
- span{
779
- color: #000;
780
- font-weight: 600;
781
- border-bottom: 4px solid @color-background-primary-weak-hover;
782
- }
783
-
784
- }
785
- }
786
-
787
798
  .time {
788
799
  display: block;
789
800
  margin: 40px 0;