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.
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "highlight.js/styles/default.css";
3
- import './html2canvas.test.js';
4
3
  interface Service {
5
4
  type: string;
6
5
  params: any;
@@ -23,7 +23,7 @@ import "highlight.js/styles/default.css";
23
23
  import { render } from "react-dom";
24
24
  import Provider from "../provider";
25
25
  const { TextArea } = Input;
26
- import "./html2canvas.test.js";
26
+ // import './html2canvas.test.js';
27
27
  import knowledge_icon from "./images/knowledge_icon.png";
28
28
  // import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
29
29
  import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate } from "./function"; //一些方法
@@ -94,10 +94,10 @@ const CustomerService = (props)=>{
94
94
  }
95
95
  });
96
96
  useEffect(()=>{
97
- if (config && config.type == 'video') {
98
- //获取热门推荐
99
- videoPageQuestiionsList(1);
100
- }
97
+ // if(config && config.type == 'video'){
98
+ // //获取热门推荐
99
+ // videoPageQuestiionsList(1);
100
+ // }
101
101
  setShowType(initShowType);
102
102
  }, [
103
103
  initShowType
@@ -107,29 +107,23 @@ const CustomerService = (props)=>{
107
107
  if (showType == 5 || showScreenshot) {
108
108
  try {
109
109
  setImgBese64('');
110
- // html2canvas(document.getElementsByTagName('html')[0],{
111
- // // ignoreElements:(element)=>{
112
- // // if(element.compareDocumentPosition(dom)===2)return true
113
- // // return false
114
- // // }
115
- // }).then((canvas)=>{
116
- // console.log(canvas,22222);
117
- // setTimeout(()=>{
118
- let dom = document.getElementById(screenshotAreaId);
119
- html2canvas(dom, {
110
+ // let dom = document.getElementById(screenshotAreaId);
111
+ html2canvas(screenshotAreaId, {
120
112
  useCORS: true,
121
113
  // allowTaint: true, // 污染处理
122
- scale: 1
114
+ scale: 1,
115
+ // logging:true,
116
+ ignoreElements: (element)=>{
117
+ if (element.compareDocumentPosition(screenshotAreaId) === 2) return true;
118
+ return false;
119
+ }
123
120
  }).then(function(canvas) {
124
- // document.body.appendChild(canvas);
125
121
  // document.body.appendChild(canvas);
126
122
  console.log(canvas, 99999);
127
123
  // var base64URL = canvas.toDataURL('image/jpeg')
128
124
  let base64URL = canvas.toDataURL("image/jpg", 1.0);
129
125
  setImgBese64(base64URL);
130
126
  });
131
- // },100)
132
- // })
133
127
  } catch (error) {
134
128
  console.log(error);
135
129
  }
@@ -315,10 +309,10 @@ const CustomerService = (props)=>{
315
309
  let watchTime = params.videoProgress;
316
310
  let courseId = getQuery('yc_id');
317
311
  let sectionId = params.VideoBriefSummaryId;
318
- // let courseId="20899",
319
- // sectionId= "462347",
320
- // videoId= "29715",
321
- // watchTime= 677
312
+ // let courseId="31007",
313
+ // sectionId= "446168",
314
+ // videoId= "71399",
315
+ // watchTime= 527
322
316
  if (videoId && courseId && sectionId) {
323
317
  http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
324
318
  "recommendedQuestions": [],
@@ -345,6 +339,9 @@ const CustomerService = (props)=>{
345
339
  answer: item.answer
346
340
  };
347
341
  });
342
+ recommendeQuestionID.current = data.map((item)=>{
343
+ return item.id;
344
+ });
348
345
  }
349
346
  console.log('dflkvmdfklvdf欢迎语', data);
350
347
  let obj = {
@@ -366,14 +363,13 @@ const CustomerService = (props)=>{
366
363
  createdAt: getDataTime(-1),
367
364
  extraInfo: obj.extraInfos != null ? JSON.stringify(obj.extraInfos) : null
368
365
  }));
369
- console.log(newHistoryMessageList, 3333333333339999);
370
366
  return newHistoryMessageList;
371
367
  });
372
368
  scrollToBottom();
373
369
  }
374
370
  return;
375
371
  } catch (error) {}
376
- }).catch(()=>{});
372
+ });
377
373
  }
