bhd-components 0.7.13 → 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.
@@ -307,46 +307,76 @@ const CustomerService = (props)=>{
307
307
  } catch (error) {}
308
308
  }, 3000);
309
309
  };
310
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
311
- const sendGreetingMessage = (type)=>{
312
- let questionsList = [];
313
- let obj = {};
314
- if (type == 1) {
315
- console.log(hotQuestionsList, newHotQuestionsList.current, '33322221111');
316
- if (newHotQuestionsList.current.length > 0) {
317
- questionsList = newHotQuestionsList.current.map((item, index)=>{
318
- if (index < 3) {
319
- return {
320
- key: "messageSource",
321
- value: item.id,
322
- question: item.question,
323
- answer: item.answer
324
- };
325
- } else {
326
- return null;
327
- }
328
- });
329
- } else {
330
- questionsList = hotQuestionsList.map((item, index)=>{
331
- if (index < 3) {
332
- return {
333
- key: "messageSource",
334
- value: item.id,
335
- question: item.question,
336
- answer: item.answer
337
- };
338
- } else {
339
- return null;
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
355
+ };
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();
340
370
  }
341
- });
371
+ return;
372
+ }).catch(()=>{});
342
373
  }
343
- questionsList = questionsList.filter((i)=>i != null);
344
- obj = {
374
+ } else {
375
+ let obj = {
345
376
  roomId: roomId,
346
377
  sender: "AI",
347
378
  recevier: mid,
348
- message: `Hi,我是智能学习助手,你遇到了什么问题?`,
349
- extraInfos: questionsList
379
+ message: `Hi,我是智能学习助手,你遇到了什么问题?`
350
380
  };
351
381
  if (pageNumHistory <= 1) {
352
382
  setHistoryMessageList((historyMessageList)=>{
@@ -357,12 +387,84 @@ const CustomerService = (props)=>{
357
387
  downvoted: false,
358
388
  quotedMessage: "",
359
389
  createdAt: getDataTime(-1),
360
- extraInfo: JSON.stringify(obj.extraInfos)
390
+ // extraInfo: JSON.stringify(obj.extraInfos),
391
+ extraInfo: JSON.stringify([
392
+ {
393
+ key: "messageSource",
394
+ value: "knowledgebase"
395
+ }
396
+ ])
361
397
  }));
362
398
  return newHistoryMessageList;
363
399
  });
364
400
  scrollToBottom();
365
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
+ // }
366
468
  return;
