bhd-components 0.7.16 → 0.7.18

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.
@@ -25,7 +25,7 @@ import "highlight.js/styles/default.css";
25
25
  import { render } from "react-dom";
26
26
  import Provider from "../provider";
27
27
  var TextArea = Input.TextArea;
28
- import "./html2canvas.test.js";
28
+ // import './html2canvas.test.js';
29
29
  import knowledge_icon from "./images/knowledge_icon.png";
30
30
  // import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
31
31
  import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate } from "./function"; //一些方法
@@ -96,10 +96,10 @@ var CustomerService = function(props) {
96
96
  }
97
97
  });
98
98
  useEffect(function() {
99
- if (config && config.type == "video") {
100
- //获取热门推荐
101
- videoPageQuestiionsList(1);
102
- }
99
+ // if(config && config.type == 'video'){
100
+ // //获取热门推荐
101
+ // videoPageQuestiionsList(1);
102
+ // }
103
103
  setShowType(initShowType);
104
104
  }, [
105
105
  initShowType
@@ -155,29 +155,23 @@ var CustomerService = function(props) {
155
155
  if (showType == 5 || showScreenshot) {
156
156
  try {
157
157
  setImgBese64("");
158
- // html2canvas(document.getElementsByTagName('html')[0],{
159
- // // ignoreElements:(element)=>{
160
- // // if(element.compareDocumentPosition(dom)===2)return true
161
- // // return false
162
- // // }
163
- // }).then((canvas)=>{
164
- // console.log(canvas,22222);
165
- // setTimeout(()=>{
166
- var dom = document.getElementById(screenshotAreaId);
167
- html2canvas(dom, {
158
+ // let dom = document.getElementById(screenshotAreaId);
159
+ html2canvas(screenshotAreaId, {
168
160
  useCORS: true,
169
161
  // allowTaint: true, // 污染处理
170
- scale: 1
162
+ scale: 1,
163
+ // logging:true,
164
+ ignoreElements: function(element) {
165
+ if (element.compareDocumentPosition(screenshotAreaId) === 2) return true;
166
+ return false;
167
+ }
171
168
  }).then(function(canvas) {
172
- // document.body.appendChild(canvas);
173
169
  // document.body.appendChild(canvas);
174
170
  console.log(canvas, 99999);
175
171
  // var base64URL = canvas.toDataURL('image/jpeg')
176
172
  var base64URL = canvas.toDataURL("image/jpg", 1.0);
177
173
  setImgBese64(base64URL);
178
174
  });
179
- // },100)
180
- // })
181
175
  } catch (error) {
182
176
  console.log(error);
183
177
  }
@@ -319,10 +313,10 @@ var CustomerService = function(props) {
319
313
  var watchTime = params.videoProgress;
320
314
  var courseId = getQuery("yc_id");
321
315
  var sectionId = params.VideoBriefSummaryId;
322
- // let courseId="20899",
323
- // sectionId= "462347",
324
- // videoId= "29715",
325
- // watchTime= 677
316
+ // let courseId="31007",
317
+ // sectionId= "446168",
318
+ // videoId= "71399",
319
+ // watchTime= 527
326
320
  if (videoId && courseId && sectionId) {
327
321
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
328
322
  "recommendedQuestions": [],
@@ -349,6 +343,9 @@ var CustomerService = function(props) {
349
343
  answer: item.answer
350
344
  };
351
345
  });
346
+ recommendeQuestionID.current = data.map(function(item) {
347
+ return item.id;
348
+ });
352
349
  }
353
350
  console.log("dflkvmdfklvdf欢迎语", data);
354
351
  var obj = {
@@ -372,14 +369,13 @@ var CustomerService = function(props) {
372
369
  createdAt: getDataTime(-1),
373
370
  extraInfo: obj.extraInfos != null ? JSON.stringify(obj.extraInfos) : null
374
371
  }));
375
- console.log(newHistoryMessageList, 3333333333339999);
376
372
  return newHistoryMessageList;
377
373
  });
378
374
  scrollToBottom();
379
375
  }
380
376
  return;
381
377
  } catch (error) {}
382
- }).catch(function() {});
378
+ });
383
379
  }
384
380
  } else {
385
381
  var obj = {
@@ -413,71 +409,54 @@ var CustomerService = function(props) {
413
409
  }
414
410
  }
415
411
  };
