bhd-components 0.6.7 → 0.6.9

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.
@@ -105,7 +105,10 @@ const HistoryFun = (props)=>{
105
105
  number = index;
106
106
  }
107
107
  });
108
- const pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
108
+ let pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
109
+ if (number == 0) {
110
+ pageNumber = 1;
111
+ }
109
112
  console.log(roomId, pageNumber, id, receiver, "第几页第几页第几页第几页第几页第几页");
110
113
  loadSpecifiedData(roomId, pageNumber, id, receiver);
111
114
  onClose();
@@ -62,6 +62,8 @@ const CustomerService = (props)=>{
62
62
  let chatRoomList = useRef(null); //获取聊天室列表
63
63
  const ctrl = useRef(); //停止生成ai回答时使用
64
64
  let childRef = useRef(null); //获取子组件方法
65
+ let scrollTopHei = useRef(0);
66
+ let isPosition = useRef(true);
65
67
  const mid = props.userData.mid;
66
68
  const remarkable = new Remarkable({
67
69
  highlight: function(str, lang) {
@@ -100,7 +102,6 @@ const CustomerService = (props)=>{
100
102
  const scrollHeight = container.scrollHeight;
101
103
  // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
102
104
  if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
103
- console.log("到底部了22222");
104
105
  // if (pageNumHistory > 1) {
105
106
  // console.log(pageNumHistory,'pageNumpageNumpageNum')
106
107
  let number = pageNumHistory - 1;
@@ -110,29 +111,35 @@ const CustomerService = (props)=>{
110
111
  if (number > 0) {
111
112
  setBottomLoading(true);
112
113
  getHistoryMessage(number, 4);
114
+ setLastId("");
113
115
  } else {
114
116
  setPageNumHistory(0);
115
117
  }
116
- }, 100);
118
+ }, 1000);
117
119
  // } else {
118
- // setLastId("");
119
120
  // }
120
121
  }
121
122
  if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
122
123
  console.log("到顶了", pageNum);
123
- // if(pageNum == 1){
124
- // setFirstpage(true);//代表是否存在第一页
125
- // }
126
124
  setLoading(true);
127
125
  let number = pageNum + 1;
128
126
  setPageNum((pageNum)=>{
129
127
  return pageNum + 1;
130
128
  });
131
129
  listTimer.current = setTimeout(()=>{
132
- console.log("下拉加载下一页", number);
133
130
  getHistoryMessage(number, 2);
134
131
  }, 1000);
135
132
  }
133
+ //生成答案过程中
134
+ if (!finished && scrollTopHei.current > scrollTop) {
135
+ // setIsPosition(false);
136
+ isPosition.current = false;
137
+ }
138
+ if (!finished && clientHeight + scrollTop >= scrollHeight) {
139
+ // console.log('到顶了111');
140
+ isPosition.current = true;
141
+ }
142
+ scrollTopHei.current = scrollTop;
136
143
  }
137
144
  const content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
138
145
  if (content) {
@@ -407,11 +414,13 @@ const CustomerService = (props)=>{
407
414
  }));
408
415
  return newHistoryMessageList;
409
416
  });
410
- if (!lastId) {
411
- setTimeout(()=>{
412
- scrollToBottom();
413
- }, 100);
414
- }
417
+ // console.log(lastId,'消息发送给老师111');
418
+ // if (!lastId) {
419
+ setTimeout(()=>{
420
+ console.log('滚动到底部');
421
+ scrollToBottom();
422
+ }, 100);
423
+ // }
415
424
  }
416
425
  //判断当前窗口是否是
417
426
  if (type == 1) {
@@ -726,11 +735,19 @@ const CustomerService = (props)=>{
726
735
  }
727
736
  if (msg.finished) {
728
737
  setFinished(true); //发送结束
738
+ // isPosition.current = true;
739
+ setTimeout(()=>{
740
+ isPosition.current = true;
741
+ }, 100);
729
742
  testLabQuestion(JSON.parse(data).message, content, "");
730
743
  }
731
744
  },
732
745
  onclose () {
733
746
  setFinished(true); //发送结束
747
+ // isPosition.current = true;
748
+ setTimeout(()=>{
749
+ isPosition.current = true;
750
+ }, 100);
734
751
  setHistoryMessageList((historyMessageList)=>{
735
752
  return historyMessageList.filter((item)=>item.id != "123456");
736
753
  });
@@ -793,9 +810,11 @@ const CustomerService = (props)=>{
793
810
  return newHistoryMessageList2;
794
811
  }
795
812
  });