367
469
  } else if (type == 2) {
368
470
  obj = {
@@ -965,7 +1067,7 @@ const CustomerService = (props)=>{
965
1067
  } else {
966
1068
  let newHistoryMessageList2 = list1.map((item)=>{
967
1069
  message = item.message + obj.message;
968
- let extraInfo = [];
1070
+ let extraInfo = null;
969
1071
  // message = '抱歉,我暂时无法回答这样的问题。'
970
1072
  if (message == '抱歉,我暂时无法回答这样的问题。') {
971
1073
  extraInfo = videoHotQuestionsList.current.map((str, index)=>{
@@ -1357,12 +1459,15 @@ const CustomerService = (props)=>{
1357
1459
  const videoPageQuestiionsList = (flag = 1)=>{
1358
1460
  console.log(flag, props, 3333333);
1359
1461
  if (config && config.type == 'video' && config.params) {
1360
- // let params = config.params;
1361
- // let videoId = params.videoId;
1362
- // let watchTime = params.videoProgress;
1363
- // let courseId = getQuery('yc_id');
1364
- // let sectionId = params.VideoBriefSummaryId;
1365
- let courseId = "20899", sectionId = "462347", videoId = "29715", watchTime = 677;
1462
+ let params = config.params;
1463
+ let videoId = params.videoId;
1464
+ let watchTime = params.videoProgress;
1465
+ let courseId = getQuery('yc_id');
1466
+ let sectionId = params.VideoBriefSummaryId;
1467
+ // let courseId="20899",
1468
+ // sectionId= "462347",
1469
+ // videoId= "29715",
1470
+ // watchTime= 677
1366
1471
  if (videoId && courseId && sectionId) {
1367
1472
  console.log(recommendeQuestionID.current, 'recommendeQuestionID.current');
1368
1473
  http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
@@ -311,48 +311,78 @@ var CustomerService = function(props) {
311
311
  } catch (error) {}
312
312
  }, 3000);
313
313
  };
314
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
315
- var sendGreetingMessage = function(type) {
316
- var questionsList = [];
317
- var obj = {};
318
- if (type == 1) {
319
- console.log(hotQuestionsList, newHotQuestionsList.current, "33322221111");
320
- if (newHotQuestionsList.current.length > 0) {
321
- questionsList = newHotQuestionsList.current.map(function(item, index) {
322
- if (index < 3) {
323
- return {
324
- key: "messageSource",
325
- value: item.id,
326
- question: item.question,
327
- answer: item.answer
328
- };
329
- } else {
330
- return null;
331
- }
332
- });
333
- } else {
334
- questionsList = hotQuestionsList.map(function(item, index) {
335
- if (index < 3) {
336
- return {
337
- key: "messageSource",
338
- value: item.id,
339
- question: item.question,
340
- answer: item.answer
341
- };
342
- } else {
343
- return null;
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
359
+ };
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();
344
376
  }
345
- });
377
+ return;
378
+ }).catch(function() {});
346
379
  }
347
- questionsList = questionsList.filter(function(i) {
348
- return i != null;
349
- });
350
- obj = {
380
+ } else {
381
+ var obj = {
351
382
  roomId: roomId,
352
383
  sender: "AI",
353
384
  recevier: mid,
354
- message: "Hi,我是智能学习助手,你遇到了什么问题?",
355
- extraInfos: questionsList
385
+ message: "Hi,我是智能学习助手,你遇到了什么问题?"
356
386
  };
357
387
  if (pageNumHistory <= 1) {
358
388
  setHistoryMessageList(function(historyMessageList) {
@@ -365,12 +395,84 @@ var CustomerService = function(props) {
365
395
  downvoted: false,
366
396
  quotedMessage: "",
367
397
  createdAt: getDataTime(-1),
368
- extraInfo: JSON.stringify(obj.extraInfos)
398
+ // extraInfo: JSON.stringify(obj.extraInfos),
399
+ extraInfo: JSON.stringify([
400
+ {
401
+ key: "messageSource",
402
+ value: "knowledgebase"
403
+ }
404
+ ])
369
405
  }));
370
406
  return newHistoryMessageList;
371
407
  });
372
408
  scrollToBottom();
373
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
+ // }
374
476
  return;
375
477
  } else if (type == 2) {
376
478
  obj = {
@@ -992,7 +1094,7 @@ var CustomerService = function(props) {
992
1094
  } else {
993
1095
  var newHistoryMessageList2 = list1.map(function(item) {
994
1096
  message = item.message + obj.message;
995
- var extraInfo = [];
1097
+ var extraInfo = null;
996
1098
  // message = '抱歉,我暂时无法回答这样的问题。'
997
1099
  if (message == "抱歉,我暂时无法回答这样的问题。") {
998
1100
  extraInfo = videoHotQuestionsList.current.map(function(str, index) {
@@ -1390,12 +1492,15 @@ var CustomerService = function(props) {
1390
1492
  var flag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
1391
1493
  console.log(flag, props, 3333333);
1392
1494
  if (config && config.type == "video" && config.params) {
1393
- // let params = config.params;
1394
- // let videoId = params.videoId;
1395
- // let watchTime = params.videoProgress;
1396
- // let courseId = getQuery('yc_id');
1397
- // let sectionId = params.VideoBriefSummaryId;
1398
- var courseId = "20899", sectionId = "462347", videoId = "29715", watchTime = 677;
1495
+ var params = config.params;
1496
+ var videoId = params.videoId;
1497
+ var watchTime = params.videoProgress;
1498
+ var courseId = getQuery("yc_id");
1499
+ var sectionId = params.VideoBriefSummaryId;
1500
+ // let courseId="20899",
1501
+ // sectionId= "462347",
1502
+ // videoId= "29715",
1503
+ // watchTime= 677
1399
1504
  if (videoId && courseId && sectionId) {
1400
1505
  console.log(recommendeQuestionID.current, "recommendeQuestionID.current");
1401
1506
  http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",