bhd-components 0.7.15 → 0.7.17

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.
@@ -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
@@ -333,46 +333,46 @@ const CustomerService = (props)=>{
333
333
  ],
334
334
  "maximum": 3
335
335
  }).then((res)=>{
336
- let data = res.data.questions;
337
- let questionsList = null;
338
- if (data.length > 0) {
339
- questionsList = data.map((item, index)=>{
340
- if (index < 3) {
336
+ try {
337
+ let data = res.data.questions;
338
+ let questionsList = null;
339
+ if (data.length > 0) {
340
+ questionsList = data.map((item, index)=>{
341
341
  return {
342
342
  key: "messageSource",
343
343
  value: item.id,
344
344
  question: item.question,
345
345
  answer: item.answer
346
346
  };
347
- } else {
348
- return null;
349
- }
350
- });
351
- }
352
- let obj = {
353
- roomId: roomId,
354
- sender: "AI",
355
- recevier: mid,
356
- message: `Hi,我是智能学习助手,你遇到了什么问题?`,
357
- extraInfos: questionsList.length > 0 ? questionsList : null
358
- };
359
- if (pageNumHistory <= 1) {
360
- setHistoryMessageList((historyMessageList)=>{
361
- let newHistoryMessageList = historyMessageList.filter((e)=>e.id != '123456_date');
362
- newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
363
- id: '123456_date',
364
- upvoted: false,
365
- downvoted: false,
366
- quotedMessage: "",
367
- createdAt: getDataTime(-1),
368
- extraInfo: JSON.stringify(obj.extraInfos)
369
- }));
370
- return newHistoryMessageList;
371
- });
372
- scrollToBottom();
373
- }
374
- return;
375
- }).catch(()=>{});
347
+ });
348
+ }
349
+ console.log('dflkvmdfklvdf欢迎语', data);
350
+ let obj = {
351
+ roomId: roomId,
352
+ sender: "AI",
353
+ recevier: mid,
354
+ message: `Hi,我是智能学习助手,你遇到了什么问题?`,
355
+ extraInfos: questionsList == null ? null : questionsList
356
+ };
357
+ if (pageNumHistory <= 1) {
358
+ console.log('欢迎语');
359
+ setHistoryMessageList((historyMessageList)=>{
360
+ let newHistoryMessageList = historyMessageList.filter((e)=>e.id != '123456_date');
361
+ newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
362
+ id: '123456_date',
363
+ upvoted: false,
364
+ downvoted: false,
365
+ quotedMessage: "",
366
+ createdAt: getDataTime(-1),
367
+ extraInfo: obj.extraInfos != null ? JSON.stringify(obj.extraInfos) : null
368
+ }));
369
+ return newHistoryMessageList;
370
+ });
371
+ scrollToBottom();
372
+ }
373
+ return;
374
+ } catch (error) {}
375
+ });
376
376
  }
377
377
  } else {
378
378
  let obj = {
@@ -404,70 +404,54 @@ const CustomerService = (props)=>{
404
404
  }
405
405
  }
406
406
  };
