bhd-components 0.6.6 → 0.6.7

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.
@@ -280,6 +280,7 @@ var HistoryFun = function(props) {
280
280
  }),
281
281
  /*#__PURE__*/ _jsx("span", {
282
282
  onClick: function() {
283
+ loadSpecifiedData();
283
284
  onClose();
284
285
  },
285
286
  children: /*#__PURE__*/ _jsx(CustomClose, {})
@@ -351,13 +352,18 @@ var HistoryFun = function(props) {
351
352
  var span = "";
352
353
  var time = "";
353
354
  if (item.count == 1) {
354
- // span = item.message.replaceAll(keyWordProblem, () => {
355
- // return `<span class=${styles.sign}>${keyWordProblem}</span>`;
356
- // });
357
- span = item.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
358
- // console.log(i,'skdcnsdjk')
359
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
360
- });
355
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
356
+ //搜索内容是否有特殊字符
357
+ if (reg.test(keyWordProblem)) {
358
+ span = item.message.replaceAll(keyWordProblem, function(e) {
359
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
360
+ });
361
+ } else {
362
+ span = item.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
363
+ // console.log(i,'skdcnsdjk')
364
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
365
+ });
366
+ }
361
367
  var currentTime = getDataTime(-1, 1); //当前时间
362
368
  var createdAt = getDataTime(item.createdAt, 1);
363
369
  if (currentTime == createdAt) {
@@ -439,16 +445,19 @@ var HistoryFun = function(props) {
439
445
  } else {
440
446
  time = getDataTime(list.updatedAt);
441
447
  }
442
- // let span = list.message.replace(
443
- // /keyWordProblem/gi,
444
- // () => {
445
- // return `<span class=${styles.sign}>${keyWordProblem}</span>`;
446
- // }
447
- // );
448
- var span = list.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
449
- // console.log(i,'skdcnsdjk')
450
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
451
- });
448
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
449
+ var span = "";
450
+ //搜索内容是否有特殊字符
451
+ if (reg.test(keyWordProblem)) {
452
+ span = list.message.replaceAll(keyWordProblem, function(e) {
453
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
454
+ });
455
+ } else {
456
+ span = list.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
457
+ // console.log(i,'skdcnsdjk')
458
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
459
+ });
460
+ }
452
461
  return /*#__PURE__*/ _jsxs("div", {
453
462
  className: styles.list,
454
463
  onClick: function() {
@@ -94,21 +94,24 @@ var CustomerService = function(props) {
94
94
  var clientHeight = container.clientHeight;
95
95
  var scrollHeight = container.scrollHeight;
96
96
  // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
97
- if (clientHeight + scrollTop + 0.5 >= scrollHeight) {
97
+ if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
98
98
  console.log("到底部了22222");
99
- // console.log(11111111,pageNumHistory)
100
- if (pageNumHistory > 1) {
101
- // console.log(pageNumHistory,'pageNumpageNumpageNum')
102
- var number = pageNumHistory - 1;
103
- setPageNumHistory(number);
104
- clearTimeout(listTimer.current);
105
- setBottomLoading(true);
106
- listTimer.current = setTimeout(function() {
99
+ // if (pageNumHistory > 1) {
100
+ // console.log(pageNumHistory,'pageNumpageNumpageNum')
101
+ var number = pageNumHistory - 1;
102
+ setPageNumHistory(number);
103
+ clearTimeout(listTimer.current);
104
+ listTimer.current = setTimeout(function() {
105
+ if (number > 0) {
106
+ setBottomLoading(true);
107
107
  getHistoryMessage(number, 4);
108
- }, 1000);
109
- } else {
110
- setLastId("");
111
- }
108
+ } else {
109
+ setPageNumHistory(0);
110
+ }
111
+ }, 100);
112
+ // } else {
113
+ // setLastId("");
114
+ // }
112
115
  }
113
116
  if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
114
117
  console.log("到顶了", pageNum);
@@ -346,17 +349,19 @@ var CustomerService = function(props) {
346
349
  setCitationContent({});
347
350
  http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
348
351
  if (res.data.id) {
349
- setHistoryMessageList(function(historyMessageList) {
350
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
351
- id: res.data.id,
352
- upvoted: false,
353
- downvoted: false,
354
- quotedMessage: "",
355
- createdAt: getDataTime(-1),
356
- extraInfo: JSON.stringify(obj.extraInfos)
357
- }));
358
- return newHistoryMessageList;
359
- });
352
+ if (pageNumHistory <= 1) {
353
+ setHistoryMessageList(function(historyMessageList) {
354
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
355
+ id: res.data.id,
356
+ upvoted: false,
357
+ downvoted: false,
358
+ quotedMessage: "",
359
+ createdAt: getDataTime(-1),
360
+ extraInfo: JSON.stringify(obj.extraInfos)
361
+ }));
362
+ return newHistoryMessageList;
363
+ });
364
+ }
360
365
  scrollToBottom();
