bhd-components 0.9.12 → 0.9.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.
@@ -31,11 +31,11 @@ var TextArea = Input.TextArea;
31
31
  // import './html2canvas.test.js';
32
32
  import knowledge_icon from "./images/knowledge_icon.png";
33
33
  // import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
34
- import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate } from "./function"; //一些方法
34
+ import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, urlToBase64 } from "./function"; //一些方法
35
35
  // import html2canvas from "html2canvas";
36
- // const screenShot = require('./screenShotPlugin.esm')
36
+ // const screenShot = require('./screenShotPlugin.esm')
37
37
  import ScreenShot from "./js-screen-shot/main";
38
- /*
38
+ /*
39
39
  自定义remarkable的text解析规则
40
40
  */ var HTML_ESCAPE_TEST_RE = /[&<>"]/;
41
41
  var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
@@ -73,6 +73,7 @@ var CustomerService = function(props) {
73
73
  var _useState11 = _sliced_to_array(useState(false), 2), loading = _useState11[0], setLoading = _useState11[1]; //上拉显示加载图标
74
74
  var _useState12 = _sliced_to_array(useState(false), 2), bottomLoading = _useState12[0], setBottomLoading = _useState12[1]; //下拉显示加载图标
75
75
  var _useState13 = _sliced_to_array(useState(true), 2), finished = _useState13[0], setFinished = _useState13[1]; //是否结束生成
76
+ var finishedRef = useRef(true); //是否结束生成
76
77
  var _useState14 = _sliced_to_array(useState(""), 2), lastId = _useState14[0], setLastId = _useState14[1]; //最后一条数据的id,可用于定位当前位置
77
78
  var _useState15 = _sliced_to_array(useState({}), 2), chatWith = _useState15[0], setChatWith = _useState15[1]; //聊天的老师id或ai
78
79
  var _useState16 = _sliced_to_array(useState(false), 2), firstLoad = _useState16[0], setFirstLoad = _useState16[1]; //第一次切换全屏时滚动到页面底部
@@ -322,12 +323,13 @@ var CustomerService = function(props) {
322
323
  }, 1000);
323
324
  }
324
325
  //生成答案过程中
325
- if (!finished && scrollTopHei.current > scrollTop) {
326
+ if (!finished && scrollHeight > scrollTop) {
327
+ console.log("生成答案过程中", scrollTopHei.current, scrollTop);
326
328
  // setIsPosition(false);
327
329
  isPosition.current = false;
328
330
  }
329
331
  if (!finished && clientHeight + scrollTop >= scrollHeight) {
330
- // console.log('到顶了111');
332
+ console.log("到顶了111", clientHeight, scrollTop, scrollHeight);
331
333
  isPosition.current = true;
332
334
  }
333
335
  scrollTopHei.current = scrollTop;
@@ -728,217 +730,256 @@ var CustomerService = function(props) {
728
730
  });
729
731
  };
730
732
  //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