407
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
407
+ //无ai权限时,发送热门问题
408
+ const getAssociativeProblem = ()=>{
409
+ http.get(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions`, {
410
+ params: {
411
+ page: 1,
412
+ maxPageSize: 5
413
+ }
414
+ }).then((res)=>{
415
+ setFinished(true);
416
+ if (res.data.total > 0) {
417
+ let questionsList = res.data.questions.map((item)=>{
418
+ return {
419
+ key: "messageSource",
420
+ value: item.id,
421
+ question: item.question,
422
+ answer: item.answer
423
+ };
424
+ });
425
+ let obj = {
426
+ roomId: roomId,
427
+ sender: "AI",
428
+ recevier: mid,
429
+ message: `猜你想问:`,
430
+ extraInfos: questionsList
431
+ };
432
+ if (pageNumHistory <= 1) {
433
+ setHistoryMessageList((historyMessageList)=>{
434
+ let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
435
+ id: 'p' + new Date().getTime(),
436
+ upvoted: false,
437
+ downvoted: false,
438
+ quotedMessage: "",
439
+ createdAt: getDataTime(-1),
440
+ extraInfo: JSON.stringify(obj.extraInfos)
441
+ }));
442
+ return newHistoryMessageList;
443
+ });
444
+ scrollToBottom();
445
+ }
446
+ return;
447
+ }
448
+ });
449
+ };
450
+ //AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
408
451
  const sendGreetingMessage = (type)=>{
409
- let questionsList = [];
410
452
  let obj = {};
411
453
  if (type == 1) {
412
454
  sendWelcomMessage();
413
- // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
414
- // if(newHotQuestionsList.current.length > 0){
415
- // questionsList = newHotQuestionsList.current.map((item, index) => {
416
- // if (index < 3) {
417
- // return {
418
- // key: "messageSource",
419
- // value: item.id,
420
- // question: item.question,
421
- // answer: item.answer,
422
- // };
423
- // } else {
424
- // return null;
425
- // }
426
- // });
427
- // }else{
428
- // questionsList = hotQuestionsList.map((item, index) => {
429
- // if (index < 3) {
430
- // return {
431
- // key: "messageSource",
432
- // value: item.id,
433
- // question: item.question,
434
- // answer: item.answer,
435
- // };
436
- // } else {
437
- // return null;
438
- // }
439
- // });
440
- // }
441
- // questionsList = questionsList.filter((i) => i != null);
442
- // obj = {
443
- // roomId: roomId,
444
- // sender: "AI",
445
- // recevier: mid,
446
- // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
447
- // extraInfos: questionsList,
448
- // };
449
- // if(pageNumHistory <= 1){
450
- // setHistoryMessageList((historyMessageList) => {
451
- // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
452
- // newHistoryMessageList.push({
453
- // ...obj,
454
- // id: '123456_date',
455
- // upvoted: false,
456
- // downvoted: false,
457
- // quotedMessage: "",
458
- // createdAt: getDataTime(-1),
459
- // extraInfo: JSON.stringify(obj.extraInfos),
460
- // // extraInfo: JSON.stringify([
461
- // // {
462
- // // key: "messageSource",
463
- // // value: "knowledgebase",
464
- // // },
465
- // // ]),
466
- // });
467
- // return newHistoryMessageList;
468
- // });
469
- // scrollToBottom();
470
- // }
471
455
  return;
472
456
  } else if (type == 2) {
473
457
  obj = {
@@ -528,35 +512,7 @@ const CustomerService = (props)=>{
528
512
  ]
529
513
  };
530
514
  } else if (type == 6) {
531
- questionsList = hotQuestionsList.map((item)=>{
532
- return {
533
- key: "messageSource",
534
- value: item.id,
535
- question: item.question,
536
- answer: item.answer
537
- };
538
- });
539
- obj = {
540
- roomId: roomId,
541
- sender: "AI",
542
- recevier: mid,
543
- message: `猜你想问:`,
544
- extraInfos: questionsList
545
- };
546
- if (pageNumHistory <= 1) {
547
- setHistoryMessageList((historyMessageList)=>{
548
- let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
549
- id: 'p' + new Date().getTime(),
550
- upvoted: false,
551
- downvoted: false,
552
- quotedMessage: "",
553
- createdAt: getDataTime(-1),
554
- extraInfo: JSON.stringify(obj.extraInfos)
555
- }));
556
- return newHistoryMessageList;
557
- });
558
- scrollToBottom();
559
- }
515
+ getAssociativeProblem();
560
516
  return;
561
517
  }
562
518
  setKeyWord("");
@@ -773,10 +729,6 @@ const CustomerService = (props)=>{
773
729
  scrollToBottom();
774
730
  }
775
731
  console.log(type, '接受答案77777');
776
- //获取下面的推荐问题
777
- // if(type == 2){
778
- // videoPageQuestiionsList(2);
779
- // }
780
732
  http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
781
733
  if (res.data.id) {
782
734
  if (pageNumHistory <= 1) {
@@ -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
@@ -337,48 +337,48 @@ var CustomerService = function(props) {
337
337
  ],
338
338
  "maximum": 3
339
339
  }).then(function(res) {
340
- var data = res.data.questions;
341
- var questionsList = null;
342
- if (data.length > 0) {
343
- questionsList = data.map(function(item, index) {
344
- if (index < 3) {
340
+ try {
341
+ var data = res.data.questions;
342
+ var questionsList = null;
343
+ if (data.length > 0) {
344
+ questionsList = data.map(function(item, index) {
345
345
  return {
346
346
  key: "messageSource",
347
347
  value: item.id,
348
348
  question: item.question,
349
349
  answer: item.answer
350
350
  };
351
- } else {
352
- return null;
353
- }
354
- });
355
- }
356
- var obj = {
357
- roomId: roomId,
358
- sender: "AI",
359
- recevier: mid,
360
- message: "Hi,我是智能学习助手,你遇到了什么问题?",
361
- extraInfos: questionsList.length > 0 ? questionsList : null
362
- };
363
- if (pageNumHistory <= 1) {
364
- setHistoryMessageList(function(historyMessageList) {
365
- var newHistoryMessageList = historyMessageList.filter(function(e) {
366
- return e.id != "123456_date";
367
351
  });
368
- newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
369
- id: "123456_date",
370
- upvoted: false,
371
- downvoted: false,
372
- quotedMessage: "",
373
- createdAt: getDataTime(-1),
374
- extraInfo: JSON.stringify(obj.extraInfos)
375
- }));
376
- return newHistoryMessageList;
377
- });
378
- scrollToBottom();
379
- }
380
- return;
381
- }).catch(function() {});
352
+ }
353
+ console.log("dflkvmdfklvdf欢迎语", data);
354
+ var obj = {
355
+ roomId: roomId,
356
+ sender: "AI",
357
+ recevier: mid,
358
+ message: "Hi,我是智能学习助手,你遇到了什么问题?",
359
+ extraInfos: questionsList == null ? null : questionsList
360
+ };
361
+ if (pageNumHistory <= 1) {
362
+ console.log("欢迎语");
363
+ setHistoryMessageList(function(historyMessageList) {
364
+ var newHistoryMessageList = historyMessageList.filter(function(e) {
365
+ return e.id != "123456_date";
366
+ });
367
+ newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
368
+ id: "123456_date",
369
+ upvoted: false,
370
+ downvoted: false,
371
+ quotedMessage: "",
372
+ createdAt: getDataTime(-1),
373
+ extraInfo: obj.extraInfos != null ? JSON.stringify(obj.extraInfos) : null
374
+ }));
375
+ return newHistoryMessageList;
376
+ });
377
+ scrollToBottom();
378
+ }
379
+ return;
380
+ } catch (error) {}
381
+ });
382
382
  }
383
383
  } else {
384
384
  var obj = {
@@ -412,70 +412,54 @@ var CustomerService = function(props) {
412
412
  }
413
413
  }
414
414
  };
415
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
415
+ //无ai权限时,发送热门问题
416
+ var getAssociativeProblem = function() {
417
+ http.get("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions"), {
418
+ params: {
419
+ page: 1,
420
+ maxPageSize: 5
421
+ }
422
+ }).then(function(res) {
423
+ setFinished(true);
424
+ if (res.data.total > 0) {
425
+ var questionsList = res.data.questions.map(function(item) {
426
+ return {
427
+ key: "messageSource",
428
+ value: item.id,
429
+ question: item.question,
430
+ answer: item.answer
431
+ };
432
+ });
433
+ var obj = {
434
+ roomId: roomId,
435
+ sender: "AI",
436
+ recevier: mid,
437
+ message: "猜你想问:",
438
+ extraInfos: questionsList
439
+ };
440
+ if (pageNumHistory <= 1) {
441
+ setHistoryMessageList(function(historyMessageList) {
442
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
443
+ id: "p" + new Date().getTime(),
444
+ upvoted: false,
445
+ downvoted: false,
446
+ quotedMessage: "",
447
+ createdAt: getDataTime(-1),
448
+ extraInfo: JSON.stringify(obj.extraInfos)
449
+ }));
450
+ return newHistoryMessageList;
451
+ });
452
+ scrollToBottom();
453
+ }
454
+ return;
455
+ }
456
+ });
457
+ };
458
+ //AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
416
459
  var sendGreetingMessage = function(type) {
417
- var questionsList = [];
418
460
  var obj = {};
419
461
  if (type == 1) {
420
462
  sendWelcomMessage();
421
- // console.log(hotQuestionsList,newHotQuestionsList.current,'33322221111');
422
- // if(newHotQuestionsList.current.length > 0){
423
- // questionsList = newHotQuestionsList.current.map((item, index) => {
424
- // if (index < 3) {
425
- // return {
426
- // key: "messageSource",
427
- // value: item.id,
428
- // question: item.question,
429
- // answer: item.answer,
430
- // };
431
- // } else {
432
- // return null;
433
- // }
434
- // });
435
- // }else{
436
- // questionsList = hotQuestionsList.map((item, index) => {
437
- // if (index < 3) {
438
- // return {
439
- // key: "messageSource",
440
- // value: item.id,
441
- // question: item.question,
442
- // answer: item.answer,
443
- // };
444
- // } else {
445
- // return null;
446
- // }
447
- // });
448
- // }
449
- // questionsList = questionsList.filter((i) => i != null);
450
- // obj = {
451
- // roomId: roomId,
452
- // sender: "AI",
453
- // recevier: mid,
454
- // message: `Hi,我是智能学习助手,你遇到了什么问题?`,
455
- // extraInfos: questionsList,
456
- // };
457
- // if(pageNumHistory <= 1){
458
- // setHistoryMessageList((historyMessageList) => {
459
- // let newHistoryMessageList = historyMessageList.filter(e=>e.id!='123456_date');
460
- // newHistoryMessageList.push({
461
- // ...obj,
462
- // id: '123456_date',
463
- // upvoted: false,
464
- // downvoted: false,
465
- // quotedMessage: "",
466
- // createdAt: getDataTime(-1),
467
- // extraInfo: JSON.stringify(obj.extraInfos),
468
- // // extraInfo: JSON.stringify([
469
- // // {
470
- // // key: "messageSource",
471
- // // value: "knowledgebase",
472
- // // },
473
- // // ]),
474
- // });
475
- // return newHistoryMessageList;
476
- // });
477
- // scrollToBottom();
478
- // }
479
463
  return;
480
464
  } else if (type == 2) {
481
465
  obj = {
@@ -536,35 +520,7 @@ var CustomerService = function(props) {
536
520
  ]
537
521
  };
538
522
  } else if (type == 6) {
539
- questionsList = hotQuestionsList.map(function(item) {
540
- return {
541
- key: "messageSource",
542
- value: item.id,
543
- question: item.question,
544
- answer: item.answer
545
- };
546
- });
547
- obj = {
548
- roomId: roomId,
549
- sender: "AI",
550
- recevier: mid,
551
- message: "猜你想问:",
552
- extraInfos: questionsList
553
- };
554
- if (pageNumHistory <= 1) {
555
- setHistoryMessageList(function(historyMessageList) {
556
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
557
- id: "p" + new Date().getTime(),
558
- upvoted: false,
559
- downvoted: false,
560
- quotedMessage: "",
561
- createdAt: getDataTime(-1),
562
- extraInfo: JSON.stringify(obj.extraInfos)
563
- }));
564
- return newHistoryMessageList;
565
- });
566
- scrollToBottom();
567
- }
523
+ getAssociativeProblem();
568
524
  return;
569
525
  }
570
526
  setKeyWord("");
@@ -790,10 +746,6 @@ var CustomerService = function(props) {
790
746
  scrollToBottom();
791
747
  }
792
748
  console.log(type, "接受答案77777");
793
- //获取下面的推荐问题
794
- // if(type == 2){
795
- // videoPageQuestiionsList(2);
796
- // }
797
749
  http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
798
750
  if (res.data.id) {
799
751
  if (pageNumHistory <= 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",