416
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
412
+ //无ai权限时,发送热门问题
413
+ var getAssociativeProblem = function() {
414
+ http.get("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions"), {
415
+ params: {
416
+ page: 1,
417
+ maxPageSize: 5
418
+ }
419
+ }).then(function(res) {
420
+ setFinished(true);
421
+ if (res.data.total > 0) {
422
+ var questionsList = res.data.questions.map(function(item) {
423
+ return {
424
+ key: "messageSource",
425
+ value: item.id,
426
+ question: item.question,
427
+ answer: item.answer
428
+ };
429
+ });
430
+ var obj = {
431
+ roomId: roomId,
432
+ sender: "AI",
433
+ recevier: mid,
434
+ message: "猜你想问:",
435
+ extraInfos: questionsList
436
+ };
437
+ if (pageNumHistory <= 1) {
438
+ setHistoryMessageList(function(historyMessageList) {
439
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
440
+ id: "p" + new Date().getTime(),
441
+ upvoted: false,
442
+ downvoted: false,
443
+ quotedMessage: "",
444
+ createdAt: getDataTime(-1),
445
+ extraInfo: JSON.stringify(obj.extraInfos)
446
+ }));
447
+ return newHistoryMessageList;
448
+ });
449
+ scrollToBottom();
450
+ }
451
+ return;
452
+ }
453
+ });
454
+ };
455
+ //AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
417
456
  var sendGreetingMessage = function(type) {
418
- var questionsList = [];
419
457
  var obj = {};
420
458
  if (type == 1) {
421
- console.log("dflkvmdfklvdf欢迎语");
422
459
  sendWelcomMessage();
423
- // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
424
- // if(newHotQuestionsList.current.length > 0){
425
- // questionsList = newHotQuestionsList.current.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
- // }else{
438
- // questionsList = hotQuestionsList.map((item, index) => {
439
- // if (index < 3) {
440
- // return {
441
- // key: "messageSource",
442
- // value: item.id,
443
- // question: item.question,
444
- // answer: item.answer,
445
- // };
446
- // } else {
447
- // return null;
448
- // }
449
- // });
450
- // }
451
- // questionsList = questionsList.filter((i) => i != null);
452
- // obj = {
453
- // roomId: roomId,
454
- // sender: "AI",
455
- // recevier: mid,
456
- // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
457
- // extraInfos: questionsList,
458
- // };
459
- // if(pageNumHistory <= 1){
460
- // setHistoryMessageList((historyMessageList) => {
461
- // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
462
- // newHistoryMessageList.push({
463
- // ...obj,
464
- // id: '123456_date',
465
- // upvoted: false,
466
- // downvoted: false,
467
- // quotedMessage: "",
468
- // createdAt: getDataTime(-1),
469
- // extraInfo: JSON.stringify(obj.extraInfos),
470
- // // extraInfo: JSON.stringify([
471
- // // {
472
- // // key: "messageSource",
473
- // // value: "knowledgebase",
474
- // // },
475
- // // ]),
476
- // });
477
- // return newHistoryMessageList;
478
- // });
479
- // scrollToBottom();
480
- // }
481
460
  return;
482
461
  } else if (type == 2) {
483
462
  obj = {
@@ -538,35 +517,7 @@ var CustomerService = function(props) {
538
517
  ]
539
518
  };
540
519
  } else if (type == 6) {
541
- questionsList = hotQuestionsList.map(function(item) {
542
- return {
543
- key: "messageSource",
544
- value: item.id,
545
- question: item.question,
546
- answer: item.answer
547
- };
548
- });
549
- obj = {
550
- roomId: roomId,
551
- sender: "AI",
552
- recevier: mid,
553
- message: "猜你想问:",
554
- extraInfos: questionsList
555
- };
556
- if (pageNumHistory <= 1) {
557
- setHistoryMessageList(function(historyMessageList) {
558
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
559
- id: "p" + new Date().getTime(),
560
- upvoted: false,
561
- downvoted: false,
562
- quotedMessage: "",
563
- createdAt: getDataTime(-1),
564
- extraInfo: JSON.stringify(obj.extraInfos)
565
- }));
566
- return newHistoryMessageList;
567
- });
568
- scrollToBottom();
569
- }
520
+ getAssociativeProblem();
570
521
  return;
571
522
  }
