bhd-components 0.10.35 → 0.10.37

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.
@@ -819,100 +819,176 @@ var CustomerService = function(props) {
819
819
  });
820
820
  };
821
821
  //AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
822
- var sendGreetingMessage = function(type) {
823
- var obj = {};
824
- if (type == 1) {
825
- sendWelcomMessage();
826
- return;
827
- } else if (type == 2) {
828
- obj = {
829
- roomId: roomId,
830
- sender: "AI",
831
- recevier: mid,
832
- message: "您的点赞是我最大的鼓励!",
833
- createdAt: getDataTime(-1),
834
- extraInfos: [
835
- {
836
- key: "messageSource",
837
- value: "knowledgebase"
838
- }
839
- ]
840
- };
841
- } else if (type == 3) {
842
- obj = {
843
- roomId: roomId,
844
- sender: "AI",
845
- recevier: mid,
846
- message: "谢谢您的反馈,我会努力改进的!",
847
- createdAt: getDataTime(-1),
848
- extraInfos: [
849
- {
850
- key: "messageSource",
851
- value: "knowledgebase"
852
- }
853
- ]
854
- };
855
- } else if (type == 4) {
856
- obj = {
857
- roomId: roomId,
858
- sender: mid,
859
- recevier: "AI",
860
- message: keyWord,
861
- createdAt: getDataTime(-1),
862
- quotedMessage: citationContent.content,
863
- extraInfos: [
864
- {
865
- key: "messageSource",
866
- value: "knowledgebase"
867
- }
868
- ]
869
- };
870
- } else if (type == 5) {
871
- obj = {
872
- roomId: roomId,
873
- sender: "AI",
874
- recevier: mid,
875
- message: "抱歉!您今日的提问量已经达到最大限额,请您明日再来提问。",
876
- createdAt: getDataTime(-1),
877
- quotedMessage: citationContent.content,
878
- extraInfos: [
879
- {
880
- key: "messageSource",
881
- value: "knowledgebase"
882
- }
883
- ]
884
- };
885
- } else if (type == 6) {
886
- getAssociativeProblem();
887
- return;
888
- }
889
- setKeyWord("");
890
- setQuestionsList([]);
891
- setCitationContent({});
892
- http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
893
- if (res.data.id) {
894
- if (pageNumHistory <= 1) {
895
- setHistoryMessageList(function(historyMessageList) {
896
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
897
- id: res.data.id,
898
- upvoted: false,
899
- downvoted: false,
900
- quotedMessage: "",
822
+ var sendGreetingMessage = function() {
823
+ var _ref = _async_to_generator(function(type) {
824
+ var message, obj, imageUrl, base64;
825
+ var _arguments = arguments;
826
+ return _ts_generator(this, function(_state) {
827
+ switch(_state.label){
828
+ case 0:
829
+ message = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "";
830
+ obj = {};
831
+ if (!(type == 1)) return [
832
+ 3,
833
+ 1
834
+ ];
835
+ sendWelcomMessage();
836
+ return [
837
+ 2
838
+ ];
839
+ case 1:
840
+ if (!(type == 2)) return [
841
+ 3,
842
+ 2
843
+ ];
844
+ obj = {
845
+ roomId: roomId,
846
+ sender: "AI",
847
+ recevier: mid,
848
+ message: "您的点赞是我最大的鼓励!",
901
849
  createdAt: getDataTime(-1),
902
- extraInfo: JSON.stringify(obj.extraInfos)
903
- }));
904
- return newHistoryMessageList;
905
- });
906
- }
907
- scrollToBottom();
908
- if (type == 4) {
909
- sendGreetingMessage(6);
850
+ extraInfos: [
851
+ {
852
+ key: "messageSource",
853
+ value: "knowledgebase"
854
+ }
855
+ ]
856
+ };
857
+ return [
858
+ 3,
859
+ 7
860
+ ];
861
+ case 2:
862
+ if (!(type == 3)) return [
863
+ 3,
864
+ 3
865
+ ];
866
+ obj = {
867
+ roomId: roomId,
868
+ sender: "AI",
869
+ recevier: mid,
870
+ message: "谢谢您的反馈,我会努力改进的!",
871
+ createdAt: getDataTime(-1),
872
+ extraInfos: [
873
+ {
874
+ key: "messageSource",
875
+ value: "knowledgebase"
876
+ }
877
+ ]
878
+ };
879
+ return [
880
+ 3,
881
+ 7
882
+ ];
883
+ case 3:
884
+ if (!(type == 4)) return [
885
+ 3,
886
+ 6
887
+ ];
888
+ obj = {
889
+ roomId: roomId,
890
+ sender: mid,
891
+ recevier: "AI",
892
+ message: message ? message : keyWord,
893
+ createdAt: getDataTime(-1),
894
+ quotedMessage: citationContent.content,
895
+ extraInfos: [
896
+ {
897
+ key: "messageSource",
898
+ value: "knowledgebase"
899
+ }
900
+ ]
901
+ };
902
+ imageUrl = "";
903
+ if (!citationContent.imageUrl) return [
904
+ 3,
905
+ 5
906
+ ];
907
+ return [
908
+ 4,
909
+ urlToBase64(citationContent.imageUrl)
910
+ ];
911
+ case 4:
912
+ base64 = _state.sent();
913
+ imageUrl = base64;
914
+ _state.label = 5;
915
+ case 5:
916
+ if (screenshotBese64) {
917
+ imageUrl = screenshotBese64;
918
+ }
919
+ console.log("imageUrl", imageUrl);
920
+ if (imageUrl) {
921
+ obj.image = imageUrl;
922
+ obj.extraInfos.push({
923
+ key: "imageUrl",
924
+ value: imageUrl
925
+ });
926
+ }
927
+ return [
928
+ 3,
929
+ 7
930
+ ];
931
+ case 6:
932
+ if (type == 5) {
933
+ obj = {
934
+ roomId: roomId,
935
+ sender: "AI",
936
+ recevier: mid,
937
+ message: "抱歉!您今日的提问量已经达到最大限额,请您明日再来提问。",
938
+ createdAt: getDataTime(-1),
939
+ quotedMessage: citationContent.content,
940
+ extraInfos: [
941
+ {
942
+ key: "messageSource",
943
+ value: "knowledgebase"
944
+ }
945
+ ]
946
+ };
947
+ } else if (type == 6) {
948
+ getAssociativeProblem();
949
+ return [
950
+ 2
951
+ ];
952
+ }
953
+ _state.label = 7;
954
+ case 7:
955
+ setKeyWord("");
956
+ setQuestionsList([]);
957
+ setCitationContent({});
958
+ setScreenshotBese64("");
959
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
960
+ if (res.data.id) {
961
+ if (pageNumHistory <= 1) {
962
+ setHistoryMessageList(function(historyMessageList) {
963
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
964
+ id: res.data.id,
965
+ upvoted: false,
966
+ downvoted: false,
967
+ quotedMessage: "",
968
+ createdAt: getDataTime(-1),
969
+ extraInfo: JSON.stringify(obj.extraInfos)
970
+ }));
971
+ return newHistoryMessageList;
972
+ });
973
+ }
974
+ scrollToBottom();
975
+ if (type == 4) {
976
+ sendGreetingMessage(6);
977
+ }
978
+ }
979
+ }).catch(function(err) {
980
+ console.log(err);
981
+ });
982
+ return [
983
+ 2
984
+ ];
910
985
  }
