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.
@@ -80,6 +80,7 @@ var CustomerService = function(props) {
80
80
  var isPosition = useRef(true);
81
81
  var recommendeQuestionID = useRef([]); //推荐问题id
82
82
  var videoHotQuestionsList = useRef([]); //视频热门问题
83
+ var newHotQuestionsList = useRef([]); //视频热门问题
83
84
  var mid = props.userData.mid;
84
85
  var remarkable = new Remarkable({
85
86
  highlight: function highlight(str, lang) {
@@ -310,33 +311,78 @@ var CustomerService = function(props) {
310
311
  } catch (error) {}
311
312
  }, 3000);
312
313
  };
313
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
314
- var sendGreetingMessage = function(type) {
315
- var questionsList = [];
316
- var obj = {};
317
- if (type == 1) {
318
- console.log(hotQuestionsList, "33322221111");
319
- questionsList = hotQuestionsList.map(function(item, index) {
320
- if (index < 3) {
321
- return {
322
- key: "messageSource",
323
- value: item.id,
324
- question: item.question,
325
- answer: item.answer
314
+ //发送欢迎语,视频页面
315
+ var sendWelcomMessage = function() {
316
+ if (config.type == "video") {
317
+ var params = config.params;
318
+ var videoId = params.videoId;
319
+ var watchTime = params.videoProgress;
320
+ var courseId = getQuery("yc_id");
321
+ var sectionId = params.VideoBriefSummaryId;
322
+ // let courseId="20899",
323
+ // sectionId= "462347",
324
+ // videoId= "29715",
325
+ // watchTime= 677
326
+ if (videoId && courseId && sectionId) {
327
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
328
+ "recommendedQuestions": [],
329
+ "contexts": [
330
+ {
331
+ "type": "VIDEO",
332
+ "courseId": courseId,
333
+ "sectionId": sectionId,
334
+ "videoId": videoId,
335
+ "watchTime": watchTime
336
+ }
337
+ ],
338
+ "maximum": 3
339
+ }).then(function(res) {
340
+ var data = res.data.questions;
341
+ var questionsList = data.map(function(item, index) {
342
+ if (index < 3) {
343
+ return {
344
+ key: "messageSource",
345
+ value: item.id,
346
+ question: item.question,
347
+ answer: item.answer
348
+ };
349
+ } else {
350
+ return null;
351
+ }
352
+ });
353
+ var obj = {
354
+ roomId: roomId,
355
+ sender: "AI",
356
+ recevier: mid,
357
+ message: "Hi,我是智能学习助手,你遇到了什么问题?",
358
+ extraInfos: questionsList.length > 0 ? questionsList : null
326
359
  };
327
- } else {
328
- return null;
329
- }
330
- });
331
- questionsList = questionsList.filter(function(i) {
332
- return i != null;
333
- });
334
- obj = {
360
+ if (pageNumHistory <= 1) {
361
+ setHistoryMessageList(function(historyMessageList) {
362
+ var newHistoryMessageList = historyMessageList.filter(function(e) {
363
+ return e.id != "123456_date";
364
+ });
365
+ newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
366
+ id: "123456_date",
367
+ upvoted: false,
368
+ downvoted: false,
369
+ quotedMessage: "",
370
+ createdAt: getDataTime(-1),
371
+ extraInfo: JSON.stringify(obj.extraInfos)
372
+ }));
373
+ return newHistoryMessageList;
374
+ });
375
+ scrollToBottom();
376
+ }
377
+ return;
378
+ }).catch(function() {});
379
+ }
380
+ } else {
381
+ var obj = {
335
382
  roomId: roomId,
336
383
  sender: "AI",
337
384
  recevier: mid,
338
- message: "Hi,我是智能学习助手,你遇到了什么问题?",
339
- extraInfos: questionsList
385
+ message: "Hi,我是智能学习助手,你遇到了什么问题?"
340
386
  };
341
387
  if (pageNumHistory <= 1) {
342
388
  setHistoryMessageList(function(historyMessageList) {
@@ -349,12 +395,84 @@ var CustomerService = function(props) {
349
395
  downvoted: false,
350
396
  quotedMessage: "",
351
397
  createdAt: getDataTime(-1),
352
- extraInfo: JSON.stringify(obj.extraInfos)
398
+ // extraInfo: JSON.stringify(obj.extraInfos),
399
+ extraInfo: JSON.stringify([
400
+ {
401
+ key: "messageSource",
402
+ value: "knowledgebase"
403
+ }
404
+ ])
353
405
  }));
354
406
  return newHistoryMessageList;
355
407
  });
356
408
  scrollToBottom();
357
409
  }