731
- var sendToTeacher = function(type) {
732
- var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
733
- console.log("消息发送给老师111");
734
- var obj = {};
735
- if (type == 1) {
736
- obj = {
737
- roomId: roomId,
738
- sender: mid,
739
- recevier: chatWith.uid,
740
- message: problem.question
741
- };
742
- if (problem.url) {
743
- obj.image = problem.url;
744
- }
745
- setProblem({});
746
- } else if (type == 2 || type == 3) {
747
- var list = contactsList.filter(function(item) {
748
- return item.roomId == roomId;
749
- });
750
- var recevier = "";
751
- if (list.length > 0) {
752
- recevier = list[0].sender;
753
- }
754
- obj = {
755
- roomId: roomId,
756
- sender: mid,
757
- recevier: recevier,
758
- message: type == 2 ? keyWord : message,
759
- quotedMessage: citationContent.content || ""
760
- };
761
- if (citationContent.imageUrl) {
762
- obj.image = citationContent.imageUrl;
763
- }
764
- if (screenshotBese64) {
765
- obj.image = screenshotBese64;
766
- setScreenshotBese64("");
767
- }
768
- }
769
- http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
770
- if (res.data.id) {
771
- // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
772
- if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
773
- setHistoryMessageList(function(historyMessageList) {
774
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
775
- id: res.data.id,
776
- upvoted: false,
777
- downvoted: false,
778
- createdAt: getDataTime(-1),
779
- extraInfo: obj.image ? JSON.stringify([
780
- {
781
- key: "imageUrl",
782
- value: obj.image
783
- }
784
- ]) : null
785
- }));
786
- return newHistoryMessageList;
787
- });
788
- // console.log(lastId,'消息发送给老师111');
789
- scrollToBottom();
790
- }
791
- //判断当前窗口是否是
733
+ var sendToTeacher = function() {
734
+ var _ref = _async_to_generator(function(type) {
735
+ var message, obj, list, recevier;
736
+ var _arguments = arguments;
737
+ return _ts_generator(this, function(_state) {
738
+ message = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "";
739
+ console.log("消息发送给老师111");
740
+ obj = {};
792
741
  if (type == 1) {
793
- var roomList = [
794
- {
795
- roomId: roomId,
796
- id: res.data.id
797
- }
798
- ];
799
- setChatObj(function(list) {
800
- var list2 = list.filter(function(item) {
801
- return item.id != roomList[0].id;
802
- });
803
- return list2.concat(roomList);
742
+ obj = {
743
+ roomId: roomId,
744
+ sender: mid,
745
+ recevier: chatWith.uid,
746
+ message: problem.question
747
+ };
748
+ if (problem.url) {
749
+ obj.image = problem.url;
750
+ }
751
+ setProblem({});
752
+ } else if (type == 2 || type == 3) {
753
+ list = contactsList.filter(function(item) {
754
+ return item.roomId == roomId;
804
755
  });
756
+ recevier = "";
757
+ if (list.length > 0) {
758
+ recevier = list[0].sender;
759
+ }
760
+ obj = {
761
+ roomId: roomId,
762
+ sender: mid,
763
+ recevier: recevier,
764
+ message: type == 2 ? keyWord : message,
765
+ quotedMessage: citationContent.content || ""
766
+ };
767
+ if (citationContent.imageUrl) {
768
+ obj.image = citationContent.imageUrl;
769
+ }
770
+ if (screenshotBese64) {
771
+ obj.image = screenshotBese64;
772
+ setScreenshotBese64("");
773
+ }
805
774
  }
806
- }
807
- }).catch(function(err) {
808
- console.log(err);
775
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
776
+ if (res.data.id) {
777
+ // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
778
+ if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
779
+ setHistoryMessageList(function(historyMessageList) {
780
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
781
+ id: res.data.id,
782
+ upvoted: false,
783
+ downvoted: false,
784
+ createdAt: getDataTime(-1),
785
+ extraInfo: obj.image ? JSON.stringify([
786
+ {
787
+ key: "imageUrl",
788
+ value: obj.image
789
+ }
790
+ ]) : null
791
+ }));
792
+ return newHistoryMessageList;
793
+ });
794
+ // console.log(lastId,'消息发送给老师111');
795
+ scrollToBottom();
796
+ }
797
+ //判断当前窗口是否是
798
+ if (type == 1) {
799
+ var roomList = [
800
+ {
801
+ roomId: roomId,
802
+ id: res.data.id
803
+ }
804
+ ];
805
+ setChatObj(function(list) {
806
+ var list2 = list.filter(function(item) {
807
+ return item.id != roomList[0].id;
808
+ });
809
+ return list2.concat(roomList);
810
+ });
811
+ }
812
+ }
813
+ }).catch(function(err) {
814
+ console.log(err);
815
+ });
816
+ return [
817
+ 2
818
+ ];
819
+ });
809
820
  });
810
- };
821
+ return function sendToTeacher(type) {
822
+ return _ref.apply(this, arguments);
823
+ };
824
+ }();
811
825
  //发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息,flag == 3 是针对视频页面点击底部推荐问题