796
- // setTimeout(() => {
797
- scrollToBottom();
798
- // }, 10);
813
+ setTimeout(()=>{
814
+ if (isPosition.current) {
815
+ scrollToBottom();
816
+ }
817
+ }, 10);
799
818
  };
800
819
  //问题记录到实验报告中
801
820
  const testLabQuestion = (title, content, teachId)=>{
@@ -840,13 +859,14 @@ const CustomerService = (props)=>{
840
859
  //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
841
860
  const getHistoryMessage = (pageNum, flag, id = "1", raw_data = [])=>{
842
861
  clearTimeout(roomMessage.current);
843
- // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
862
+ console.log(pageNum, flag, 'dkfjvndfjvndfkvdf');
844
863
  // flag == 1 时已经设置好了位置标记
845
864
  let last_id = "";
846
865
  if (flag == 2 && historyMessageList.length > 0) {
847
866
  last_id = historyMessageList[0].id;
848
867
  }
849
868
  if (flag != 1 && last_id != "") {
869
+ console.log(last_id, 'dkfjvndfjvndfkvdflast_idlast_idlast_id');
850
870
  setLastId(last_id);
851
871
  }
852
872
  //取消搜索页码标记
@@ -986,6 +1006,7 @@ const CustomerService = (props)=>{
986
1006
  if (!lastId && originList != newList) {
987
1007
  setTimeout(()=>{
988
1008
  scrollToBottom();
1009
+ readMessage(roomId, urllocation, userData, http);
989
1010
  }, 100);
990
1011
  }
991
1012
  }
@@ -1884,7 +1905,7 @@ const CustomerService = (props)=>{
1884
1905
  return /*#__PURE__*/ _jsxs("div", {
1885
1906
  className: `${styles.operate_modal_bottom}`,
1886
1907
  style: {
1887
- position: showStopBtn ? 'sticky' : 'relative'
1908
+ position: showStopBtn && isPosition.current ? 'sticky' : 'relative'
1888
1909
  },
1889
1910
  children: [
1890
1911
  /*#__PURE__*/ _jsxs("p", {
@@ -2077,7 +2098,7 @@ const CustomerService = (props)=>{
2077
2098
  let placeholder = "";
2078
2099
  let disabled = false;
2079
2100
  if (voiceRecordingStatus == 2) {
2080
- placeholder = "语音录制中,请说话...";
2101
+ placeholder = "正在录制语音,再次点击麦克风结束录制。";
2081
2102
  } else if (voiceRecordingStatus == 1) {
2082
2103
  placeholder = "正在语音识别文字,请稍后...";
2083
2104
  } else if (!finished) {
@@ -2151,6 +2172,11 @@ const CustomerService = (props)=>{
2151
2172
  setQuestionsList([]);
2152
2173
  setAnswerMode(-1);
2153
2174
  setTeacherList([]);
2175
+ setTimeout(()=>{
2176
+ setQuestionsList([]);
2177
+ setTeacherList([]);
2178
+ clearTimeout(timer.current);
2179
+ }, 200);
2154
2180
  setHistoryMessageList((historyMessageList)=>{
2155
2181
  return historyMessageList.filter((item)=>item.id != "-1");
2156
2182
  });
@@ -2254,6 +2280,11 @@ const CustomerService = (props)=>{
2254
2280
  setQuestionsList([]);
2255
2281
  setAnswerMode(-1);
2256
2282
  setTeacherList([]);
2283
+ setTimeout(()=>{
2284
+ setQuestionsList([]);
2285
+ setTeacherList([]);
2286
+ clearTimeout(timer.current);
2287
+ }, 200);
2257
2288
  setHistoryMessageList((historyMessageList)=>{
2258
2289
  return historyMessageList.filter((item)=>item.id != "-1");
2259
2290
  });
@@ -151,6 +151,8 @@
151
151
  display: flex;
152
152
  flex-direction: column;
153
153
  align-items: flex-end;
154
+
155
+
154
156
  }
155
157
  }
156
158
  .right {
@@ -181,12 +183,10 @@
181
183
  width: 100%;
182
184
  .main {
183
185
  max-width: 80%;
184
- // .content:hover ~ .main_content{
185
- // .operate_modal {
186
- // // display: block;
187
- // visibility: visible;
188
- // }
189
- // }
186
+
187
+ .main_content_flag{
188
+ width: 100%;
189
+ }
190
190
  .main_content_flag:hover{
191
191
  .operate_modal {
192
192
  // display: block;
@@ -195,21 +195,9 @@
195
195
  }
196
196
  .main_content {
197
197
  position: relative;
198
- // &:hover {
199
- // .operate_modal {
200
- // // display: block;
201
- // visibility: visible;
202
- // }
203
- // }
204
-
198
+
205
199
  .content {
206
- // &:hover {
207
- // .operate_modal {
208
- // // display: block;
209
- // visibility: visible;
210
- // }
211
- // }
212
-
200
+
213
201
  max-width: 100%;
214
202
  // width: 100%;
215
203
  //以下优化ai返回的内容的样式
@@ -218,6 +206,7 @@
218
206
  line-height: 1;
219
207
  p{
220
208
  word-break: break-all;
209
+ white-space: break-spaces;
221
210
  }
222
211
  p,
223
212
  li {
@@ -231,6 +220,13 @@
231
220
  padding: 10px 0;
232
221
  }
233
222
  ol {
223
+ list-style: decimal;
224
+ padding-inline-start: 20px;
225
+
226
+ li{
227
+ list-style-type: auto;
228
+ }
229
+
234
230
  li p {
235
231
  padding: 4px 0;
236
232
  font-size: 14px;
@@ -429,6 +425,7 @@
429
425
  font-weight: 400;
430
426
  line-height: 1.8;
431
427
  cursor: pointer;
428
+ list-style-type: none;
432
429
  }
433
430
  }
434
431
  .time {
@@ -153,6 +153,8 @@
153
153
  display: flex;
154
154
  flex-direction: column;
155
155
  align-items: flex-end;
156
+
157
+
156
158
  }
157
159
  }
158
160
  .right {
@@ -183,12 +185,10 @@
183
185
  width: 100%;
184
186
  .main {
185
187
  max-width: 80%;
186
- // .content:hover ~ .main_content{
187
- // .operate_modal {
188
- // // display: block;
189
- // visibility: visible;
190
- // }
191
- // }
188
+
189
+ .main_content_flag{
190
+ width: 100%;
191
+ }
192
192
  .main_content_flag:hover{
193
193
  .operate_modal {
194
194
  // display: block;
@@ -197,21 +197,9 @@
197
197
  }
198
198
  .main_content {
199
199
  position: relative;
200
- // &:hover {
201
- // .operate_modal {
202
- // // display: block;
203
- // visibility: visible;
204
- // }
205
- // }
206
-
200
+
207
201
  .content {
208
- // &:hover {
209
- // .operate_modal {
210
- // // display: block;
211
- // visibility: visible;
212
- // }
213
- // }
214
-
202
+
215
203
  max-width: 100%;
216
204
  // width: 100%;
217
205
  //以下优化ai返回的内容的样式
@@ -220,6 +208,7 @@
220
208
  line-height: 1;
221
209
  p{
222
210
  word-break: break-all;
211
+ white-space: break-spaces;
223
212
  }
224
213
  p,
225
214
  li {
@@ -233,6 +222,13 @@
233
222
  padding: 10px 0;
234
223
  }
235
224
  ol {
225
+ list-style: decimal;
226
+ padding-inline-start: 20px;
227
+
228
+ li{
229
+ list-style-type: auto;
230
+ }
231
+
236
232
  li p {
237
233
  padding: 4px 0;
238
234
  font-size: 14px;
@@ -431,6 +427,7 @@
431
427
  font-weight: 400;
432
428
  line-height: 1.8;
433
429
  cursor: pointer;
430
+ list-style-type: none;
434
431
  }
435
432
  }
436
433
  .time {
@@ -107,6 +107,9 @@ var HistoryFun = function(props) {
107
107
  }
108
108
  });
109
109
  var pageNumber = findPageNumber(30, Math.ceil(total / 30), number);
110
+ if (number == 0) {
111
+ pageNumber = 1;
112
+ }
110
113
  console.log(roomId, pageNumber, id, receiver, "第几页第几页第几页第几页第几页第几页");
111
114
  loadSpecifiedData(roomId, pageNumber, id, receiver);
112
115
  onClose();
@@ -63,6 +63,8 @@ var CustomerService = function(props) {
63
63
  var chatRoomList = useRef(null); //获取聊天室列表
64
64
  var ctrl = useRef(); //停止生成ai回答时使用
65
65
  var childRef = useRef(null); //获取子组件方法
66
+ var scrollTopHei = useRef(0);
67
+ var isPosition = useRef(true);
66
68
  var mid = props.userData.mid;
67
69
  var remarkable = new Remarkable({
68
70
  highlight: function highlight(str, lang) {
@@ -95,7 +97,6 @@ var CustomerService = function(props) {
95
97
  var scrollHeight = container.scrollHeight;
96
98
  // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
97
99
  if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
98
- console.log("到底部了22222");
99
100
  // if (pageNumHistory > 1) {
100
101
  // console.log(pageNumHistory,'pageNumpageNumpageNum')
101
102
  var number = pageNumHistory - 1;
@@ -105,29 +106,35 @@ var CustomerService = function(props) {
105
106
  if (number > 0) {
106
107
  setBottomLoading(true);
107
108
  getHistoryMessage(number, 4);
109
+ setLastId("");
108
110
  } else {
109
111
  setPageNumHistory(0);
110
112
  }
111
- }, 100);
113
+ }, 1000);
112
114
  // } else {
113
- // setLastId("");
114
115
  // }
115
116
  }
116
117
  if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
117
118
  console.log("到顶了", pageNum);
118
- // if(pageNum == 1){
119
- // setFirstpage(true);//代表是否存在第一页
120
- // }
121
119
  setLoading(true);
122
120
  var number1 = pageNum + 1;
123
121
  setPageNum(function(pageNum) {
124
122
  return pageNum + 1;
125
123
  });
126
124
  listTimer.current = setTimeout(function() {
127
- console.log("下拉加载下一页", number1);
128
125
  getHistoryMessage(number1, 2);
129
126
  }, 1000);
130
127
  }
128
+ //生成答案过程中
129
+ if (!finished && scrollTopHei.current > scrollTop) {
130
+ // setIsPosition(false);
131
+ isPosition.current = false;
132
+ }
133
+ if (!finished && clientHeight + scrollTop >= scrollHeight) {
134
+ // console.log('到顶了111');
135
+ isPosition.current = true;
136
+ }
137
+ scrollTopHei.current = scrollTop;
131
138
  };
132
139
  if (showType != 1 && !firstLoad && pageCount > 0) {
133
140
  setFirstLoad(true);
@@ -412,11 +419,13 @@ var CustomerService = function(props) {
412
419
  }));
413
420
  return newHistoryMessageList;
414
421
  });
415
- if (!lastId) {
416
- setTimeout(function() {
417
- scrollToBottom();
418
- }, 100);
419
- }
422
+ // console.log(lastId,'消息发送给老师111');
423
+ // if (!lastId) {
424
+ setTimeout(function() {
425
+ console.log("滚动到底部");
426
+ scrollToBottom();
427
+ }, 100);
428
+ // }
420
429
  }
421
430
  //判断当前窗口是否是
422
431
  if (type == 1) {
@@ -743,11 +752,19 @@ var CustomerService = function(props) {
743
752
  }
744
753
  if (msg.finished) {
745
754
  setFinished(true); //发送结束
755
+ // isPosition.current = true;
756
+ setTimeout(function() {
757
+ isPosition.current = true;
758
+ }, 100);
746
759
  testLabQuestion(JSON.parse(data).message, content, "");
747
760
  }
748
761
  },
749
762
  onclose: function onclose() {
750
763
  setFinished(true); //发送结束
764
+ // isPosition.current = true;
765
+ setTimeout(function() {
766
+ isPosition.current = true;
767
+ }, 100);
751
768
  setHistoryMessageList(function(historyMessageList) {
752
769
  return historyMessageList.filter(function(item) {
753
770
  return item.id != "123456";
@@ -812,9 +829,11 @@ var CustomerService = function(props) {
812
829
  return newHistoryMessageList2;
813
830
  }
814
831
  });
815
- // setTimeout(() => {
816
- scrollToBottom();
817
- // }, 10);
832
+ setTimeout(function() {
833
+ if (isPosition.current) {
834
+ scrollToBottom();
835
+ }
836
+ }, 10);
818
837
  };
819
838
  //问题记录到实验报告中
820
839
  var testLabQuestion = function(title, content, teachId) {
@@ -862,13 +881,14 @@ var CustomerService = function(props) {
862
881
  var getHistoryMessage = function(pageNum, flag) {
863
882
  var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1", raw_data = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
864
883
  clearTimeout(roomMessage.current);
865
- // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
884
+ console.log(pageNum, flag, "dkfjvndfjvndfkvdf");
866
885
  // flag == 1 时已经设置好了位置标记
867
886
  var last_id = "";
868
887
  if (flag == 2 && historyMessageList.length > 0) {
869
888
  last_id = historyMessageList[0].id;
870
889
  }
871
890
  if (flag != 1 && last_id != "") {
891
+ console.log(last_id, "dkfjvndfjvndfkvdflast_idlast_idlast_id");
872
892
  setLastId(last_id);
873
893
  }
874
894
  //取消搜索页码标记
@@ -1014,6 +1034,7 @@ var CustomerService = function(props) {
1014
1034
  if (!lastId && originList != newList) {
1015
1035
  setTimeout(function() {
1016
1036
  scrollToBottom();
1037
+ readMessage(roomId, urllocation, userData, http);
1017
1038
  }, 100);
1018
1039
  }
1019
1040
  }
@@ -1948,7 +1969,7 @@ var CustomerService = function(props) {
1948
1969
  return /*#__PURE__*/ _jsxs("div", {
1949
1970
  className: "".concat(styles.operate_modal_bottom),
1950
1971
  style: {
1951
- position: showStopBtn ? "sticky" : "relative"
1972
+ position: showStopBtn && isPosition.current ? "sticky" : "relative"
1952
1973
  },
1953
1974
  children: [
1954
1975
  /*#__PURE__*/ _jsxs("p", {
@@ -2153,7 +2174,7 @@ var CustomerService = function(props) {
2153
2174
  var placeholder = "";
2154
2175
  var disabled = false;
2155
2176
  if (voiceRecordingStatus == 2) {
2156
- placeholder = "语音录制中,请说话...";
2177
+ placeholder = "正在录制语音,再次点击麦克风结束录制。";
2157
2178
  } else if (voiceRecordingStatus == 1) {
2158
2179
  placeholder = "正在语音识别文字,请稍后...";
2159
2180
  } else if (!finished) {
@@ -2231,6 +2252,11 @@ var CustomerService = function(props) {
2231
2252
  setQuestionsList([]);
2232
2253
  setAnswerMode(-1);
2233
2254
  setTeacherList([]);
2255
+ setTimeout(function() {
2256
+ setQuestionsList([]);
2257
+ setTeacherList([]);
2258
+ clearTimeout(timer.current);
2259
+ }, 200);
2234
2260
  setHistoryMessageList(function(historyMessageList) {
2235
2261
  return historyMessageList.filter(function(item) {
2236
2262
  return item.id != "-1";
@@ -2340,6 +2366,11 @@ var CustomerService = function(props) {
2340
2366
  setQuestionsList([]);
2341
2367
  setAnswerMode(-1);
2342
2368
  setTeacherList([]);
2369
+ setTimeout(function() {
2370
+ setQuestionsList([]);
2371
+ setTeacherList([]);
2372
+ clearTimeout(timer.current);
2373
+ }, 200);
2343
2374
  setHistoryMessageList(function(historyMessageList) {
2344
2375
  return historyMessageList.filter(function(item) {
2345
2376
  return item.id != "-1";
@@ -151,6 +151,8 @@
151
151
  display: flex;
152
152
  flex-direction: column;
153
153
  align-items: flex-end;
154
+
155
+
154
156
  }
155
157
  }
156
158
  .right {
@@ -181,12 +183,10 @@
181
183
  width: 100%;
182
184
  .main {
183
185
  max-width: 80%;
184
- // .content:hover ~ .main_content{
185
- // .operate_modal {
186
- // // display: block;
187
- // visibility: visible;
188
- // }
189
- // }
186
+
187
+ .main_content_flag{
188
+ width: 100%;
189
+ }
190
190
  .main_content_flag:hover{
191
191
  .operate_modal {
192
192
  // display: block;
@@ -195,21 +195,9 @@
195
195
  }
196
196
  .main_content {
197
197
  position: relative;
198
- // &:hover {
199
- // .operate_modal {
200
- // // display: block;
201
- // visibility: visible;
202
- // }
203
- // }
204
-
198
+
205
199
  .content {
206
- // &:hover {
207
- // .operate_modal {
208
- // // display: block;
209
- // visibility: visible;
210
- // }
211
- // }
212
-
200
+
213
201
  max-width: 100%;
214
202
  // width: 100%;
215
203
  //以下优化ai返回的内容的样式
@@ -218,6 +206,7 @@
218
206
  line-height: 1;
219
207
  p{
220
208
  word-break: break-all;
209
+ white-space: break-spaces;
221
210
  }
222
211
  p,
223
212
  li {
@@ -231,6 +220,13 @@
231
220
  padding: 10px 0;
232
221
  }
233
222
  ol {
223
+ list-style: decimal;
224
+ padding-inline-start: 20px;
225
+
226
+ li{
227
+ list-style-type: auto;
228
+ }
229
+
234
230
  li p {
235
231
  padding: 4px 0;
236
232
  font-size: 14px;
@@ -429,6 +425,7 @@
429
425
  font-weight: 400;
430
426
  line-height: 1.8;
431
427
  cursor: pointer;
428
+ list-style-type: none;
432
429
  }
433
430
  }
434
431
  .time {