378
374
  } else {
379
375
  let obj = {
@@ -405,71 +401,54 @@ const CustomerService = (props)=>{
405
401
  }
406
402
  }
407
403
  };
408
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
404
+ //无ai权限时,发送热门问题
405
+ const getAssociativeProblem = ()=>{
406
+ http.get(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions`, {
407
+ params: {
408
+ page: 1,
409
+ maxPageSize: 5
410
+ }
411
+ }).then((res)=>{
412
+ setFinished(true);
413
+ if (res.data.total > 0) {
414
+ let questionsList = res.data.questions.map((item)=>{
415
+ return {
416
+ key: "messageSource",
417
+ value: item.id,
418
+ question: item.question,
419
+ answer: item.answer
420
+ };
421
+ });
422
+ let obj = {
423
+ roomId: roomId,
424
+ sender: "AI",
425
+ recevier: mid,
426
+ message: `猜你想问:`,
427
+ extraInfos: questionsList
428
+ };
429
+ if (pageNumHistory <= 1) {
430
+ setHistoryMessageList((historyMessageList)=>{
431
+ let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
432
+ id: 'p' + new Date().getTime(),
433
+ upvoted: false,
434
+ downvoted: false,
435
+ quotedMessage: "",
436
+ createdAt: getDataTime(-1),
437
+ extraInfo: JSON.stringify(obj.extraInfos)
438
+ }));
439
+ return newHistoryMessageList;
440
+ });
441
+ scrollToBottom();
442
+ }
443
+ return;
444
+ }
445
+ });
446
+ };
447
+ //AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
409
448
  const sendGreetingMessage = (type)=>{
410
- let questionsList = [];
411
449
  let obj = {};
412
450
  if (type == 1) {
413
- console.log('dflkvmdfklvdf欢迎语');
414
451
  sendWelcomMessage();
415
- // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
416
- // if(newHotQuestionsList.current.length > 0){
417
- // questionsList = newHotQuestionsList.current.map((item, index) => {
418
- // if (index < 3) {
419
- // return {
420
- // key: "messageSource",
421
- // value: item.id,
422
- // question: item.question,
423
- // answer: item.answer,
424
- // };
425
- // } else {
426
- // return null;
427
- // }
428
- // });
429
- // }else{
430
- // questionsList = hotQuestionsList.map((item, index) => {
431
- // if (index < 3) {
432
- // return {
433
- // key: "messageSource",
434
- // value: item.id,
435
- // question: item.question,
436
- // answer: item.answer,
437
- // };
438
- // } else {
439
- // return null;
440
- // }
441
- // });
442
- // }
443
- // questionsList = questionsList.filter((i) => i != null);
444
- // obj = {
445
- // roomId: roomId,
446
- // sender: "AI",
447
- // recevier: mid,
448
- // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
449
- // extraInfos: questionsList,
450
- // };
451
- // if(pageNumHistory <= 1){
452
- // setHistoryMessageList((historyMessageList) => {
453
- // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
454
- // newHistoryMessageList.push({
455
- // ...obj,
456
- // id: '123456_date',
457
- // upvoted: false,
458
- // downvoted: false,
459
- // quotedMessage: "",
460
- // createdAt: getDataTime(-1),
461
- // extraInfo: JSON.stringify(obj.extraInfos),
462
- // // extraInfo: JSON.stringify([
463
- // // {
464
- // // key: "messageSource",
465
- // // value: "knowledgebase",
466
- // // },
467
- // // ]),
468
- // });
469
- // return newHistoryMessageList;
470
- // });
471
- // scrollToBottom();
472
- // }
473
452
  return;
474
453
  } else if (type == 2) {
475
454
  obj = {
@@ -530,35 +509,7 @@ const CustomerService = (props)=>{
530
509
  ]
531
510
  };
532
511
  } else if (type == 6) {
533
- questionsList = hotQuestionsList.map((item)=>{
534
- return {
535
- key: "messageSource",
536
- value: item.id,
537
- question: item.question,
538
- answer: item.answer
539
- };
540
- });
541
- obj = {
542
- roomId: roomId,
543
- sender: "AI",
544
- recevier: mid,
545
- message: `猜你想问:`,
546
- extraInfos: questionsList
547
- };
548
- if (pageNumHistory <= 1) {
549
- setHistoryMessageList((historyMessageList)=>{
550
- let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
551
- id: 'p' + new Date().getTime(),
552
- upvoted: false,
553
- downvoted: false,
554
- quotedMessage: "",
555
- createdAt: getDataTime(-1),
556
- extraInfo: JSON.stringify(obj.extraInfos)
557
- }));
558
- return newHistoryMessageList;
559
- });
560
- scrollToBottom();
561
- }
512
+ getAssociativeProblem();
562
513
  return;
563
514
  }
564
515
  setKeyWord("");
@@ -678,7 +629,7 @@ const CustomerService = (props)=>{
678
629
  recevier: "AI",
679
630
  message: questions.question,
680
631
  quotedMessage: '',
681
- id: "654321",
632
+ id: 'p' + new Date().getTime(),
682
633
  upvoted: false,
683
634
  downvoted: false,
684
635
  createdAt: getDataTime(-1),
@@ -736,7 +687,7 @@ const CustomerService = (props)=>{
736
687
  recevier: "AI",
737
688
  message: keyWord,
738
689
  quotedMessage: citationContent.content,
739
- id: "654321",
690
+ id: 'p' + new Date().getTime(),
740
691
  upvoted: false,
741
692
  downvoted: false,
742
693
  createdAt: getDataTime(-1),
@@ -764,7 +715,7 @@ const CustomerService = (props)=>{
764
715
  if (pageNumHistory <= 1) {
765
716
  setHistoryMessageList((historyMessageList)=>{
766
717
  let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
767
- id: null,
718
+ id: 'p' + new Date().getTime(),
768
719
  upvoted: false,
769
720
  downvoted: false,
770
721
  createdAt: getDataTime(-1),
@@ -775,10 +726,6 @@ const CustomerService = (props)=>{
775
726
  scrollToBottom();
776
727
  }
777
728
  console.log(type, '接受答案77777');
778
- //获取下面的推荐问题
779
- // if(type == 2){
780
- // videoPageQuestiionsList(2);
781
- // }
782
729
  http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
783
730
  if (res.data.id) {
784
731
  if (pageNumHistory <= 1) {
@@ -827,9 +774,11 @@ const CustomerService = (props)=>{
827
774
  ctrl.current = new AbortController();
828
775
  clearTimeout(receiveMessageTimer.current);
829
776
  receiveMessageTimer.current = setTimeout(()=>{
830
- setHistoryMessageList((historyMessageList)=>{
831
- return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
832
- });
777
+ // setHistoryMessageList((historyMessageList) => {
778
+ // return historyMessageList.filter(
779
+ // (item) => item.id != "123456" && item.id != "654321"
780
+ // );
781
+ // });
833
782
  setFinished(true);
834
783
  ctrl.current.abort();
835
784
  setHistoryMessageList((historyMessageList)=>{
@@ -844,6 +793,7 @@ const CustomerService = (props)=>{
844
793
  });
845
794
  });
846
795
  }, 60 * 1000);
796
+ setFinished(false);
847
797
  if (config && config.type == 'video' && config.params) {
848
798
  let params = config.params;
849
799
  let videoId = params.videoId;
@@ -1469,10 +1419,10 @@ const CustomerService = (props)=>{
1469
1419
  let watchTime = params.videoProgress;
1470
1420
  let courseId = getQuery('yc_id');
1471
1421
  let sectionId = params.VideoBriefSummaryId;
1472
- // let courseId="20899",
1473
- // sectionId= "462347",
1474
- // videoId= "29715",
1475
- // watchTime= 677
1422
+ // let courseId="31007",
1423
+ // sectionId= "446168",
1424
+ // videoId= "71399",
1425
+ // watchTime= 527
1476
1426
  if (videoId && courseId && sectionId) {
1477
1427
  console.log(recommendeQuestionID.current, 'recommendeQuestionID.current');
1478
1428
  http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
@@ -1502,17 +1452,13 @@ const CustomerService = (props)=>{
1502
1452
  setHotQuestionsList(data);
1503
1453
  newHotQuestionsList.current = data;
1504
1454
  }
1505
- // let ids:any[] = [];
1506
- // data.map((str: { id: string; })=>{
1507
- // ids.push(str.id);
1508
- // })
1509
- // recommendeQuestionID.current = Array.from(new Set(recommendeQuestionID.current.concat(ids)));
1510
- resettingBottomHei();
1455
+ let ids = [];
1456
+ data.map((str)=>{
1457
+ ids.push(str.id);
1458
+ });
1459
+ recommendeQuestionID.current = Array.from(new Set(recommendeQuestionID.current.concat(ids)));
1511
1460
  scrollToBottom();
1512
- // console.log(data,99999);
1513
- // if(data.length < 4){
1514
- // getQuestiionsList('',4)
1515
- // }
1461
+ resettingBottomHei();
1516
1462
  }
1517
1463
  }).catch(()=>{});
1518
1464
  }
@@ -1643,7 +1589,7 @@ const CustomerService = (props)=>{
1643
1589
  }
1644
1590
  } else {
1645
1591
  if (document.getElementById("Drawer_buttom_modal")) {
1646
- let hei = document.getElementById("Drawer_buttom_modal").offsetHeight + document.getElementById("BottomAssociationProblem").offsetHeight;
1592
+ let hei = document.getElementById("Drawer_buttom_modal").offsetHeight + document.getElementById("BottomAssociationProblem_modal").offsetHeight;
1647
1593
  setButtomHei(hei);
1648
1594
  }
1649
1595
  }
@@ -2178,7 +2124,6 @@ const CustomerService = (props)=>{
2178
2124
  return /*#__PURE__*/ _jsx("li", {
2179
2125
  onClick: ()=>{
2180
2126
  sendMessage(list, 1);
2181
- recommendeQuestionID.current = recommendeQuestionID.current.concat(list.value);
2182
2127
  setBottomRecommendationQuestions([]);
2183
2128
  resettingBottomHei();
2184
2129
  },
@@ -2428,7 +2373,6 @@ const CustomerService = (props)=>{
2428
2373
  } else if (JSON.parse(previousLineData.extraInfo).length > 0 && JSON.parse(previousLineData.extraInfo)[0].key == "imageUrl") {
2429
2374
  showTeacherBtn = false;
2430
2375
  }
2431
- console.log(showTeacherBtn, 'dlvkdfl');
2432
2376
  /// style={{position:showStopBtn && isPosition.current ? 'sticky' : 'relative'}}
2433
2377
  return /*#__PURE__*/ _jsxs("div", {
2434
2378
  className: `${styles.operate_modal_bottom}`,
@@ -2707,7 +2651,7 @@ const CustomerService = (props)=>{
2707
2651
  onClick: ()=>{
2708
2652
  setHistoryMessageList((historyMessageList)=>{
2709
2653
  let newHistoryMessageList = historyMessageList.concat({
2710
- id: -1,
2654
+ id: 'p' + new Date().getTime(),
2711
2655
  roomId: roomId,
2712
2656
  sender: mid,
2713
2657
  recevier: 'AI',
@@ -2745,7 +2689,7 @@ const CustomerService = (props)=>{
2745
2689
  onClick: ()=>{
2746
2690
  setHistoryMessageList((historyMessageList)=>{
2747
2691
  let newHistoryMessageList = historyMessageList.concat({
2748
- id: -1,
2692
+ id: 'p' + new Date().getTime(),
2749
2693
  roomId: roomId,
2750
2694
  sender: mid,
2751
2695
  recevier: 'AI',
@@ -3059,23 +3003,51 @@ const CustomerService = (props)=>{
3059
3003
  };
3060
3004
  //视频页面底部推荐问题
3061
3005
  const renderBottomAssociationProblem = ()=>{
3062
- return /*#__PURE__*/ _jsx("div", {
3063
- className: styles.issues_list_flag,
3064
- id: "BottomAssociationProblem",
3065
- children: bottomRecommendationQuestions.map((item)=>{
3066
- return /*#__PURE__*/ _jsx("p", {
3067
- onClick: ()=>{
3068
- sendMessage(item, 1);
3069
- if (config && config.type == 'video') {
3070
- recommendeQuestionID.current = recommendeQuestionID.current.concat(item.id);
3071
- setBottomRecommendationQuestions([]);
3072
- resettingBottomHei();
3073
- }
3074
- },
3075
- children: item.question
3076
- }, item.id);
3077
- })
3078
- });
3006
+ if (showType == 1 || showType == 3) {
3007
+ return /*#__PURE__*/ _jsx("div", {
3008
+ className: styles.issues_list_flag,
3009
+ id: "BottomAssociationProblem",
3010
+ children: bottomRecommendationQuestions.map((item)=>{
3011
+ return /*#__PURE__*/ _jsxs(_Fragment, {
3012
+ children: [
3013
+ /*#__PURE__*/ _jsx("p", {
3014
+ onClick: ()=>{
3015
+ sendMessage(item, 1);
3016
+ if (config && config.type == 'video') {
3017
+ setBottomRecommendationQuestions([]);
3018
+ resettingBottomHei();
3019
+ }
3020
+ },
3021
+ children: item.question
3022
+ }, item.id),
3023
+ /*#__PURE__*/ _jsx("br", {})
3024
+ ]
3025
+ });
3026
+ })
3027
+ });
3028
+ } else {
3029
+ return /*#__PURE__*/ _jsx("div", {
3030
+ className: styles.issues_list_flag,
3031
+ id: "BottomAssociationProblem_modal",
3032
+ children: bottomRecommendationQuestions.map((item)=>{
3033
+ return /*#__PURE__*/ _jsxs(_Fragment, {
3034
+ children: [
3035
+ /*#__PURE__*/ _jsx("p", {
3036
+ onClick: ()=>{
3037
+ sendMessage(item, 1);
3038
+ if (config && config.type == 'video') {
3039
+ setBottomRecommendationQuestions([]);
3040
+ resettingBottomHei();
3041
+ }
3042
+ },
3043
+ children: item.question
3044
+ }, item.id),
3045
+ /*#__PURE__*/ _jsx("br", {})
3046
+ ]
3047
+ });
3048
+ })
3049
+ });
3050
+ }
3079
3051
  };
3080
3052
  //加载指定数据,点击历史记录
3081
3053
  const loadSpecifiedData = (renewRoomId, page, id, receiver, keyWordProblem)=>{
@@ -3173,7 +3145,7 @@ const CustomerService = (props)=>{
3173
3145
  className: styles.Drawer_buttom_Issues_List,
3174
3146
  children: [
3175
3147
  renderAssociationProblem(),
3176
- renderBottomAssociationProblem(),
3148
+ showType == 1 && renderBottomAssociationProblem(),
3177
3149
  /*#__PURE__*/ _jsx("div", {
3178
3150
  className: styles.Drawer_buttom,
3179
3151
  id: "Drawer_buttom",
@@ -3260,6 +3232,7 @@ const CustomerService = (props)=>{
3260
3232
  className: styles.Drawer_buttom_Issues_List,
3261
3233
  children: [
3262
3234
  renderAssociationProblem(),
3235
+ showType == 2 && renderBottomAssociationProblem(),
3263
3236
  /*#__PURE__*/ _jsx("div", {
3264
3237
  className: styles.Drawer_buttom,
3265
3238
  id: "Drawer_buttom_modal",
@@ -3355,6 +3328,7 @@ const CustomerService = (props)=>{
3355
3328
  className: `${styles.Drawer_buttom_Issues_List} ${styles.Drawer_buttom_Issues_List_newlabo}`,
3356
3329
  children: [
3357
3330
  renderAssociationProblem(),
3331
+ showType == 3 && renderBottomAssociationProblem(),
3358
3332
  /*#__PURE__*/ _jsx("div", {
3359
3333
  className: styles.Drawer_buttom,
3360
3334
  id: "Drawer_buttom",
@@ -3462,6 +3436,7 @@ const CustomerService = (props)=>{
3462
3436
  className: styles.Drawer_buttom_Issues_List,
3463
3437
  children: [
3464
3438
  renderAssociationProblem(),
3439
+ (showType == 4 || showType == 5) && renderBottomAssociationProblem(),
3465
3440
  /*#__PURE__*/ _jsx("div", {
3466
3441
  className: styles.Drawer_buttom,
3467
3442
  id: "Drawer_buttom_modal",
@@ -3552,6 +3527,7 @@ const CustomerService = (props)=>{
3552
3527
  className: `${styles.Drawer_buttom_Issues_List} ${styles.Drawer_buttom_Issues_List_newlabo}`,
3553
3528
  children: [
3554
3529
  renderAssociationProblem(),
3530
+ (showType == 4 || showType == 5) && renderBottomAssociationProblem(),
3555
3531
  /*#__PURE__*/ _jsx("div", {
3556
3532
  className: styles.Drawer_buttom,
3557
3533
  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;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "highlight.js/styles/default.css";
3
- import './html2canvas.test.js';
4
3
  interface Service {
5
4
  type: string;
6
5
  params: any;