812
826
  var sendMessage = function() {
813
827
  var _ref = _async_to_generator(function(item, flag) {
814
- var type, questions, sendData, obj, sendData1, imageUrl;
828
+ var type, questions, sendData, obj, sendData1, imageUrl, base64;
815
829
  var _arguments = arguments;
816
830
  return _ts_generator(this, function(_state) {
817
- type = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "";
818
- console.log(item, flag, 888888888);
819
- questions = [];
820
- if (item && flag) {
821
- questions = [
822
- item
823
- ];
824
- }
825
- //点击知识库的问题,或者是点击问候消息
826
- if (questions.length > 0) {
827
- questions = questions[0];
828
- //知识库联想的问题没有答案
829
- if (!questions.answer && userData.modules.some(function(item) {
830
- return item.short == "AIservice";
831
- })) {
832
- sendData = {
833
- //相关数据
831
+ switch(_state.label){
832
+ case 0:
833
+ type = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "";
834
+ console.log(item, flag, 888888888);
835
+ questions = [];
836
+ if (item && flag) {
837
+ questions = [
838
+ item
839
+ ];
840
+ }
841
+ if (!(questions.length > 0)) return [
842
+ 3,
843
+ 1
844
+ ];
845
+ questions = questions[0];
846
+ //知识库联想的问题没有答案
847
+ if (!questions.answer && userData.modules.some(function(item) {
848
+ return item.short == "AIservice";
849
+ })) {
850
+ sendData = {
851
+ //相关数据
852
+ roomId: roomId,
853
+ message: questions.question,
854
+ quotedMessage: "",
855
+ regenerate: true,
856
+ generateUpvoteOrDownvoteMessage: false
857
+ };
858
+ if (pageNumHistory <= 1) {
859
+ setHistoryMessageList(function(historyMessageList) {
860
+ var newHistoryMessageList = historyMessageList.concat({
861
+ roomId: roomId,
862
+ sender: mid,
863
+ recevier: "AI",
864
+ message: questions.question,
865
+ quotedMessage: "",
866
+ id: "p" + new Date().getTime(),
867
+ upvoted: false,
868
+ downvoted: false,
869
+ createdAt: getDataTime(-1),
870
+ extraInfo: JSON.stringify([])
871
+ });
872
+ return newHistoryMessageList;
873
+ });
874
+ }
875
+ setFinished(false);
876
+ aiSendQuestions(3, sendData, 1);
877
+ return [
878
+ 2
879
+ ];
880
+ }
881
+ console.log(questions, "知识库内容11111");
882
+ obj = {
834
883
  roomId: roomId,
884
+ sender: mid,
885
+ recevier: "AI",
835
886
  message: questions.question,
836
- quotedMessage: "",
837
- regenerate: true,
887
+ extraInfos: [
888
+ {
889
+ key: "questionId",
890
+ value: flag == 1 ? questions.value : questions.id
891
+ }
892
+ ]
893
+ };
894
+ //发送问题 1 类型,发送问题需要的参数,问题的答案id等
895
+ sendingExistingIssues(1, obj, {
896
+ key: "questionId",
897
+ value: flag == 1 ? questions.value : questions.id,
898
+ answer: questions.answer
899
+ }, type);
900
+ setKeyWord("");
901
+ setQuestionsList([]);
902
+ setCitationContent({});
903
+ return [
904
+ 3,
905
+ 5
906
+ ];
907
+ case 1:
908
+ if (!userData.modules.some(function(item) {
909
+ return item.short == "AIservice";
910
+ })) return [
911
+ 3,
912
+ 4
913
+ ];
914
+ console.log("citationContent", citationContent);
915
+ sendData1 = {
916
+ //相关数据
917
+ roomId: roomId,
918
+ message: keyWord,
919
+ quotedMessage: citationContent.content || "",
920
+ regenerate: citationContent.content != "" ? false : true,
838
921
  generateUpvoteOrDownvoteMessage: false
839
922
  };
923
+ imageUrl = "";
924
+ if (!citationContent.imageUrl) return [
925
+ 3,
926
+ 3
927
+ ];
928
+ return [
929
+ 4,
930
+ urlToBase64(citationContent.imageUrl)
931
+ ];
932
+ case 2:
933
+ base64 = _state.sent();
934
+ console.log("base64", base64);
935
+ console.log("citationContent.imageUrl", citationContent.imageUrl);
936
+ sendData1.image = base64;
937
+ imageUrl = base64;
938
+ _state.label = 3;
939
+ case 3:
940
+ if (screenshotBese64) {
941
+ console.log("screenshotBese64", screenshotBese64);
942
+ sendData1.image = screenshotBese64;
943
+ imageUrl = screenshotBese64;
944
+ }
840
945
  if (pageNumHistory <= 1) {
841
946
  setHistoryMessageList(function(historyMessageList) {
842
947
  var newHistoryMessageList = historyMessageList.concat({
843
948
  roomId: roomId,
844
949
  sender: mid,
845
950
  recevier: "AI",
846
- message: questions.question,
847
- quotedMessage: "",
951
+ message: keyWord,
952
+ quotedMessage: citationContent.content,
848
953
  id: "p" + new Date().getTime(),
849
954
  upvoted: false,
850
955
  downvoted: false,
851
956
  createdAt: getDataTime(-1),
852
- extraInfo: JSON.stringify([])
957
+ extraInfo: imageUrl ? JSON.stringify([
958
+ {
959
+ key: "imageUrl",
960
+ value: imageUrl
961
+ }
962
+ ]) : JSON.stringify([])
853
963
  });
854
964
  return newHistoryMessageList;
855
965
  });
856
966
  }
857
967
  setFinished(false);
858
- aiSendQuestions(3, sendData, 1);
968
+ aiSendQuestions(3, sendData1, 1);
969
+ setScreenshotBese64("");
970
+ return [
971
+ 3,
972
+ 5
973
+ ];
974
+ case 4:
975
+ //不存在AI客服
976
+ sendGreetingMessage(4);
977
+ _state.label = 5;
978
+ case 5:
859
979
  return [
860
980
  2
861
981
  ];
862
- }
863
- console.log(questions, "知识库内容11111");
864
- obj = {
865
- roomId: roomId,
866
- sender: mid,
867
- recevier: "AI",
868
- message: questions.question,
869
- extraInfos: [
870
- {
871
- key: "questionId",
872
- value: flag == 1 ? questions.value : questions.id
873
- }
874
- ]
875
- };
876
- //发送问题 1 类型,发送问题需要的参数,问题的答案id等
877
- sendingExistingIssues(1, obj, {
878
- key: "questionId",
879
- value: flag == 1 ? questions.value : questions.id,
880
- answer: questions.answer
881
- }, type);
882
- setKeyWord("");
883
- setQuestionsList([]);
884
- setCitationContent({});
885
- } else if (userData.modules.some(function(item) {
886
- return item.short == "AIservice";
887
- })) {
888
- console.log("citationContent", citationContent);
889
- sendData1 = {
890
- //相关数据
891
- roomId: roomId,
892
- message: keyWord,
893
- quotedMessage: citationContent.content || "",
894
- regenerate: citationContent.content != "" ? false : true,
895
- generateUpvoteOrDownvoteMessage: false
896
- };
897
- imageUrl = "";
898
- if (citationContent.imageUrl) {
899
- // let base64:string=await urlToBase64(citationContent.imageUrl) as string
900
- console.log("citationContent.imageUrl", citationContent.imageUrl);
901
- sendData1.image = citationContent.imageUrl;
902
- imageUrl = citationContent.imageUrl;
903
- }
904
- if (screenshotBese64) {
905
- console.log("screenshotBese64", screenshotBese64);
906
- sendData1.image = screenshotBese64;
907
- imageUrl = screenshotBese64;
908
- }
909
- if (pageNumHistory <= 1) {
910
- setHistoryMessageList(function(historyMessageList) {
911
- var newHistoryMessageList = historyMessageList.concat({
912
- roomId: roomId,
913
- sender: mid,
914
- recevier: "AI",
915
- message: keyWord,
916
- quotedMessage: citationContent.content,
917
- id: "p" + new Date().getTime(),
918
- upvoted: false,
919
- downvoted: false,
920
- createdAt: getDataTime(-1),
921
- extraInfo: imageUrl ? JSON.stringify([
922
- {
923
- key: "imageUrl",
924
- value: imageUrl
925
- }
926
- ]) : JSON.stringify([])
927
- });
928
- return newHistoryMessageList;
929
- });
930
- }
931
- setFinished(false);
932
- aiSendQuestions(3, sendData1, 1);
933
- setScreenshotBese64("");
934
- //存在AI客服
935
- } else {
936
- //不存在AI客服
937
- sendGreetingMessage(4);
938
982
  }
939
- return [
940
- 2
941
- ];
942
983
  });
943
984
  });
944
985
  return function sendMessage(item, flag) {
@@ -1107,69 +1148,76 @@ var CustomerService = function(props) {
1107
1148
  signal: ctrl.current.signal,
1108
1149
  openWhenHidden: true,
1109
1150
  onopen: function onopen(res) {
1110
- console.info("eventSource open: ", res);
1111
- clearTimeout(receiveMessageTimer.current);
1112
- if (res.status >= 300) {
1113
- console.log("sdckjsdncskdcjsdc", res.status);
1114
- setFinished(true);
1115
- setHistoryMessageList(function(historyMessageList) {
1116
- return historyMessageList.filter(function(item) {
1117
- return item.id != "123456" && item.id != "654321";
1118
- });
1119
- });
1120
- ctrl.current.abort();
1121
- }
1122
- if (res.status == 200) {
1123
- setFinished(false);
1124
- }
1125
- if (res.status == 401) {
1126
- //身份认证未通过,从新请求新的token后再次发送请求
1127
- verifyJWT(urllocation).then(function() {
1128
- console.log("重新请求");
1129
- setHistoryMessageList(function(historyMessageList) {
1130
- return historyMessageList.filter(function(item) {
1131
- return item.id != "123456" && item.id != "654321";
1151
+ return _async_to_generator(function() {
1152
+ return _ts_generator(this, function(_state) {
1153
+ console.info("eventSource open: ", res);
1154
+ clearTimeout(receiveMessageTimer.current);
1155
+ if (res.status >= 300) {
1156
+ console.log("sdckjsdncskdcjsdc", res.status);
1157
+ setFinished(true);
1158
+ setHistoryMessageList(function(historyMessageList) {
1159
+ return historyMessageList.filter(function(item) {
1160
+ return item.id != "123456" && item.id != "654321";
1161
+ });
1132
1162
  });
1133
- });
1134
- aiSendQuestions(type, obj, id);
1135
- });
1136
- }
1137
- if (res.status == 403) {
1138
- //暂无权限
1139
- console.log("暂无权限");
1140
- setHistoryMessageList(function(historyMessageList) {
1141
- return historyMessageList.concat({
1142
- roomId: roomId,
1143
- sender: "AI",
1144
- recevier: mid,
1145
- message: "暂无权限",
1146
- id: "123456",
1147
- createdAt: "",
1148
- extraInfo: null
1149
- });
1150
- });
1151
- }
1152
- if (res.status == 429) {
1153
- //同一时间只允许进行一个对话。
1154
- }
1155
- if (res.status == 429) {
1156
- //每天问答的 Token 数必须小于等于 10 万。
1157
- sendGreetingMessage(5);
1158
- }
1159
- if (res.status == 500) {
1160
- // 系统错误,请稍后再试。
1161
- setHistoryMessageList(function(historyMessageList) {
1162
- return historyMessageList.concat({
1163
- roomId: roomId,
1164
- sender: "AI",
1165
- recevier: mid,
1166
- message: "系统出错了,请稍后重试!",
1167
- id: "123456",
1168
- createdAt: "",
1169
- extraInfo: null
1170
- });
1163
+ ctrl.current.abort();
1164
+ }
1165
+ if (res.status == 200) {
1166
+ setFinished(false);
1167
+ }
1168
+ if (res.status == 401) {
1169
+ //身份认证未通过,从新请求新的token后再次发送请求
1170
+ verifyJWT(urllocation).then(function() {
1171
+ console.log("重新请求");
1172
+ setHistoryMessageList(function(historyMessageList) {
1173
+ return historyMessageList.filter(function(item) {
1174
+ return item.id != "123456" && item.id != "654321";
1175
+ });
1176
+ });
1177
+ aiSendQuestions(type, obj, id);
1178
+ });
1179
+ }
1180
+ if (res.status == 403) {
1181
+ //暂无权限
1182
+ console.log("暂无权限");
1183
+ setHistoryMessageList(function(historyMessageList) {
1184
+ return historyMessageList.concat({
1185
+ roomId: roomId,
1186
+ sender: "AI",
1187
+ recevier: mid,
1188
+ message: "暂无权限",
1189
+ id: "123456",
1190
+ createdAt: "",
1191
+ extraInfo: null
1192
+ });
1193
+ });
1194
+ }
1195
+ if (res.status == 429) {
1196
+ //同一时间只允许进行一个对话。
1197
+ }
1198
+ if (res.status == 429) {
1199
+ //每天问答的 Token 数必须小于等于 10 万。
1200
+ sendGreetingMessage(5);
1201
+ }
1202
+ if (res.status == 500) {
1203
+ // 系统错误,请稍后再试。
1204
+ setHistoryMessageList(function(historyMessageList) {
1205
+ return historyMessageList.concat({
1206
+ roomId: roomId,
1207
+ sender: "AI",
1208
+ recevier: mid,
1209
+ message: "系统出错了,请稍后重试!",
1210
+ id: "123456",
1211
+ createdAt: "",
1212
+ extraInfo: null
1213
+ });
1214
+ });
1215
+ }
1216
+ return [
1217
+ 2
1218
+ ];
1171
1219
  });
1172
- }
1220
+ })();
1173
1221
  },
1174
1222
  onerror: function onerror(err) {
1175
1223
  console.log(err, "dflkvdmfvlkdfv");
@@ -1190,31 +1238,39 @@ var CustomerService = function(props) {
1190
1238
  //识别的内容
1191
1239
  // console.log("eventSource msg: ", event.data);
1192
1240
  var msg = JSON.parse(event.data);
1193
- if (msg.message) {
1194
- content = content + msg.message;
1195
- // isPosition.current = true;
1196
- renderAiAnswerTimer.current = setTimeout(function() {
1241
+ if (msg.message) {}
1242
+ setFinished(function(prevData) {
1243
+ finishedRef.current = false;
1244
+ return finishedRef.current;
1245
+ });
1246
+ console.log("返回中", msg);
1247
+ content = content + msg.message;
1248
+ // isPosition.current = true;
1249
+ renderAiAnswerTimer.current = setTimeout(function() {
1250
+ if (!finishedRef.current) {
1197
1251
  renderAiAnswer(msg, id, type);
1198
- }, 100);
1199
- }
1252
+ }
1253
+ }, 100);
1200
1254
  if (msg.finished) {
1201
- setFinished(true); //发送结束
1255
+ // console.log('返回完成',msg)
1256
+ // setFinished(true); //发送结束
1202
1257
  if (!flagKeyWord) {
1203
1258
  videoPageQuestiionsList(2);
1204
1259
  }
1205
1260
  // isPosition.current = true;
1206
- setTimeout(function() {
1207
- isPosition.current = true;
1208
- }, 100);
1261
+ // setTimeout(()=>{
1262
+ // isPosition.current = true;
1263
+ // },100)
1209
1264
  testLabQuestion(JSON.parse(data).message, content, "");
1210
- }
1265
+ } else {}
1211
1266
  },
1212
1267
  onclose: function onclose() {
1213
- setFinished(true); //发送结束
1214
- // isPosition.current = true;
1215
- setTimeout(function() {
1216
- isPosition.current = true;
1217
- }, 100);
1268
+ console.log("eventSource close");
1269
+ // setFinished(true); //发送结束
1270
+ // // isPosition.current = true;
1271
+ // setTimeout(()=>{
1272
+ // isPosition.current = true;
1273
+ // },100)
1218
1274
  setHistoryMessageList(function(historyMessageList) {
1219
1275
  return historyMessageList.filter(function(item) {
1220
1276
  return item.id != "123456";
@@ -1295,9 +1351,20 @@ var CustomerService = function(props) {
1295
1351
  return newHistoryMessageList2;
1296
1352
  }
1297
1353
  });
1298
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1299
- if (container) {
1300
- container.scrollTop = container.scrollHeight;
1354
+ console.log("isPosition", isPosition.current);
1355
+ if (isPosition.current) {
1356
+ var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1357
+ if (container) {
1358
+ container.scrollTop = container.scrollHeight;
1359
+ }
1360
+ }
1361
+ if (msg.finished) {
1362
+ console.log("返回完成", msg);
1363
+ //发送结束
1364
+ setFinished(function(prevData) {
1365
+ finishedRef.current = true;
1366
+ return finishedRef.current;
1367
+ });
1301
1368
  }
1302
1369
  // console.log('historyMessageList',historyMessageList)
1303
1370
  // if(isPosition.current){
@@ -2699,7 +2766,11 @@ var CustomerService = function(props) {
2699
2766
  return item.id != "123456";
2700
2767
  });
2701
2768
  });
2702
- setFinished(true);
2769
+ // setFinished(true);
2770
+ setFinished(function(prevData) {
2771
+ finishedRef.current = true;
2772
+ return finishedRef.current;
2773
+ });
2703
2774
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
2704
2775
  }
2705
2776
  }),
@@ -2717,7 +2788,11 @@ var CustomerService = function(props) {
2717
2788
  return item.id != "123456";
2718
2789
  });
2719
2790
  });
2720
- setFinished(true);
2791
+ // setFinished(true);
2792
+ setFinished(function(prevData) {
2793
+ finishedRef.current = true;
2794
+ return finishedRef.current;
2795
+ });
2721
2796
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
2722
2797
  },
2723
2798
  children: "停止生成"