410
+ }
411
+ };
412
+ //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
413
+ var sendGreetingMessage = function(type) {
414
+ var questionsList = [];
415
+ var obj = {};
416
+ if (type == 1) {
417
+ sendWelcomMessage();
418
+ // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
419
+ // if(newHotQuestionsList.current.length > 0){
420
+ // questionsList = newHotQuestionsList.current.map((item, index) => {
421
+ // if (index < 3) {
422
+ // return {
423
+ // key: "messageSource",
424
+ // value: item.id,
425
+ // question: item.question,
426
+ // answer: item.answer,
427
+ // };
428
+ // } else {
429
+ // return null;
430
+ // }
431
+ // });
432
+ // }else{
433
+ // questionsList = hotQuestionsList.map((item, index) => {
434
+ // if (index < 3) {
435
+ // return {
436
+ // key: "messageSource",
437
+ // value: item.id,
438
+ // question: item.question,
439
+ // answer: item.answer,
440
+ // };
441
+ // } else {
442
+ // return null;
443
+ // }
444
+ // });
445
+ // }
446
+ // questionsList = questionsList.filter((i) => i != null);
447
+ // obj = {
448
+ // roomId: roomId,
449
+ // sender: "AI",
450
+ // recevier: mid,
451
+ // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
452
+ // extraInfos: questionsList,
453
+ // };
454
+ // if(pageNumHistory <= 1){
455
+ // setHistoryMessageList((historyMessageList) => {
456
+ // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
457
+ // newHistoryMessageList.push({
458
+ // ...obj,
459
+ // id: '123456_date',
460
+ // upvoted: false,
461
+ // downvoted: false,
462
+ // quotedMessage: "",
463
+ // createdAt: getDataTime(-1),
464
+ // extraInfo: JSON.stringify(obj.extraInfos),
465
+ // // extraInfo: JSON.stringify([
466
+ // // {
467
+ // // key: "messageSource",
468
+ // // value: "knowledgebase",
469
+ // // },
470
+ // // ]),
471
+ // });
472
+ // return newHistoryMessageList;
473
+ // });
474
+ // scrollToBottom();
475
+ // }
358
476
  return;
359
477
  } else if (type == 2) {
360
478
  obj = {
@@ -539,7 +657,8 @@ var CustomerService = function(props) {
539
657
  };
540
658
  //发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息,flag == 3 是针对视频页面点击底部推荐问题
541
659
  var sendMessage = function(item, flag) {
542
- // console.log(item,flag,888888888);
660
+ var type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
661
+ console.log(item, flag, 888888888);
543
662
  var questions = [];
544
663
  if (item && flag) {
545
664
  questions = [
@@ -601,7 +720,7 @@ var CustomerService = function(props) {
601
720
  key: "questionId",
602
721
  value: flag == 1 ? questions.value : questions.id,
603
722
  answer: questions.answer
604
- });
723
+ }, type);
605
724
  setKeyWord("");
606
725
  setQuestionsList([]);
607
726
  setCitationContent({});
@@ -653,7 +772,7 @@ var CustomerService = function(props) {
653
772
  }
654
773
  };
655
774
  //向知识库发送问题 或答案 type:1 发送问题 2 接受答案
656
- var sendingExistingIssues = function(type, obj, questions) {
775
+ var sendingExistingIssues = function(type, obj, questions, problemType) {
657
776
  if (pageNumHistory <= 1) {
658
777
  setHistoryMessageList(function(historyMessageList) {
659
778
  var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
@@ -704,10 +823,10 @@ var CustomerService = function(props) {
704
823
  }
705
824
  ]
706
825
  };
707
- sendingExistingIssues(2, dataObj, "");
826
+ sendingExistingIssues(2, dataObj, "", problemType);
708
827
  testLabQuestion(obj.message, questions.answer, "");
709
828
  }
710
- if (type == 2 && config && config.type == "video") {
829
+ if (type == 2 && config && config.type == "video" && problemType != "AssociativeProblem") {
711
830
  //先请求问题列表
712
831
  videoPageQuestiionsList(2);
713
832
  }
@@ -757,6 +876,7 @@ var CustomerService = function(props) {
757
876
  obj.regenerate = false;
758
877
  }
759
878
  var data = JSON.stringify(obj);
879
+ var flagKeyWord = keyWord;
760
880
  setKeyWord("");
761
881
  setQuestionsList([]);
762
882
  setTimeout(function() {
@@ -905,7 +1025,9 @@ var CustomerService = function(props) {
905
1025
  }
906
1026
  if (msg.finished) {
907
1027
  setFinished(true); //发送结束
908
- videoPageQuestiionsList(2);
1028
+ if (!flagKeyWord) {
1029
+ videoPageQuestiionsList(2);
1030
+ }
909
1031
  // isPosition.current = true;
910
1032
  setTimeout(function() {
911
1033
  isPosition.current = true;
@@ -972,7 +1094,7 @@ var CustomerService = function(props) {
972
1094
  } else {
973
1095
  var newHistoryMessageList2 = list1.map(function(item) {
974
1096
  message = item.message + obj.message;
975
- var extraInfo = [];
1097
+ var extraInfo = null;
976
1098
  // message = '抱歉,我暂时无法回答这样的问题。'
977
1099
  if (message == "抱歉,我暂时无法回答这样的问题。") {
978
1100
  extraInfo = videoHotQuestionsList.current.map(function(str, index) {
@@ -1377,8 +1499,8 @@ var CustomerService = function(props) {
1377
1499
  var sectionId = params.VideoBriefSummaryId;
1378
1500
  // let courseId="20899",
1379
1501
  // sectionId= "462347",
1380
- // videoId= "29707",
1381
- // watchTime= 262
1502
+ // videoId= "29715",
1503
+ // watchTime= 677
1382
1504
  if (videoId && courseId && sectionId) {
1383
1505
  console.log(recommendeQuestionID.current, "recommendeQuestionID.current");
1384
1506
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
@@ -1406,6 +1528,7 @@ var CustomerService = function(props) {
1406
1528
  setBottomRecommendationQuestions(data);
1407
1529
  } else {
1408
1530
  setHotQuestionsList(data);
1531
+ newHotQuestionsList.current = data;
1409
1532
  }
1410
1533
  // let ids:any[] = [];
1411
1534
  // data.map((str: { id: string; })=>{
@@ -2062,7 +2185,7 @@ var CustomerService = function(props) {
2062
2185
  ]
2063
2186
  }),
2064
2187
  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", {
2065
- className: "".concat(styles.association_problem, " ").concat(item.message == "抱歉,我暂时无法回答这样的问题。" ? "association_problem_flag" : ""),
2188
+ className: "".concat(styles.association_problem, " ").concat(item.message == "抱歉,我暂时无法回答这样的问题。" ? styles.association_problem_flag : ""),
2066
2189
  children: [
2067
2190
  item.message == "抱歉,我暂时无法回答这样的问题。" && /*#__PURE__*/ _jsx("li", {
2068
2191
  className: styles.related_issues_flag,
@@ -2336,6 +2459,7 @@ var CustomerService = function(props) {
2336
2459
  } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2337
2460
  showTeacherBtn = false;
2338
2461
  }
2462
+ console.log(showTeacherBtn, "dlvkdfl");
2339
2463
  /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2340
2464
  return /*#__PURE__*/ _jsxs("div", {
2341
2465
  className: "".concat(styles.operate_modal_bottom),
@@ -2733,6 +2857,8 @@ var CustomerService = function(props) {
2733
2857
  }
2734
2858
  }, 1000);
2735
2859
  }
2860
+ setBottomRecommendationQuestions([]);
2861
+ resettingBottomHei();
2736
2862
  },
2737
2863
  onPressEnter: function(e) {
2738
2864
  // console.log('发送内容22222',props)
@@ -2743,6 +2869,8 @@ var CustomerService = function(props) {
2743
2869
  clearTimeout(timer.current);
2744
2870
  setKeyWord("");
2745
2871
  setCitationContent({});
2872
+ setBottomRecommendationQuestions([]);
2873
+ resettingBottomHei();
2746
2874
  //查找是否是召唤老师回答并有相应的老师名称
2747
2875
  if (answerMode == 1 && teacherList.length > 0) {
2748
2876
  var list = teacherList.filter(function(v) {
@@ -2973,7 +3101,7 @@ var CustomerService = function(props) {
2973
3101
  className: styles.item,
2974
3102
  children: /*#__PURE__*/ _jsx("span", {
2975
3103
  onClick: function() {
2976
- sendMessage(item, 2);
3104
+ sendMessage(item, 2, "AssociativeProblem");
2977
3105
  setKeyWord("");
2978
3106
  onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
2979
3107
  },
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",