361
366
  if (type == 4) {
362
367
  sendGreetingMessage(6);
@@ -469,21 +474,23 @@ var CustomerService = function(props) {
469
474
  } else if (userData.modules.some(function(item) {
470
475
  return item.short == "AIservice";
471
476
  })) {
472
- setHistoryMessageList(function(historyMessageList) {
473
- var newHistoryMessageList = historyMessageList.concat({
474
- roomId: roomId,
475
- sender: mid,
476
- recevier: "AI",
477
- message: keyWord,
478
- quotedMessage: citationContent.content,
479
- id: "654321",
480
- upvoted: false,
481
- downvoted: false,
482
- createdAt: getDataTime(-1),
483
- extraInfo: JSON.stringify([])
477
+ if (pageNumHistory <= 1) {
478
+ setHistoryMessageList(function(historyMessageList) {
479
+ var newHistoryMessageList = historyMessageList.concat({
480
+ roomId: roomId,
481
+ sender: mid,
482
+ recevier: "AI",
483
+ message: keyWord,
484
+ quotedMessage: citationContent.content,
485
+ id: "654321",
486
+ upvoted: false,
487
+ downvoted: false,
488
+ createdAt: getDataTime(-1),
489
+ extraInfo: JSON.stringify([])
490
+ });
491
+ return newHistoryMessageList;
484
492
  });
485
- return newHistoryMessageList;
486
- });
493
+ }
487
494
  setFinished(false);
488
495
  aiSendQuestions(3, {
489
496
  //相关数据
@@ -501,32 +508,36 @@ var CustomerService = function(props) {
501
508
  };
502
509
  //向知识库发送问题 或答案 type:1 发送问题 2 接受答案
503
510
  var sendingExistingIssues = function(type, obj, questions) {
504
- setHistoryMessageList(function(historyMessageList) {
505
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
506
- id: null,
507
- upvoted: false,
508
- downvoted: false,
509
- createdAt: getDataTime(-1),
510
- extraInfo: JSON.stringify(obj.extraInfos)
511
- }));
512
- return newHistoryMessageList;
513
- });
514
- scrollToBottom();
511
+ if (pageNumHistory <= 1) {
512
+ setHistoryMessageList(function(historyMessageList) {
513
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
514
+ id: null,
515
+ upvoted: false,
516
+ downvoted: false,
517
+ createdAt: getDataTime(-1),
518
+ extraInfo: JSON.stringify(obj.extraInfos)
519
+ }));
520
+ return newHistoryMessageList;
521
+ });
522
+ scrollToBottom();
523
+ }
515
524
  http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
516
525
  if (res.data.id) {
517
- //更新聊天记录id
518
- setHistoryMessageList(function(historyMessageList) {
519
- var newHistoryMessageList = historyMessageList.map(function(item) {
520
- if (item.id == null) {
521
- return _object_spread_props(_object_spread({}, item), {
522
- id: res.data.id
523
- });
524
- } else {
525
- return item;
526
- }
526
+ if (pageNumHistory <= 1) {
527
+ //更新聊天记录id
528
+ setHistoryMessageList(function(historyMessageList) {
529
+ var newHistoryMessageList = historyMessageList.map(function(item) {
530
+ if (item.id == null) {
531
+ return _object_spread_props(_object_spread({}, item), {
532
+ id: res.data.id
533
+ });
534
+ } else {
535
+ return item;
536
+ }
537
+ });
538
+ return newHistoryMessageList;
527
539
  });
528
- return newHistoryMessageList;
529
- });
540
+ }
530
541
  }
531
542
  if (type == 1) {
532
543
  //发送答案,调用自动回答
@@ -591,39 +602,42 @@ var CustomerService = function(props) {
591
602
  setTimeout(function() {
592
603
  setQuestionsList([]);
593
604
  }, 2000);
605
+ // console.log(pageNumHistory,44444444444444);
594
606
  //占位信息
595
- setHistoryMessageList(function(historyMessageList) {
596
- if (type == 2) {
597
- return historyMessageList.map(function(item) {
598
- if (item.id == id) {
599
- return {
600
- roomId: roomId,
601
- sender: "AI",
602
- recevier: mid,
603
- message: "正在输入...",
604
- id: "123456",
605
- createdAt: getDataTime(-1),
606
- extraInfo: null
607
- };
608
- } else {
609
- return item;
610
- }
611
- });
612
- } else {
613
- return historyMessageList.concat({
614
- roomId: roomId,
615
- sender: "AI",
616
- recevier: mid,
617
- message: "正在输入...",
618
- id: "123456",
619
- createdAt: getDataTime(-1),
620
- extraInfo: null
621
- });
622
- }
623
- });
624
- setTimeout(function() {
625
- scrollToBottom();
626
- }, 10);
607
+ if (pageNumHistory <= 1) {
608
+ setHistoryMessageList(function(historyMessageList) {
609
+ if (type == 2) {
610
+ return historyMessageList.map(function(item) {
611
+ if (item.id == id) {
612
+ return {
613
+ roomId: roomId,
614
+ sender: "AI",
615
+ recevier: mid,
616
+ message: "正在输入...",
617
+ id: "123456",
618
+ createdAt: getDataTime(-1),
619
+ extraInfo: null
620
+ };
621
+ } else {
622
+ return item;
623
+ }
624
+ });
625
+ } else {
626
+ return historyMessageList.concat({
627
+ roomId: roomId,
628
+ sender: "AI",
629
+ recevier: mid,
630
+ message: "正在输入...",
631
+ id: "123456",
632
+ createdAt: getDataTime(-1),
633
+ extraInfo: null
634
+ });
635
+ }
636
+ });
637
+ setTimeout(function() {
638
+ scrollToBottom();
639
+ }, 10);
640
+ }
627
641
  //使用fetchEventSource接收数据
628
642
  var eventSource = fetchEventSource("".concat(urllocation, "/chat-service/public/v1.0/chat-with-ai/messages"), {
629
643
  method: "POST",
@@ -744,7 +758,9 @@ var CustomerService = function(props) {
744
758
  };
745
759
  //渲染AI回答
746
760
  var renderAiAnswer = function(msg, message_id, type) {
761
+ // console.log(pageNumHistory,5555555);
747
762
  // console.log(aiSendQuestions().abort(),'slkdsdsdsd')
763
+ if (pageNumHistory > 1) return;
748
764
  var obj = msg;
749
765
  var id = msg.messageId;
750
766
  setHistoryMessageList(function(historyMessageList) {
@@ -844,7 +860,7 @@ var CustomerService = function(props) {
844
860
  };
845
861
  //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
846
862
  var getHistoryMessage = function(pageNum, flag) {
847
- var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1";
863
+ var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1", raw_data = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
848
864
  clearTimeout(roomMessage.current);
849
865
  // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
850
866
  // flag == 1 时已经设置好了位置标记
@@ -861,10 +877,11 @@ var CustomerService = function(props) {
861
877
  }
862
878
  var rid = flag == 3 ? id : roomId;
863
879
  if (rid == "") return;
880
+ var page = pageNum ? pageNum : 1;
864
881
  return http.get("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), {
865
882
  params: {
866
883
  roomId: rid,
867
- page: pageNum ? pageNum : 1,
884
+ page: page,
868
885
  maxPageSize: 30,
869
886
  direction: "desc"
870
887
  }
@@ -876,6 +893,13 @@ var CustomerService = function(props) {
876
893
  var total = res.data.total;
877
894
  var maxPageSize = 30;
878
895
  var dataList = res.data.messages.reverse();
896
+ //历史记录点击进来的,多加载一页,防止定位不准
897
+ if (flag == 1 && page > 1) {
898
+ var markPage = page - 1;
899
+ setPageNumHistory(markPage);
900
+ getHistoryMessage(page - 1, 5, "1", dataList);
901
+ return;
902
+ }
879
903
  setPageCount(Math.ceil(total / maxPageSize));
880
904
  var newHistoryMessageList = [];
881
905
  setHistoryMessageList(function(historyMessageList) {
@@ -884,6 +908,9 @@ var CustomerService = function(props) {
884
908
  if (flag == 1) {
885
909
  newHistoryMessageList = dataList;
886
910
  }
911
+ if (flag == 5) {
912
+ newHistoryMessageList = raw_data.concat(dataList);
913
+ }
887
914
  if (flag == 4) {
888
915
  newHistoryMessageList = historyMessageList.concat(dataList); //下拉加载,向后追加内容
889
916
  }
@@ -905,6 +932,7 @@ var CustomerService = function(props) {
905
932
  totalNumber = newHistoryMessageList.length;
906
933
  return newHistoryMessageList;
907
934
  });
935
+ // console.log(lastId,'lastIdlastId-------')
908
936
  //如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
909
937
  try {
910
938
  if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
@@ -1237,13 +1265,12 @@ var CustomerService = function(props) {
1237
1265
  container.scrollTop = 60;
1238
1266
  try {
1239
1267
  setTimeout(function() {
1240
- // let top2 =
1268
+ var top = showType == 1 || showType == 3 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1269
+ // let top =
1241
1270
  // showType == 1 || showType == 3
1242
- // ? $("#li_flag").offset().top - 20
1271
+ // ? $("#li_flag").offset().top
1243
1272
  // : $("#chat_content_modal #li_flag").offset().top -
1244
- // $("#chat_content_modal").offset().top +
1245
- // 24;
1246
- var top = showType == 1 || showType == 3 ? $("#li_flag").offset().top : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top;
1273
+ // $("#chat_content_modal").offset().top;
1247
1274
  // console.log(top2,top,444444444444)
1248
1275
  $("#".concat(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal")).animate({
1249
1276
  scrollTop: top
@@ -2194,15 +2221,21 @@ var CustomerService = function(props) {
2194
2221
  setButtomHei(45);
2195
2222
  return;
2196
2223
  }
2197
- } else {}
2224
+ }
2198
2225
  //跟老师对话
2199
2226
  var roomList = contactsList;
2200
2227
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2201
2228
  sendToTeacher(2);
2202
2229
  } else {
2203
- setAnswerMode(-1);
2230
+ clearTimeout(timer.current);
2204
2231
  setQuestionsList([]);
2232
+ setAnswerMode(-1);
2205
2233
  setTeacherList([]);
2234
+ setHistoryMessageList(function(historyMessageList) {
2235
+ return historyMessageList.filter(function(item) {
2236
+ return item.id != "-1";
2237
+ });
2238
+ });
2206
2239
  sendMessage("", 0);
2207
2240
  }
2208
2241
  setButtomHei(45);
@@ -2303,6 +2336,15 @@ var CustomerService = function(props) {
2303
2336
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2304
2337
  sendToTeacher(2);
2305
2338
  } else {
2339
+ clearTimeout(timer.current);
2340
+ setQuestionsList([]);
2341
+ setAnswerMode(-1);
2342
+ setTeacherList([]);
2343
+ setHistoryMessageList(function(historyMessageList) {
2344
+ return historyMessageList.filter(function(item) {
2345
+ return item.id != "-1";
2346
+ });
2347
+ });
2306
2348
  sendMessage("", 0);
2307
2349
  }
2308
2350
  onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
@@ -2351,9 +2393,19 @@ var CustomerService = function(props) {
2351
2393
  bottom: "".concat(buttomHei + 14, "px")
2352
2394
  },
2353
2395
  children: teacherList.map(function(item) {
2354
- var span = item.name.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2355
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2356
- });
2396
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2397
+ var span = "";
2398
+ //搜索内容是否有特殊字符
2399
+ if (reg.test(keyWord)) {
2400
+ span = item.name.replaceAll(keyWord, function(e) {
2401
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
2402
+ });
2403
+ } else {
2404
+ span = item.name.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2405
+ // console.log(i,'skdcnsdjk')
2406
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2407
+ });
2408
+ }
2357
2409
  return /*#__PURE__*/ _jsx("p", {
2358
2410
  className: styles.item,
2359
2411
  children: /*#__PURE__*/ _jsx("span", {
@@ -2374,9 +2426,19 @@ var CustomerService = function(props) {
2374
2426
  bottom: "".concat(buttomHei + 6, "px")
2375
2427
  },
2376
2428
  children: questionsList.map(function(item) {
2377
- var span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2378
- return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2379
- });
2429
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2430
+ var span = "";
2431
+ //搜索内容是否有特殊字符
2432
+ if (reg.test(keyWord)) {
2433
+ span = item.question.replaceAll(keyWord, function(e) {
2434
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
2435
+ });
2436
+ } else {
2437
+ span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2438
+ // console.log(i,'skdcnsdjk')
2439
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2440
+ });
2441
+ }
2380
2442
  return /*#__PURE__*/ _jsx("p", {
2381
2443
  className: styles.item,
2382
2444
  children: /*#__PURE__*/ _jsx("span", {
@@ -2396,25 +2458,26 @@ var CustomerService = function(props) {
2396
2458
  };
2397
2459
  //加载指定数据,点击历史记录
2398
2460
  var loadSpecifiedData = function(renewRoomId, page, id, receiver) {
2461
+ // let renewRoomId = '4a615d7126b343f78d10dcb06dbc29b0';
2462
+ // let page = 1;
2463
+ // let id = '0e459f0a3a62438698f170b42b94d150';
2464
+ // let receiver = mid;
2399
2465
  if (page != 1) {
2400
2466
  setPageNumHistory(page);
2401
2467
  }
2402
- setPageNum(page);
2403
2468
  setLastId(id); //用于定位
2469
+ setPageNum(page);
2404
2470
  //如果是当前聊天室
2405
2471
  if (renewRoomId == roomId) {
2406
2472
  getHistoryMessage(page, 1);
2407
2473
  } else {
2408
2474
  setRoomId(renewRoomId);
2409
- // if (childRef.current) {
2410
2475
  if (receiver != mid) {
2411
2476
  createRooms(receiver);
2412
2477
  }
2413
2478
  setTimeout(function() {
2414
- // childRef.current.roomsListTimer();
2415
2479
  roomsListTimer();
2416
2480
  }, 500);
2417
- // }
2418
2481
  }
2419
2482
  setShowContacts(true);
2420
2483
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",