572
523
  setKeyWord("");
@@ -693,7 +644,7 @@ var CustomerService = function(props) {
693
644
  recevier: "AI",
694
645
  message: questions.question,
695
646
  quotedMessage: "",
696
- id: "654321",
647
+ id: "p" + new Date().getTime(),
697
648
  upvoted: false,
698
649
  downvoted: false,
699
650
  createdAt: getDataTime(-1),
@@ -753,7 +704,7 @@ var CustomerService = function(props) {
753
704
  recevier: "AI",
754
705
  message: keyWord,
755
706
  quotedMessage: citationContent.content,
756
- id: "654321",
707
+ id: "p" + new Date().getTime(),
757
708
  upvoted: false,
758
709
  downvoted: false,
759
710
  createdAt: getDataTime(-1),
@@ -781,7 +732,7 @@ var CustomerService = function(props) {
781
732
  if (pageNumHistory <= 1) {
782
733
  setHistoryMessageList(function(historyMessageList) {
783
734
  var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
784
- id: null,
735
+ id: "p" + new Date().getTime(),
785
736
  upvoted: false,
786
737
  downvoted: false,
787
738
  createdAt: getDataTime(-1),
@@ -792,10 +743,6 @@ var CustomerService = function(props) {
792
743
  scrollToBottom();
793
744
  }
794
745
  console.log(type, "接受答案77777");
795
- //获取下面的推荐问题
796
- // if(type == 2){
797
- // videoPageQuestiionsList(2);
798
- // }
799
746
  http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
800
747
  if (res.data.id) {
801
748
  if (pageNumHistory <= 1) {
@@ -844,11 +791,11 @@ var CustomerService = function(props) {
844
791
  ctrl.current = new AbortController();
845
792
  clearTimeout(receiveMessageTimer.current);
846
793
  receiveMessageTimer.current = setTimeout(function() {
847
- setHistoryMessageList(function(historyMessageList) {
848
- return historyMessageList.filter(function(item) {
849
- return item.id != "123456" && item.id != "654321";
850
- });
851
- });
794
+ // setHistoryMessageList((historyMessageList) => {
795
+ // return historyMessageList.filter(
796
+ // (item) => item.id != "123456" && item.id != "654321"
797
+ // );
798
+ // });
852
799
  setFinished(true);
853
800
  ctrl.current.abort();
854
801
  setHistoryMessageList(function(historyMessageList) {
@@ -863,6 +810,7 @@ var CustomerService = function(props) {
863
810
  });
864
811
  });
865
812
  }, 60 * 1000);
813
+ setFinished(false);
866
814
  if (config && config.type == "video" && config.params) {
867
815
  var params = config.params;
868
816
  var videoId = params.videoId;
@@ -1502,10 +1450,10 @@ var CustomerService = function(props) {
1502
1450
  var watchTime = params.videoProgress;
1503
1451
  var courseId = getQuery("yc_id");
1504
1452
  var sectionId = params.VideoBriefSummaryId;
1505
- // let courseId="20899",
1506
- // sectionId= "462347",
1507
- // videoId= "29715",
1508
- // watchTime= 677
1453
+ // let courseId="31007",
1454
+ // sectionId= "446168",
1455
+ // videoId= "71399",
1456
+ // watchTime= 527
1509
1457
  if (videoId && courseId && sectionId) {
1510
1458
  console.log(recommendeQuestionID.current, "recommendeQuestionID.current");
1511
1459
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
@@ -1535,17 +1483,13 @@ var CustomerService = function(props) {
1535
1483
  setHotQuestionsList(data);
1536
1484
  newHotQuestionsList.current = data;
1537
1485
  }
1538
- // let ids:any[] = [];
1539
- // data.map((str: { id: string; })=>{
1540
- // ids.push(str.id);
1541
- // })
1542
- // recommendeQuestionID.current = Array.from(new Set(recommendeQuestionID.current.concat(ids)));
1543
- resettingBottomHei();
1486
+ var ids = [];
1487
+ data.map(function(str) {
1488
+ ids.push(str.id);
1489
+ });
1490
+ recommendeQuestionID.current = Array.from(new Set(recommendeQuestionID.current.concat(ids)));
1544
1491
  scrollToBottom();
1545
- // console.log(data,99999);
1546
- // if(data.length < 4){
1547
- // getQuestiionsList('',4)
1548
- // }
1492
+ resettingBottomHei();
1549
1493
  }
1550
1494
  }).catch(function() {});
1551
1495
  }
@@ -1684,7 +1628,7 @@ var CustomerService = function(props) {
1684
1628
  }
1685
1629
  } else {
1686
1630
  if (document.getElementById("Drawer_buttom_modal")) {
1687
- var hei1 = document.getElementById("Drawer_buttom_modal").offsetHeight + document.getElementById("BottomAssociationProblem").offsetHeight;
1631
+ var hei1 = document.getElementById("Drawer_buttom_modal").offsetHeight + document.getElementById("BottomAssociationProblem_modal").offsetHeight;
1688
1632
  setButtomHei(hei1);
1689
1633
  }
1690
1634
  }
@@ -2202,7 +2146,6 @@ var CustomerService = function(props) {
2202
2146
  return /*#__PURE__*/ _jsx("li", {
2203
2147
  onClick: function() {
2204
2148
  sendMessage(list, 1);
2205
- recommendeQuestionID.current = recommendeQuestionID.current.concat(list.value);
2206
2149
  setBottomRecommendationQuestions([]);
2207
2150
  resettingBottomHei();
2208
2151
  },
@@ -2464,7 +2407,6 @@ var CustomerService = function(props) {
2464
2407
  } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2465
2408
  showTeacherBtn = false;
2466
2409
  }
2467
- console.log(showTeacherBtn, "dlvkdfl");
2468
2410
  /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2469
2411
  return /*#__PURE__*/ _jsxs("div", {
2470
2412
  className: "".concat(styles.operate_modal_bottom),
@@ -2757,7 +2699,7 @@ var CustomerService = function(props) {
2757
2699
  onClick: function() {
2758
2700
  setHistoryMessageList(function(historyMessageList) {
2759
2701
  var newHistoryMessageList = historyMessageList.concat({
2760
- id: -1,
2702
+ id: "p" + new Date().getTime(),
2761
2703
  roomId: roomId,
2762
2704
  sender: mid,
2763
2705
  recevier: "AI",
@@ -2795,7 +2737,7 @@ var CustomerService = function(props) {
2795
2737
  onClick: function() {
2796
2738
  setHistoryMessageList(function(historyMessageList) {
2797
2739
  var newHistoryMessageList = historyMessageList.concat({
2798
- id: -1,
2740
+ id: "p" + new Date().getTime(),
2799
2741
  roomId: roomId,
2800
2742
  sender: mid,
2801
2743
  recevier: "AI",
@@ -3121,23 +3063,51 @@ var CustomerService = function(props) {
3121
3063
  };
3122
3064
  //视频页面底部推荐问题
3123
3065
  var renderBottomAssociationProblem = function() {
3124
- return /*#__PURE__*/ _jsx("div", {
3125
- className: styles.issues_list_flag,
3126
- id: "BottomAssociationProblem",
3127
- children: bottomRecommendationQuestions.map(function(item) {
3128
- return /*#__PURE__*/ _jsx("p", {
3129
- onClick: function() {
3130
- sendMessage(item, 1);
3131
- if (config && config.type == "video") {
3132
- recommendeQuestionID.current = recommendeQuestionID.current.concat(item.id);
3133
- setBottomRecommendationQuestions([]);
3134
- resettingBottomHei();
3135
- }
3136
- },
3137
- children: item.question
3138
- }, item.id);
3139
- })
3140
- });
3066
+ if (showType == 1 || showType == 3) {
3067
+ return /*#__PURE__*/ _jsx("div", {
3068
+ className: styles.issues_list_flag,
3069
+ id: "BottomAssociationProblem",
3070
+ 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
+ });
3086
+ })
3087
+ });
3088
+ } else {
3089
+ return /*#__PURE__*/ _jsx("div", {
3090
+ className: styles.issues_list_flag,
3091
+ id: "BottomAssociationProblem_modal",
3092
+ 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
+ });
3108
+ })
3109
+ });
3110
+ }
3141
3111
  };
3142
3112
  //加载指定数据,点击历史记录
3143
3113
  var loadSpecifiedData = function(renewRoomId, page, id, receiver, keyWordProblem) {
@@ -3235,7 +3205,7 @@ var CustomerService = function(props) {
3235
3205
  className: styles.Drawer_buttom_Issues_List,
3236
3206
  children: [
3237
3207
  renderAssociationProblem(),
3238
- renderBottomAssociationProblem(),
3208
+ showType == 1 && renderBottomAssociationProblem(),
3239
3209
  /*#__PURE__*/ _jsx("div", {
3240
3210
  className: styles.Drawer_buttom,
3241
3211
  id: "Drawer_buttom",
@@ -3322,6 +3292,7 @@ var CustomerService = function(props) {
3322
3292
  className: styles.Drawer_buttom_Issues_List,
3323
3293
  children: [
3324
3294
  renderAssociationProblem(),
3295
+ showType == 2 && renderBottomAssociationProblem(),
3325
3296
  /*#__PURE__*/ _jsx("div", {
3326
3297
  className: styles.Drawer_buttom,
3327
3298
  id: "Drawer_buttom_modal",
@@ -3417,6 +3388,7 @@ var CustomerService = function(props) {
3417
3388
  className: "".concat(styles.Drawer_buttom_Issues_List, " ").concat(styles.Drawer_buttom_Issues_List_newlabo),
3418
3389
  children: [
3419
3390
  renderAssociationProblem(),
3391
+ showType == 3 && renderBottomAssociationProblem(),
3420
3392
  /*#__PURE__*/ _jsx("div", {
3421
3393
  className: styles.Drawer_buttom,
3422
3394
  id: "Drawer_buttom",
@@ -3524,6 +3496,7 @@ var CustomerService = function(props) {
3524
3496
  className: styles.Drawer_buttom_Issues_List,
3525
3497
  children: [
3526
3498
  renderAssociationProblem(),
3499
+ (showType == 4 || showType == 5) && renderBottomAssociationProblem(),
3527
3500
  /*#__PURE__*/ _jsx("div", {
3528
3501
  className: styles.Drawer_buttom,
3529
3502
  id: "Drawer_buttom_modal",
@@ -3614,6 +3587,7 @@ var CustomerService = function(props) {
3614
3587
  className: "".concat(styles.Drawer_buttom_Issues_List, " ").concat(styles.Drawer_buttom_Issues_List_newlabo),
3615
3588
  children: [
3616
3589
  renderAssociationProblem(),
3590
+ (showType == 4 || showType == 5) && renderBottomAssociationProblem(),
3617
3591
  /*#__PURE__*/ _jsx("div", {
3618
3592
  className: styles.Drawer_buttom,
3619
3593
  id: "Drawer_buttom",
@@ -398,7 +398,7 @@
398
398
  // 最后一行操作按钮
399
399
  .operate_modal_bottom{
400
400
  position: relative;
401
- top: 10px ;
401
+ top: 12px ;
402
402
  &::before{
403
403
  content: '';
404
404
  display: block;
@@ -406,7 +406,7 @@
406
406
  height: 1px;
407
407
  background-color: rgba(0, 0, 0, 0.06);
408
408
  position: absolute;
409
- bottom: 40px;
409
+ bottom: 42px;
410
410
  left: -16px;
411
411
  }
412
412
  &>p{
@@ -969,6 +969,8 @@
969
969
  border-radius: 38px;
970
970
  margin-bottom: 16px;
971
971
  line-height: 1.5;
972
+ display: inline-block;
973
+
972
974
  cursor: pointer;
973
975
  &:hover{
974
976
  background-color: @color-background-primary-weak;
@@ -395,7 +395,7 @@
395
395
  // 最后一行操作按钮
396
396
  .operate_modal_bottom{
397
397
  position: relative;
398
- top: 10px ;
398
+ top: 12px ;
399
399
  &::before{
400
400
  content: '';
401
401
  display: block;
@@ -403,7 +403,7 @@
403
403
  height: 1px;
404
404
  background-color: rgba(0, 0, 0, 0.06);
405
405
  position: absolute;
406
- bottom: 40px;
406
+ bottom: 42px;
407
407
  left: -16px;
408
408
  }
409
409
  &>p{
@@ -966,6 +966,8 @@
966
966
  border-radius: 38px;
967
967
  margin-bottom: 16px;
968
968
  line-height: 1.5;
969
+ display: inline-block;
970
+
969
971
  cursor: pointer;
970
972
  &:hover{
971
973
  background-color: @color-background-primary-weak;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.7.16",
3
+ "version": "0.7.18",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",