911
- }
912
- }).catch(function(err) {
913
- console.log(err);
986
+ });
914
987
  });
915
- };
988
+ return function sendGreetingMessage(type) {
989
+ return _ref.apply(this, arguments);
990
+ };
991
+ }();
916
992
  //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
917
993
  var sendToTeacher = function() {
918
994
  var _ref = _async_to_generator(function(type) {
@@ -1292,7 +1368,7 @@ var CustomerService = function(props) {
1292
1368
  roomId: roomId,
1293
1369
  sender: "AI",
1294
1370
  recevier: mid,
1295
- message: "正在输入...",
1371
+ message: "正在思考...",
1296
1372
  id: "123456",
1297
1373
  createdAt: getDataTime(-1),
1298
1374
  extraInfo: null
@@ -1306,7 +1382,7 @@ var CustomerService = function(props) {
1306
1382
  roomId: roomId,
1307
1383
  sender: "AI",
1308
1384
  recevier: mid,
1309
- message: "正在输入...",
1385
+ message: "正在思考...",
1310
1386
  id: "123456",
1311
1387
  createdAt: getDataTime(-1),
1312
1388
  extraInfo: null
@@ -2417,6 +2493,12 @@ var CustomerService = function(props) {
2417
2493
  var message = item.message;
2418
2494
  var li;
2419
2495
  // 是否需要显示日期
2496
+ // 判断是否第一项:
2497
+ // 如果是第一项显示日期+时间;
2498
+ //
2499
+ // 如果不是第一项:
2500
+ // 先判断是否跨天;如果跨天:就显示日期+时间;
2501
+ // 如果不跨天:判断是否超过10分钟,超过10分钟判断是否是当天,如果当天显示时间,不是当天就显示日期+时间;没超过10分钟不显示
2420
2502
  var itemIndex = historyMessageList.findIndex(function(ite) {
2421
2503
  return ite.id === item.id;
2422
2504
  });
@@ -2428,16 +2510,30 @@ var CustomerService = function(props) {
2428
2510
  } else {
2429
2511
  //非第一项 与上一项进行对比
2430
2512
  var beforeTime = historyMessageList[itemIndex - 1].createdAt;
2431
- //判断与上一条数据 是否跨天
2432
2513
  var beforeTimeObj = parseDate(beforeTime);
2514
+ // 上一条的日期
2433
2515
  var beforeTimeStr = "".concat(beforeTimeObj.year, "-").concat(beforeTimeObj.month, "-").concat(beforeTimeObj.day);
2516
+ // 当前这条的日期
2434
2517
  var curTimeStr = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day);
2518
+ var now = new Date();
2519
+ // 当天的日期
2520
+ var nowTimeStr = "".concat(now.getFullYear(), "-").concat(String(now.getMonth() + 1).padStart(2, "0"), "-").concat(String(now.getDate()).padStart(2, "0"));
2521
+ //判断与上一条数据 是否跨天
2435
2522
  if (beforeTimeStr !== curTimeStr) {
2523
+ // 跨天
2524
+ // 显示日期+时间
2436
2525
  time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
2437
2526
  } else {
2438
2527
  //没有跨天 判断是否相隔超过10分钟
2439
2528
  if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
2440
- time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
2529
+ //判断是否当天
2530
+ if (curTimeStr === nowTimeStr) {
2531
+ // 当天,显示时间
2532
+ time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
2533
+ } else {
2534
+ // 非当天,显示日期+时间
2535
+ time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
2536
+ }
2441
2537
  }
2442
2538
  }
2443
2539
  }
@@ -2446,7 +2542,9 @@ var CustomerService = function(props) {
2446
2542
  // let code = message.split("```");
2447
2543
  // code = code[1];
2448
2544
  // console.log(code,888888888);
2449
- message = removeMermaidBlockComments(message);
2545
+ if (finishedRef.current || i != historyMessageList.length - 1) {
2546
+ message = removeMermaidBlockComments(message);
2547
+ }
2450
2548
  message = handleRenderSyntaxBlock(message, finishedRef.current || i != historyMessageList.length - 1);
2451
2549
  if (lastId == item.id && keyWordProblem != "") {
2452
2550
  //点击历史记录时,找到关键字,防止关键字和标签名重复
@@ -2546,17 +2644,23 @@ var CustomerService = function(props) {
2546
2644
  },
2547
2645
  className: styles.content_child
2548
2646
  }),
2549
- !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2647
+ !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo).find(function(x) {
2648
+ return x.key == "imageUrl";
2649
+ }) && /*#__PURE__*/ _jsxs("p", {
2550
2650
  className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2551
2651
  children: [
2552
2652
  /*#__PURE__*/ _jsx("img", {
2553
- src: JSON.parse(item.extraInfo)[0].value
2653
+ src: JSON.parse(item.extraInfo).find(function(x) {
2654
+ return x.key == "imageUrl";
2655
+ }).value
2554
2656
  }),
2555
2657
  /*#__PURE__*/ _jsx("div", {
2556
2658
  className: styles.mask_zoom,
2557
2659
  children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2558
2660
  onClick: function() {
2559
- setViewBase64(JSON.parse(item.extraInfo)[0].value);
2661
+ setViewBase64(JSON.parse(item.extraInfo).find(function(x) {
2662
+ return x.key == "imageUrl";
2663
+ }).value);
2560
2664
  setVisible(true);
2561
2665
  }
2562
2666
  })
@@ -2654,7 +2758,10 @@ var CustomerService = function(props) {
2654
2758
  style: {
2655
2759
  marginRight: "12px"
2656
2760
  },
2657
- children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
2761
+ children: isAiChatWindow ? // item.extraInfo == null || header == 1
2762
+ userData.modules.some(function(item) {
2763
+ return item.short == "AIservice";
2764
+ }) ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
2658
2765
  src: knowledge_icon
2659
2766
  }) : /*#__PURE__*/ _jsx("img", {
2660
2767
  src: headImg
@@ -2760,17 +2867,23 @@ var CustomerService = function(props) {
2760
2867
  })
2761
2868
  ]
2762
2869
  }),
2763
- !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
2870
+ !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo).find(function(x) {
2871
+ return x.key == "imageUrl";
2872
+ }) && /*#__PURE__*/ _jsxs("p", {
2764
2873
  className: "".concat(styles.img_con, " ").concat(showType == 2 || showType == 4 ? styles.img_con2 : ""),
2765
2874
  children: [
2766
2875
  /*#__PURE__*/ _jsx("img", {
2767
- src: JSON.parse(item.extraInfo)[0].value
2876
+ src: JSON.parse(item.extraInfo).find(function(x) {
2877
+ return x.key == "imageUrl";
2878
+ }).value
2768
2879
  }),
2769
2880
  /*#__PURE__*/ _jsx("div", {
2770
2881
  className: styles.mask_zoom,
2771
2882
  children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
2772
2883
  onClick: function() {
2773
- setViewBase64(JSON.parse(item.extraInfo)[0].value);
2884
+ setViewBase64(JSON.parse(item.extraInfo).find(function(x) {
2885
+ return x.key == "imageUrl";
2886
+ }).value);
2774
2887
  setVisible(true);
2775
2888
  }
2776
2889
  })
@@ -3399,44 +3512,50 @@ var CustomerService = function(props) {
3399
3512
  };
3400
3513
  //发送截图信息
3401
3514
  var sendScreenshotData = function(message) {
3402
- if (contactsList.length > 0 && contactsList[0].roomId == roomId) {
3403
- setKeyWord("");
3404
- setCitationContent({});
3405
- setBottomRecommendationQuestions([]);
3406
- setHistoryMessageList(function(historyMessageList) {
3407
- var newHistoryMessageList = historyMessageList.concat({
3408
- id: "p" + new Date().getTime(),
3515
+ if (userData.modules.some(function(item) {
3516
+ return item.short == "AIservice";
3517
+ })) {
3518
+ if (contactsList.length > 0 && contactsList[0].roomId == roomId) {
3519
+ setKeyWord("");
3520
+ setCitationContent({});
3521
+ setBottomRecommendationQuestions([]);
3522
+ setHistoryMessageList(function(historyMessageList) {
3523
+ var newHistoryMessageList = historyMessageList.concat({
3524
+ id: "p" + new Date().getTime(),
3525
+ roomId: roomId,
3526
+ sender: mid,
3527
+ recevier: "AI",
3528
+ message: message,
3529
+ createdAt: getDataTime(-1),
3530
+ extraInfo: JSON.stringify([
3531
+ {
3532
+ key: "imageUrl",
3533
+ value: screenshotBese64
3534
+ }
3535
+ ])
3536
+ });
3537
+ return newHistoryMessageList;
3538
+ });
3539
+ //ai窗口
3540
+ aiSendQuestions(3, {
3541
+ //相关数据
3409
3542
  roomId: roomId,
3410
- sender: mid,
3411
- recevier: "AI",
3412
3543
  message: message,
3413
- createdAt: getDataTime(-1),
3414
- extraInfo: JSON.stringify([
3415
- {
3416
- key: "imageUrl",
3417
- value: screenshotBese64
3418
- }
3419
- ])
3420
- });
3421
- return newHistoryMessageList;
3422
- });
3423
- //ai窗口
3424
- aiSendQuestions(3, {
3425
- //相关数据
3426
- roomId: roomId,
3427
- message: message,
3428
- image: screenshotBese64,
3429
- quotedMessage: citationContent.content || "",
3430
- regenerate: citationContent.content != "" ? false : true,
3431
- generateUpvoteOrDownvoteMessage: false
3432
- }, 1);
3433
- setScreenshotBese64("");
3544
+ image: screenshotBese64,
3545
+ quotedMessage: citationContent.content || "",
3546
+ regenerate: citationContent.content != "" ? false : true,
3547
+ generateUpvoteOrDownvoteMessage: false
3548
+ }, 1);
3549
+ setScreenshotBese64("");
3550
+ } else {
3551
+ //老师窗口
3552
+ sendToTeacher(3, message);
3553
+ }
3554
+ scrollToBottom();
3555
+ resettingBottomHei();
3434
3556
  } else {
3435
- //老师窗口
3436
- sendToTeacher(3, message);
3557
+ sendGreetingMessage(4, message);
3437
3558
  }
3438
- scrollToBottom();
3439
- resettingBottomHei();
3440
3559
  };
3441
3560
  //渲染底部按钮
3442
3561
  var renderBottomAnt = function() {
package/esm/utils/Date.js CHANGED
@@ -1,5 +1,9 @@
1
1
  var parseDate = function(dateStr) {
2
2
  var date = new Date(dateStr); // 创建一个日期对象,表示当前时间
3
+ // @ts-ignore
4
+ if (date == "Invalid Date") {
5
+ date = new Date();
6
+ }
3
7
  var year = date.getFullYear().toString(); // 获取年份
4
8
  var month = String(date.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
5
9
  var day = String(date.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.10.35",
3
+ "version": "0.10.37",
4
4
  "description": "组件功能描述",
5
5
  "config": {
6
6
  "commitizen": {