bhd-components 0.10.22 → 0.10.24
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.
- package/dist/index.esm.es5.development.css +1419 -1123
- package/dist/index.esm.es5.development.js +698 -566
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +2177 -2177
- package/dist/vendor.esm.es5.production.js +98 -98
- package/es2017/customerService/historyFun.js +2 -2
- package/es2017/customerService/index.js +713 -581
- package/es2017/customerService/index.module.less +21 -6
- package/es2017/customerService/index2.module.less +16 -4
- package/esm/customerService/historyFun.js +2 -2
- package/esm/customerService/index.js +691 -558
- package/esm/customerService/index.module.less +21 -6
- package/esm/customerService/index2.module.less +16 -4
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import ViewImage from "../viewImage";
|
|
|
9
9
|
import cssStyle from "./index.module.less";
|
|
10
10
|
import cssStyleOnline from "./index2.module.less";
|
|
11
11
|
import Input from "../bhdEnterInput";
|
|
12
|
+
import { Virtuoso } from "react-virtuoso";
|
|
12
13
|
let styles = cssStyle;
|
|
13
14
|
if (false) {
|
|
14
15
|
styles = cssStyleOnline;
|
|
@@ -60,6 +61,7 @@ const CustomerService = (props)=>{
|
|
|
60
61
|
const [citationContent, setCitationContent] = useState({}); //引用内容
|
|
61
62
|
const [roomId, setRoomId] = useState(""); //聊天室id
|
|
62
63
|
const [historyMessageList, setHistoryMessageList] = useState([]); //历史消息
|
|
64
|
+
const historyMessageListRef = useRef([]);
|
|
63
65
|
const [keyWord, setKeyWord] = useState(""); //搜索内容
|
|
64
66
|
const [questionsList, setQuestionsList] = useState([]); //问题列表
|
|
65
67
|
const [hotQuestionsList, setHotQuestionsList] = useState([]); //热门问题
|
|
@@ -73,6 +75,7 @@ const CustomerService = (props)=>{
|
|
|
73
75
|
const [finished, setFinished] = useState(true); //是否结束生成
|
|
74
76
|
const finishedRef = useRef(true); //是否结束生成
|
|
75
77
|
const [lastId, setLastId] = useState(""); //最后一条数据的id,可用于定位当前位置
|
|
78
|
+
const lastIdRef = useRef("");
|
|
76
79
|
const [chatWith, setChatWith] = useState({}); //聊天的老师id或ai
|
|
77
80
|
const [firstLoad, setFirstLoad] = useState(false); //第一次切换全屏时滚动到页面底部
|
|
78
81
|
const [buttomHei, setButtomHei] = useState(45); //底部输入框的高度
|
|
@@ -102,6 +105,7 @@ const CustomerService = (props)=>{
|
|
|
102
105
|
const ctrl = useRef(); //停止生成ai回答时使用
|
|
103
106
|
let childRef = useRef(null); //获取子组件方法
|
|
104
107
|
let scrollTopHei = useRef(0);
|
|
108
|
+
let [isPositionState, setIsPositionState] = useState(true);
|
|
105
109
|
let isPosition = useRef(true);
|
|
106
110
|
let recommendeQuestionID = useRef([]); //推荐问题id
|
|
107
111
|
let videoHotQuestionsList = useRef([]); //视频热门问题
|
|
@@ -109,6 +113,10 @@ const CustomerService = (props)=>{
|
|
|
109
113
|
let newShowType = useRef(false);
|
|
110
114
|
const mid = props.userData.mid;
|
|
111
115
|
const renderAiAnswerTimer = useRef(null);
|
|
116
|
+
const historyMessageListVirtuosoRef = useRef(null);
|
|
117
|
+
const [firstItemIndex, setFirstItemIndex] = useState(0);
|
|
118
|
+
const [historyMessageListVirtuosoHeight, setHistoryMessageListVirtuosoHeight] = useState(null);
|
|
119
|
+
const msgStreamingCountRef = useRef(0);
|
|
112
120
|
const remarkable = new Remarkable({
|
|
113
121
|
html: true,
|
|
114
122
|
highlight: function(str, lang) {
|
|
@@ -144,8 +152,7 @@ const CustomerService = (props)=>{
|
|
|
144
152
|
};
|
|
145
153
|
return newRemarkable.render(message);
|
|
146
154
|
};
|
|
147
|
-
const [screenShotType, setScreenShotType] = useState(0) //1是 screenShotPlugin 2是html2canvas
|
|
148
|
-
;
|
|
155
|
+
const [screenShotType, setScreenShotType] = useState(0); //1是 screenShotPlugin 2是html2canvas
|
|
149
156
|
const screenShotPlugin = useRef();
|
|
150
157
|
useEffect(()=>{
|
|
151
158
|
// if(config && config.type == 'video'){
|
|
@@ -161,11 +168,11 @@ const CustomerService = (props)=>{
|
|
|
161
168
|
console.log('kkkkkkkkkkk');
|
|
162
169
|
try {
|
|
163
170
|
newShowType.current = true;
|
|
164
|
-
setImgBese64(
|
|
171
|
+
setImgBese64("");
|
|
165
172
|
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
166
173
|
setScreenShotType(1);
|
|
167
|
-
console.log(
|
|
168
|
-
console.log(
|
|
174
|
+
// console.log("看看变了没有1213133");
|
|
175
|
+
// console.log("截图方式:【screenShotPlugin】", ScreenShot);
|
|
169
176
|
screenShotPlugin.current = new ScreenShot({
|
|
170
177
|
clickCutFullScreen: true,
|
|
171
178
|
enableWebRtc: true,
|
|
@@ -193,7 +200,7 @@ const CustomerService = (props)=>{
|
|
|
193
200
|
// base64
|
|
194
201
|
// );
|
|
195
202
|
setImgBese64(base64);
|
|
196
|
-
window.addEventListener(
|
|
203
|
+
window.addEventListener("resize", cancelScreenshot);
|
|
197
204
|
},
|
|
198
205
|
triggerCallback: ()=>{
|
|
199
206
|
// 截图组件加载完毕调用此方法来完成框选区域的截图
|
|
@@ -201,7 +208,7 @@ const CustomerService = (props)=>{
|
|
|
201
208
|
},
|
|
202
209
|
cancelCallback: (err)=>{
|
|
203
210
|
if (err.code === -1 || err.code === -2) {
|
|
204
|
-
console.log(err);
|
|
211
|
+
// console.log(err);
|
|
205
212
|
newShowType.current = false;
|
|
206
213
|
if (saveShowType != -1) {
|
|
207
214
|
setShowType(saveShowType);
|
|
@@ -217,8 +224,9 @@ const CustomerService = (props)=>{
|
|
|
217
224
|
});
|
|
218
225
|
} else {
|
|
219
226
|
setScreenShotType(2);
|
|
220
|
-
console.log(
|
|
227
|
+
// console.log("截图方式:【html2canvas】");
|
|
221
228
|
html2canvas(screenshotAreaId, {
|
|
229
|
+
//__docusaurus
|
|
222
230
|
useCORS: true,
|
|
223
231
|
allowTaint: true,
|
|
224
232
|
scale: 1,
|
|
@@ -270,11 +278,11 @@ const CustomerService = (props)=>{
|
|
|
270
278
|
// },
|
|
271
279
|
// });
|
|
272
280
|
} catch (error) {
|
|
273
|
-
|
|
281
|
+
// console.log(error);
|
|
274
282
|
}
|
|
275
283
|
}
|
|
276
284
|
function cancelScreenshot() {
|
|
277
|
-
console.log(
|
|
285
|
+
// console.log("cancelScreenshotcancelScreenshotcancelScreenshot");
|
|
278
286
|
newShowType.current = false;
|
|
279
287
|
if (saveShowType != -1) {
|
|
280
288
|
setShowType(saveShowType);
|
|
@@ -288,72 +296,81 @@ const CustomerService = (props)=>{
|
|
|
288
296
|
}
|
|
289
297
|
//|| showScreenshot
|
|
290
298
|
if (showType == 5 || showScreenshot) {
|
|
291
|
-
console.log(
|
|
299
|
+
// console.log("bbbbbbbbbbbbbb");
|
|
292
300
|
handlerHtml2canvas();
|
|
293
301
|
// window.addEventListener('resize',handlerHtml2canvas)
|
|
294
302
|
}
|
|
295
303
|
if (showType != 1 && !firstLoad && pageCount > 0) {
|
|
296
304
|
setFirstLoad(true);
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
function handleScroll() {
|
|
300
|
-
const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
301
|
-
const scrollTop = container.scrollTop;
|
|
302
|
-
const clientHeight = container.clientHeight;
|
|
303
|
-
const scrollHeight = container.scrollHeight;
|
|
304
|
-
// console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
|
|
305
|
-
if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
|
|
306
|
-
// if (pageNumHistory > 1) {
|
|
307
|
-
// console.log(pageNumHistory,'pageNumpageNumpageNum')
|
|
308
|
-
let number = pageNumHistory - 1;
|
|
309
|
-
setPageNumHistory(number);
|
|
310
|
-
clearTimeout(listTimer.current);
|
|
311
|
-
listTimer.current = setTimeout(()=>{
|
|
312
|
-
if (number > 0) {
|
|
313
|
-
setBottomLoading(true);
|
|
314
|
-
getHistoryMessage(number, 4);
|
|
315
|
-
setLastId("");
|
|
316
|
-
} else {
|
|
317
|
-
setPageNumHistory(0);
|
|
318
|
-
}
|
|
319
|
-
}, 1000);
|
|
320
|
-
// } else {
|
|
321
|
-
// }
|
|
322
|
-
}
|
|
323
|
-
if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
|
|
324
|
-
console.log("到顶了", pageNum);
|
|
325
|
-
setLoading(true);
|
|
326
|
-
let number = pageNum + 1;
|
|
327
|
-
setPageNum((pageNum)=>{
|
|
328
|
-
return pageNum + 1;
|
|
329
|
-
});
|
|
330
|
-
listTimer.current = setTimeout(()=>{
|
|
331
|
-
getHistoryMessage(number, 2);
|
|
332
|
-
}, 1000);
|
|
333
|
-
}
|
|
334
|
-
//生成答案过程中
|
|
335
|
-
if (!finished && scrollHeight > scrollTop) {
|
|
336
|
-
console.log('生成答案过程中', scrollTopHei.current, scrollTop);
|
|
337
|
-
// setIsPosition(false);
|
|
338
|
-
isPosition.current = false;
|
|
339
|
-
}
|
|
340
|
-
if (!finished && clientHeight + scrollTop >= scrollHeight) {
|
|
341
|
-
console.log('到顶了111', clientHeight, scrollTop, scrollHeight);
|
|
342
|
-
isPosition.current = true;
|
|
343
|
-
}
|
|
344
|
-
scrollTopHei.current = scrollTop;
|
|
345
|
-
}
|
|
346
|
-
const content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
347
|
-
if (content) {
|
|
348
|
-
content.addEventListener("scroll", handleScroll);
|
|
305
|
+
// scrollToBottom();
|
|
349
306
|
}
|
|
307
|
+
// function handleScroll() {
|
|
308
|
+
// const container = document.getElementById(
|
|
309
|
+
// showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
|
|
310
|
+
// );
|
|
311
|
+
// const scrollTop = container.scrollTop;
|
|
312
|
+
// const clientHeight = container.clientHeight;
|
|
313
|
+
// const scrollHeight = container.scrollHeight;
|
|
314
|
+
// // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
|
|
315
|
+
// if (
|
|
316
|
+
// clientHeight + scrollTop + 0.5 >= scrollHeight &&
|
|
317
|
+
// pageNumHistory > 1
|
|
318
|
+
// ) {
|
|
319
|
+
// // if (pageNumHistory > 1) {
|
|
320
|
+
// // console.log(pageNumHistory,'pageNumpageNumpageNum')
|
|
321
|
+
// let number = pageNumHistory - 1;
|
|
322
|
+
// setPageNumHistory(number);
|
|
323
|
+
// clearTimeout(listTimer.current);
|
|
324
|
+
// listTimer.current = setTimeout(() => {
|
|
325
|
+
// if (number > 0) {
|
|
326
|
+
// setBottomLoading(true);
|
|
327
|
+
// getHistoryMessage(number, 4);
|
|
328
|
+
// setLastId("");
|
|
329
|
+
// } else {
|
|
330
|
+
// setPageNumHistory(0);
|
|
331
|
+
// }
|
|
332
|
+
// }, 1000);
|
|
333
|
+
// // } else {
|
|
334
|
+
// // }
|
|
335
|
+
// }
|
|
336
|
+
// if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
|
|
337
|
+
// // console.log("到顶了", pageNum);
|
|
338
|
+
// setLoading(true);
|
|
339
|
+
// let number = pageNum + 1;
|
|
340
|
+
// setPageNum((pageNum) => {
|
|
341
|
+
// return pageNum + 1;
|
|
342
|
+
// });
|
|
343
|
+
// listTimer.current = setTimeout(() => {
|
|
344
|
+
// getHistoryMessage(number, 2);
|
|
345
|
+
// }, 1000);
|
|
346
|
+
// }
|
|
347
|
+
// //生成答案过程中
|
|
348
|
+
// if (!finished && scrollHeight > scrollTop) {
|
|
349
|
+
// // console.log("生成答案过程中", scrollTopHei.current, scrollTop);
|
|
350
|
+
// // setIsPosition(false);
|
|
351
|
+
// isPosition.current = false;
|
|
352
|
+
// }
|
|
353
|
+
// if (!finished && clientHeight + scrollTop >= scrollHeight) {
|
|
354
|
+
// // console.log("到顶了111", clientHeight, scrollTop, scrollHeight);
|
|
355
|
+
// isPosition.current = true;
|
|
356
|
+
// }
|
|
357
|
+
// scrollTopHei.current = scrollTop;
|
|
358
|
+
// }
|
|
359
|
+
// const content = document.getElementById(
|
|
360
|
+
// showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
|
|
361
|
+
// );
|
|
362
|
+
// if (content) {
|
|
363
|
+
// content.addEventListener("scroll", handleScroll);
|
|
364
|
+
// }
|
|
350
365
|
return ()=>{
|
|
351
|
-
const content = document.getElementById(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
366
|
+
// const content = document.getElementById(
|
|
367
|
+
// showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal"
|
|
368
|
+
// );
|
|
369
|
+
// if (content) {
|
|
370
|
+
// content.removeEventListener("scroll", handleScroll);
|
|
371
|
+
// }
|
|
372
|
+
window.removeEventListener("resize", handlerHtml2canvas);
|
|
373
|
+
window.removeEventListener("resize", cancelScreenshot);
|
|
357
374
|
};
|
|
358
375
|
}, [
|
|
359
376
|
historyMessageList,
|
|
@@ -361,18 +378,41 @@ const CustomerService = (props)=>{
|
|
|
361
378
|
pageCount,
|
|
362
379
|
showScreenshot
|
|
363
380
|
]);
|
|
381
|
+
useEffect(()=>{
|
|
382
|
+
historyMessageListRef.current = historyMessageList;
|
|
383
|
+
}, [
|
|
384
|
+
historyMessageList
|
|
385
|
+
]);
|
|
386
|
+
useEffect(()=>{
|
|
387
|
+
lastIdRef.current = lastId;
|
|
388
|
+
}, [
|
|
389
|
+
lastId
|
|
390
|
+
]);
|
|
391
|
+
useEffect(()=>{
|
|
392
|
+
console.log('isPositionState', isPositionState, isPosition.current);
|
|
393
|
+
}, [
|
|
394
|
+
isPositionState
|
|
395
|
+
]);
|
|
364
396
|
useEffect(()=>{
|
|
365
397
|
resettingBottomHei();
|
|
366
|
-
|
|
398
|
+
const timer = setTimeout(()=>{
|
|
399
|
+
scrollToBottom();
|
|
400
|
+
clearTimeout(timer);
|
|
401
|
+
}, 80);
|
|
367
402
|
let dom = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
368
403
|
if (dom) {
|
|
404
|
+
let hei = null;
|
|
369
405
|
if (showType == 1) {
|
|
370
|
-
|
|
406
|
+
hei = window.innerHeight - 60 - buttomHei;
|
|
407
|
+
dom.style.maxHeight = `${hei}px`;
|
|
371
408
|
} else if (showType == 3) {
|
|
372
|
-
|
|
409
|
+
hei = window.innerHeight - 114 - buttomHei;
|
|
410
|
+
dom.style.maxHeight = `${hei}px`;
|
|
373
411
|
} else {
|
|
374
|
-
|
|
412
|
+
hei = window.innerHeight - 160 - 62 - buttomHei;
|
|
413
|
+
dom.style.maxHeight = `${hei}px`;
|
|
375
414
|
}
|
|
415
|
+
setHistoryMessageListVirtuosoHeight(hei);
|
|
376
416
|
}
|
|
377
417
|
}, [
|
|
378
418
|
buttomHei,
|
|
@@ -419,7 +459,7 @@ const CustomerService = (props)=>{
|
|
|
419
459
|
let chat_content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
420
460
|
if (chat_content) {
|
|
421
461
|
chat_content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
422
|
-
delegate(chat_content,
|
|
462
|
+
delegate(chat_content, "click", `.${styles.copyCode}`, (event, target)=>{
|
|
423
463
|
findCopyContent(event);
|
|
424
464
|
});
|
|
425
465
|
}
|
|
@@ -456,10 +496,10 @@ const CustomerService = (props)=>{
|
|
|
456
496
|
const findCopyContent = (e)=>{
|
|
457
497
|
let source = findParent(e.target, styles.copyCode);
|
|
458
498
|
if (!source) return;
|
|
459
|
-
let id = source.getAttribute(
|
|
460
|
-
let position = source.getAttribute(
|
|
499
|
+
let id = source.getAttribute("data-id");
|
|
500
|
+
let position = source.getAttribute("data-position");
|
|
461
501
|
if (!id && !position) return;
|
|
462
|
-
let message =
|
|
502
|
+
let message = "";
|
|
463
503
|
setHistoryMessageList((list)=>{
|
|
464
504
|
var _list_filter_;
|
|
465
505
|
message = (_list_filter_ = list.filter((e)=>e.id == id)[0]) === null || _list_filter_ === void 0 ? void 0 : _list_filter_.message;
|
|
@@ -502,17 +542,17 @@ const CustomerService = (props)=>{
|
|
|
502
542
|
// watchTime= 753
|
|
503
543
|
if (videoId && courseId && sectionId) {
|
|
504
544
|
http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
|
|
505
|
-
|
|
506
|
-
|
|
545
|
+
recommendedQuestions: [],
|
|
546
|
+
contexts: [
|
|
507
547
|
{
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
548
|
+
type: "VIDEO",
|
|
549
|
+
courseId: courseId,
|
|
550
|
+
sectionId: sectionId,
|
|
551
|
+
videoId: videoId,
|
|
552
|
+
watchTime: watchTime
|
|
513
553
|
}
|
|
514
554
|
],
|
|
515
|
-
|
|
555
|
+
maximum: 3
|
|
516
556
|
}).then((res)=>{
|
|
517
557
|
try {
|
|
518
558
|
let data = res.data.questions;
|
|
@@ -534,22 +574,22 @@ const CustomerService = (props)=>{
|
|
|
534
574
|
recommendeQuestionID.current = data.map((item)=>{
|
|
535
575
|
return item.id;
|
|
536
576
|
});
|
|
537
|
-
|
|
577
|
+
// console.log(recommendeQuestionID.current, 4444444);
|
|
538
578
|
}
|
|
539
|
-
console.log(
|
|
579
|
+
// console.log("dflkvmdfklvdf欢迎语", data);
|
|
540
580
|
let obj = {
|
|
541
581
|
roomId: roomId,
|
|
542
582
|
sender: "AI",
|
|
543
583
|
recevier: mid,
|
|
544
|
-
message: `Hi
|
|
584
|
+
message: `Hi,我是智能学习助手,你遇到了什么问题?1`,
|
|
545
585
|
extraInfos: questionsList == null ? null : questionsList
|
|
546
586
|
};
|
|
547
587
|
if (pageNumHistory <= 1) {
|
|
548
|
-
console.log(
|
|
588
|
+
// console.log("欢迎语");
|
|
549
589
|
setHistoryMessageList((historyMessageList)=>{
|
|
550
|
-
let newHistoryMessageList = historyMessageList.filter((e)=>e.id !=
|
|
590
|
+
let newHistoryMessageList = historyMessageList.filter((e)=>e.id != "123456_date");
|
|
551
591
|
newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
|
|
552
|
-
id:
|
|
592
|
+
id: "123456_date",
|
|
553
593
|
upvoted: false,
|
|
554
594
|
downvoted: false,
|
|
555
595
|
quotedMessage: "",
|
|
@@ -569,11 +609,11 @@ const CustomerService = (props)=>{
|
|
|
569
609
|
roomId: roomId,
|
|
570
610
|
sender: "AI",
|
|
571
611
|
recevier: mid,
|
|
572
|
-
message: `Hi
|
|
612
|
+
message: `Hi,我是智能学习助手,你遇到了什么问题?2`
|
|
573
613
|
};
|
|
574
614
|
if (pageNumHistory <= 1) {
|
|
575
615
|
setHistoryMessageList((historyMessageList)=>{
|
|
576
|
-
let newHistoryMessageList = historyMessageList.filter((e)=>e.id !=
|
|
616
|
+
let newHistoryMessageList = historyMessageList.filter((e)=>e.id != "123456_date");
|
|
577
617
|
newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
|
|
578
618
|
id: '123456_date',
|
|
579
619
|
upvoted: false,
|
|
@@ -602,6 +642,7 @@ const CustomerService = (props)=>{
|
|
|
602
642
|
maxPageSize: 5
|
|
603
643
|
}
|
|
604
644
|
}).then((res)=>{
|
|
645
|
+
finishedRef.current = true;
|
|
605
646
|
setFinished(true);
|
|
606
647
|
if (res.data.total > 0) {
|
|
607
648
|
let questionsList = res.data.questions.map((item)=>{
|
|
@@ -622,7 +663,7 @@ const CustomerService = (props)=>{
|
|
|
622
663
|
if (pageNumHistory <= 1) {
|
|
623
664
|
setHistoryMessageList((historyMessageList)=>{
|
|
624
665
|
let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
625
|
-
id:
|
|
666
|
+
id: "p" + new Date().getTime(),
|
|
626
667
|
upvoted: false,
|
|
627
668
|
downvoted: false,
|
|
628
669
|
quotedMessage: "",
|
|
@@ -809,8 +850,8 @@ const CustomerService = (props)=>{
|
|
|
809
850
|
});
|
|
810
851
|
};
|
|
811
852
|
//发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息,flag == 3 是针对视频页面点击底部推荐问题
|
|
812
|
-
const sendMessage = async (item, flag, type =
|
|
813
|
-
console.log(item, flag, 888888888);
|
|
853
|
+
const sendMessage = async (item, flag, type = "")=>{
|
|
854
|
+
// console.log(item, flag, 888888888);
|
|
814
855
|
let questions = [];
|
|
815
856
|
if (item && flag) {
|
|
816
857
|
questions = [
|
|
@@ -847,11 +888,12 @@ const CustomerService = (props)=>{
|
|
|
847
888
|
return newHistoryMessageList;
|
|
848
889
|
});
|
|
849
890
|
}
|
|
891
|
+
finishedRef.current = false;
|
|
850
892
|
setFinished(false);
|
|
851
893
|
aiSendQuestions(3, sendData, 1);
|
|
852
894
|
return;
|
|
853
895
|
}
|
|
854
|
-
console.log(questions,
|
|
896
|
+
// console.log(questions, "知识库内容11111");
|
|
855
897
|
//向知识库发送问题 type 1,发送问题 2 发送答案 obj 需要的参数
|
|
856
898
|
let obj = {
|
|
857
899
|
roomId: roomId,
|
|
@@ -875,7 +917,7 @@ const CustomerService = (props)=>{
|
|
|
875
917
|
setQuestionsList([]);
|
|
876
918
|
setCitationContent({});
|
|
877
919
|
} else if (userData.modules.some((item)=>item.short == "AIservice")) {
|
|
878
|
-
console.log(
|
|
920
|
+
// console.log("citationContent", citationContent);
|
|
879
921
|
let sendData = {
|
|
880
922
|
//相关数据
|
|
881
923
|
roomId: roomId,
|
|
@@ -884,16 +926,16 @@ const CustomerService = (props)=>{
|
|
|
884
926
|
regenerate: citationContent.content != "" ? false : true,
|
|
885
927
|
generateUpvoteOrDownvoteMessage: false
|
|
886
928
|
};
|
|
887
|
-
let imageUrl =
|
|
929
|
+
let imageUrl = "";
|
|
888
930
|
if (citationContent.imageUrl) {
|
|
889
931
|
let base64 = await urlToBase64(citationContent.imageUrl);
|
|
890
|
-
console.log(
|
|
891
|
-
console.log(
|
|
932
|
+
// console.log("base64", base64);
|
|
933
|
+
// console.log("citationContent.imageUrl", citationContent.imageUrl);
|
|
892
934
|
sendData.image = base64;
|
|
893
935
|
imageUrl = base64;
|
|
894
936
|
}
|
|
895
937
|
if (screenshotBese64) {
|
|
896
|
-
console.log(
|
|
938
|
+
// console.log("screenshotBese64", screenshotBese64);
|
|
897
939
|
sendData.image = screenshotBese64;
|
|
898
940
|
imageUrl = screenshotBese64;
|
|
899
941
|
}
|
|
@@ -919,9 +961,10 @@ const CustomerService = (props)=>{
|
|
|
919
961
|
return newHistoryMessageList;
|
|
920
962
|
});
|
|
921
963
|
}
|
|
964
|
+
finishedRef.current = false;
|
|
922
965
|
setFinished(false);
|
|
923
966
|
aiSendQuestions(3, sendData, 1);
|
|
924
|
-
setScreenshotBese64(
|
|
967
|
+
setScreenshotBese64("");
|
|
925
968
|
//存在AI客服
|
|
926
969
|
} else {
|
|
927
970
|
//不存在AI客服
|
|
@@ -943,7 +986,7 @@ const CustomerService = (props)=>{
|
|
|
943
986
|
});
|
|
944
987
|
scrollToBottom();
|
|
945
988
|
}
|
|
946
|
-
console.log(type,
|
|
989
|
+
// console.log(type, "接受答案77777");
|
|
947
990
|
http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
|
|
948
991
|
if (res.data.id) {
|
|
949
992
|
if (pageNumHistory <= 1) {
|
|
@@ -979,7 +1022,7 @@ const CustomerService = (props)=>{
|
|
|
979
1022
|
sendingExistingIssues(2, dataObj, "", problemType);
|
|
980
1023
|
testLabQuestion(obj.message, questions.answer, "");
|
|
981
1024
|
}
|
|
982
|
-
if (type == 2 && config && config.type ==
|
|
1025
|
+
if (type == 2 && config && config.type == "video" && problemType != "AssociativeProblem") {
|
|
983
1026
|
//先请求问题列表
|
|
984
1027
|
videoPageQuestiionsList(2);
|
|
985
1028
|
}
|
|
@@ -995,6 +1038,7 @@ const CustomerService = (props)=>{
|
|
|
995
1038
|
setHistoryMessageList((historyMessageList)=>{
|
|
996
1039
|
return historyMessageList.filter((item)=>item.id != "123456");
|
|
997
1040
|
});
|
|
1041
|
+
finishedRef.current = true;
|
|
998
1042
|
setFinished(true);
|
|
999
1043
|
ctrl.current.abort();
|
|
1000
1044
|
setHistoryMessageList((historyMessageList)=>{
|
|
@@ -1009,8 +1053,12 @@ const CustomerService = (props)=>{
|
|
|
1009
1053
|
});
|
|
1010
1054
|
});
|
|
1011
1055
|
}, 60 * 1000);
|
|
1056
|
+
finishedRef.current = false;
|
|
1012
1057
|
setFinished(false);
|
|
1013
|
-
|
|
1058
|
+
isPosition.current = true;
|
|
1059
|
+
setIsPositionState(true);
|
|
1060
|
+
msgStreamingCountRef.current = 0;
|
|
1061
|
+
if (config && config.type == "video" && config.params) {
|
|
1014
1062
|
let params = config.params;
|
|
1015
1063
|
let videoId = params.videoId;
|
|
1016
1064
|
let watchTime = params.videoProgress;
|
|
@@ -1089,7 +1137,8 @@ const CustomerService = (props)=>{
|
|
|
1089
1137
|
console.info("eventSource open: ", res);
|
|
1090
1138
|
clearTimeout(receiveMessageTimer.current);
|
|
1091
1139
|
if (res.status >= 300) {
|
|
1092
|
-
console.log("sdckjsdncskdcjsdc", res.status);
|
|
1140
|
+
// console.log("sdckjsdncskdcjsdc", res.status);
|
|
1141
|
+
finishedRef.current = true;
|
|
1093
1142
|
setFinished(true);
|
|
1094
1143
|
setHistoryMessageList((historyMessageList)=>{
|
|
1095
1144
|
return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
|
|
@@ -1097,12 +1146,13 @@ const CustomerService = (props)=>{
|
|
|
1097
1146
|
ctrl.current.abort();
|
|
1098
1147
|
}
|
|
1099
1148
|
if (res.status == 200) {
|
|
1149
|
+
finishedRef.current = true;
|
|
1100
1150
|
setFinished(false);
|
|
1101
1151
|
}
|
|
1102
1152
|
if (res.status == 401) {
|
|
1103
1153
|
//身份认证未通过,从新请求新的token后再次发送请求
|
|
1104
1154
|
verifyJWT(urllocation).then(()=>{
|
|
1105
|
-
console.log("重新请求");
|
|
1155
|
+
// console.log("重新请求");
|
|
1106
1156
|
setHistoryMessageList((historyMessageList)=>{
|
|
1107
1157
|
return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
|
|
1108
1158
|
});
|
|
@@ -1111,7 +1161,7 @@ const CustomerService = (props)=>{
|
|
|
1111
1161
|
}
|
|
1112
1162
|
if (res.status == 403) {
|
|
1113
1163
|
//暂无权限
|
|
1114
|
-
console.log("暂无权限");
|
|
1164
|
+
// console.log("暂无权限");
|
|
1115
1165
|
setHistoryMessageList((historyMessageList)=>{
|
|
1116
1166
|
return historyMessageList.concat({
|
|
1117
1167
|
roomId: roomId,
|
|
@@ -1147,7 +1197,7 @@ const CustomerService = (props)=>{
|
|
|
1147
1197
|
}
|
|
1148
1198
|
},
|
|
1149
1199
|
onerror (err) {
|
|
1150
|
-
console.log(err, "dflkvdmfvlkdfv");
|
|
1200
|
+
// console.log(err, "dflkvdmfvlkdfv");
|
|
1151
1201
|
let state = err.response;
|
|
1152
1202
|
setHistoryMessageList((historyMessageList)=>{
|
|
1153
1203
|
return historyMessageList.concat({
|
|
@@ -1166,39 +1216,26 @@ const CustomerService = (props)=>{
|
|
|
1166
1216
|
// console.log("eventSource msg: ", event.data);
|
|
1167
1217
|
let msg = JSON.parse(event.data);
|
|
1168
1218
|
if (msg.message) {}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
console.log('返回中', msg);
|
|
1219
|
+
finishedRef.current = false;
|
|
1220
|
+
setFinished(false);
|
|
1221
|
+
msgStreamingCountRef.current = msgStreamingCountRef.current + 1;
|
|
1222
|
+
console.log("返回中", msg);
|
|
1174
1223
|
content = content + msg.message;
|
|
1175
|
-
// isPosition.current = true;
|
|
1176
|
-
clearTimeout(renderAiAnswerTimer.current);
|
|
1177
1224
|
renderAiAnswerTimer.current = setTimeout(()=>{
|
|
1178
1225
|
if (!finishedRef.current) {
|
|
1179
1226
|
renderAiAnswer(msg, id, type);
|
|
1180
1227
|
}
|
|
1181
|
-
},
|
|
1228
|
+
}, 1 * msgStreamingCountRef.current);
|
|
1182
1229
|
if (msg.finished) {
|
|
1183
1230
|
// console.log('返回完成',msg)
|
|
1184
|
-
// setFinished(true); //发送结束
|
|
1185
1231
|
if (!flagKeyWord) {
|
|
1186
1232
|
videoPageQuestiionsList(2);
|
|
1187
1233
|
}
|
|
1188
|
-
// isPosition.current = true;
|
|
1189
|
-
// setTimeout(()=>{
|
|
1190
|
-
// isPosition.current = true;
|
|
1191
|
-
// },100)
|
|
1192
1234
|
testLabQuestion(JSON.parse(data).message, content, "");
|
|
1193
1235
|
} else {}
|
|
1194
1236
|
},
|
|
1195
1237
|
onclose () {
|
|
1196
1238
|
console.log("eventSource close");
|
|
1197
|
-
// setFinished(true); //发送结束
|
|
1198
|
-
// // isPosition.current = true;
|
|
1199
|
-
// setTimeout(()=>{
|
|
1200
|
-
// isPosition.current = true;
|
|
1201
|
-
// },100)
|
|
1202
1239
|
setHistoryMessageList((historyMessageList)=>{
|
|
1203
1240
|
return historyMessageList.filter((item)=>item.id != "123456");
|
|
1204
1241
|
});
|
|
@@ -1228,7 +1265,6 @@ const CustomerService = (props)=>{
|
|
|
1228
1265
|
let list = prevHistoryMessageList.filter((item)=>{
|
|
1229
1266
|
return item.id == id;
|
|
1230
1267
|
});
|
|
1231
|
-
// console.log('renderAiAnswer',{list1,list})
|
|
1232
1268
|
let message = "";
|
|
1233
1269
|
if (list.length == 0) {
|
|
1234
1270
|
message = obj.message;
|
|
@@ -1277,26 +1313,14 @@ const CustomerService = (props)=>{
|
|
|
1277
1313
|
return newHistoryMessageList2;
|
|
1278
1314
|
}
|
|
1279
1315
|
});
|
|
1280
|
-
console.log(
|
|
1281
|
-
|
|
1282
|
-
const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
1283
|
-
if (container) {
|
|
1284
|
-
container.scrollTop = container.scrollHeight;
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1316
|
+
console.log("isPosition", isPosition.current);
|
|
1317
|
+
scrollToBottom();
|
|
1287
1318
|
if (msg.finished) {
|
|
1288
|
-
console.log('返回完成', msg);
|
|
1319
|
+
console.log('返回完成', msg, msgStreamingCountRef.current);
|
|
1289
1320
|
//发送结束
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
return finishedRef.current;
|
|
1293
|
-
});
|
|
1321
|
+
finishedRef.current = true;
|
|
1322
|
+
setFinished(true);
|
|
1294
1323
|
}
|
|
1295
|
-
// console.log('historyMessageList',historyMessageList)
|
|
1296
|
-
// if(isPosition.current){
|
|
1297
|
-
// console.log('mmmmmmmmmmmmm打印一下',)
|
|
1298
|
-
// scrollToBottom();
|
|
1299
|
-
// }
|
|
1300
1324
|
};
|
|
1301
1325
|
//问题记录到实验报告中
|
|
1302
1326
|
const testLabQuestion = (title, content, teachId)=>{
|
|
@@ -1309,7 +1333,7 @@ const CustomerService = (props)=>{
|
|
|
1309
1333
|
stepId: stepId,
|
|
1310
1334
|
stepIds: stepIds
|
|
1311
1335
|
}).then(()=>{
|
|
1312
|
-
console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
|
|
1336
|
+
// console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
|
|
1313
1337
|
setChatObj((list1)=>{
|
|
1314
1338
|
let list = list1.filter((e)=>e.roomId != roomId);
|
|
1315
1339
|
return list;
|
|
@@ -1346,7 +1370,7 @@ const CustomerService = (props)=>{
|
|
|
1346
1370
|
params: {
|
|
1347
1371
|
roomId: rid,
|
|
1348
1372
|
page: page,
|
|
1349
|
-
maxPageSize:
|
|
1373
|
+
maxPageSize: 30,
|
|
1350
1374
|
direction: "desc"
|
|
1351
1375
|
}
|
|
1352
1376
|
}).then((res)=>{
|
|
@@ -1355,7 +1379,7 @@ const CustomerService = (props)=>{
|
|
|
1355
1379
|
if (res.data.messages.length > 0) {
|
|
1356
1380
|
clearTimeout(listTimer.current);
|
|
1357
1381
|
let total = res.data.total;
|
|
1358
|
-
let maxPageSize =
|
|
1382
|
+
let maxPageSize = 30;
|
|
1359
1383
|
let dataList = res.data.messages.reverse();
|
|
1360
1384
|
//历史记录点击进来的,多加载一页,防止定位不准
|
|
1361
1385
|
if (flag == 1 && page > 1) {
|
|
@@ -1365,6 +1389,7 @@ const CustomerService = (props)=>{
|
|
|
1365
1389
|
return;
|
|
1366
1390
|
}
|
|
1367
1391
|
setPageCount(Math.ceil(total / maxPageSize));
|
|
1392
|
+
setFirstItemIndex(total - maxPageSize * (page - 1));
|
|
1368
1393
|
let newHistoryMessageList = [];
|
|
1369
1394
|
setHistoryMessageList((historyMessageList)=>{
|
|
1370
1395
|
//获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
|
|
@@ -1408,7 +1433,7 @@ const CustomerService = (props)=>{
|
|
|
1408
1433
|
scrollToBottom();
|
|
1409
1434
|
}, 1000);
|
|
1410
1435
|
} else {
|
|
1411
|
-
scrollTo(
|
|
1436
|
+
scrollTo(lastIdRef.current);
|
|
1412
1437
|
}
|
|
1413
1438
|
}
|
|
1414
1439
|
setBottomLoading(false);
|
|
@@ -1457,7 +1482,7 @@ const CustomerService = (props)=>{
|
|
|
1457
1482
|
params: {
|
|
1458
1483
|
roomId: rid,
|
|
1459
1484
|
page: 1,
|
|
1460
|
-
maxPageSize: totalNumber == 0 ?
|
|
1485
|
+
maxPageSize: totalNumber == 0 ? 30 : totalNumber,
|
|
1461
1486
|
direction: "desc"
|
|
1462
1487
|
}
|
|
1463
1488
|
}).then((res)=>{
|
|
@@ -1476,7 +1501,7 @@ const CustomerService = (props)=>{
|
|
|
1476
1501
|
return newHistoryMessageList;
|
|
1477
1502
|
});
|
|
1478
1503
|
// console.log(dataList.length , originList,lastId,'dfkvdnfkvdfj44444');
|
|
1479
|
-
if (!
|
|
1504
|
+
if (!lastIdRef.current && originList != newList) {
|
|
1480
1505
|
scrollToBottom();
|
|
1481
1506
|
readMessage(roomId, urllocation, userData, http);
|
|
1482
1507
|
}
|
|
@@ -1505,7 +1530,7 @@ const CustomerService = (props)=>{
|
|
|
1505
1530
|
if (room.length > 0) {
|
|
1506
1531
|
// console.log(room,'dfvdfvdfvdfv')
|
|
1507
1532
|
let chatID = room[0].id;
|
|
1508
|
-
console.log(chatID, "chatIDchatIDchatID");
|
|
1533
|
+
// console.log(chatID, "chatIDchatIDchatID");
|
|
1509
1534
|
let index = -1;
|
|
1510
1535
|
newHistoryMessageList.forEach((item, i)=>{
|
|
1511
1536
|
// console.log(item,item.id,'lskdcmsldksdcsdc')
|
|
@@ -1517,7 +1542,7 @@ const CustomerService = (props)=>{
|
|
|
1517
1542
|
//有新的消息
|
|
1518
1543
|
if (index != -1) {
|
|
1519
1544
|
let newMessage = newHistoryMessageList.slice(index);
|
|
1520
|
-
console.log(newMessage, "newMessagenewMessage");
|
|
1545
|
+
// console.log(newMessage, "newMessagenewMessage");
|
|
1521
1546
|
let result = [];
|
|
1522
1547
|
newMessage.forEach((item, index)=>{
|
|
1523
1548
|
let isQuestion = item.receiver !== mid; //是否为问题
|
|
@@ -1533,7 +1558,7 @@ const CustomerService = (props)=>{
|
|
|
1533
1558
|
}
|
|
1534
1559
|
}
|
|
1535
1560
|
});
|
|
1536
|
-
console.log(result, "存储的消息");
|
|
1561
|
+
// console.log(result, "存储的消息");
|
|
1537
1562
|
result.map((item)=>{
|
|
1538
1563
|
testLabQuestion(item.question, item.answer, String(item.id));
|
|
1539
1564
|
});
|
|
@@ -1636,7 +1661,7 @@ const CustomerService = (props)=>{
|
|
|
1636
1661
|
setQuestionsList(questionList);
|
|
1637
1662
|
}
|
|
1638
1663
|
if (questionList.length < 4 && flag == 3) {
|
|
1639
|
-
console.log(
|
|
1664
|
+
// console.log("视频页面,联想问题小于4个");
|
|
1640
1665
|
//视频页面,联想问题小于4个
|
|
1641
1666
|
http.get(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions`, {
|
|
1642
1667
|
params: {
|
|
@@ -1663,31 +1688,34 @@ const CustomerService = (props)=>{
|
|
|
1663
1688
|
};
|
|
1664
1689
|
//获取视频页面热门问题 flag == 1,默认推荐问题 == 2,底部渲染问题,flag == 3,ai回答后请求相关问题
|
|
1665
1690
|
const videoPageQuestiionsList = (flag = 1)=>{
|
|
1666
|
-
console.log(flag, props, 3333333);
|
|
1667
|
-
if (config && config.type ==
|
|
1691
|
+
// console.log(flag, props, 3333333);
|
|
1692
|
+
if (config && config.type == "video" && config.params) {
|
|
1668
1693
|
let params = config.params;
|
|
1669
1694
|
let videoId = params.videoId;
|
|
1670
1695
|
let watchTime = params.videoProgress;
|
|
1671
|
-
let courseId = getQuery(
|
|
1696
|
+
let courseId = getQuery("yc_id");
|
|
1672
1697
|
let sectionId = params.VideoBriefSummaryId;
|
|
1673
1698
|
// let courseId="31007",
|
|
1674
1699
|
// sectionId= "446168",
|
|
1675
1700
|
// videoId= "71399",
|
|
1676
1701
|
// watchTime= 527
|
|
1677
1702
|
if (videoId && courseId && sectionId) {
|
|
1678
|
-
console.log(
|
|
1703
|
+
// console.log(
|
|
1704
|
+
// recommendeQuestionID.current,
|
|
1705
|
+
// "recommendeQuestionID.current"
|
|
1706
|
+
// );
|
|
1679
1707
|
http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
|
|
1680
|
-
|
|
1681
|
-
|
|
1708
|
+
recommendedQuestions: recommendeQuestionID.current,
|
|
1709
|
+
contexts: [
|
|
1682
1710
|
{
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1711
|
+
type: "VIDEO",
|
|
1712
|
+
courseId: courseId,
|
|
1713
|
+
sectionId: sectionId,
|
|
1714
|
+
videoId: videoId,
|
|
1715
|
+
watchTime: watchTime
|
|
1688
1716
|
}
|
|
1689
1717
|
],
|
|
1690
|
-
|
|
1718
|
+
maximum: flag == 1 || flag == 2 ? 3 : 5
|
|
1691
1719
|
}).then((res)=>{
|
|
1692
1720
|
if (res.data.total > 0) {
|
|
1693
1721
|
let data = res.data.questions;
|
|
@@ -1793,32 +1821,31 @@ const CustomerService = (props)=>{
|
|
|
1793
1821
|
};
|
|
1794
1822
|
//设置滚动条滚动到底部
|
|
1795
1823
|
const scrollToBottom = ()=>{
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1824
|
+
if (!historyMessageListVirtuosoRef.current || !isPosition.current) {
|
|
1825
|
+
return;
|
|
1826
|
+
} else {
|
|
1827
|
+
historyMessageListVirtuosoRef.current.scrollToIndex({
|
|
1828
|
+
index: "LAST",
|
|
1829
|
+
align: "end",
|
|
1830
|
+
behavior: "auto"
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1805
1833
|
};
|
|
1806
1834
|
//滚动到指定位置
|
|
1807
1835
|
const scrollTo = (id)=>{
|
|
1808
|
-
const
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
}, 100);
|
|
1819
|
-
} catch (error) {}
|
|
1836
|
+
const timer = setTimeout(()=>{
|
|
1837
|
+
const index = historyMessageListRef.current.findIndex((x)=>x.id === id);
|
|
1838
|
+
// console.log("scrollTo", id, index, historyMessageListRef.current);
|
|
1839
|
+
if (index > -1) {
|
|
1840
|
+
historyMessageListVirtuosoRef.current.scrollToIndex({
|
|
1841
|
+
index,
|
|
1842
|
+
align: "start",
|
|
1843
|
+
behavior: "auto"
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1820
1846
|
setLoading(false);
|
|
1821
|
-
|
|
1847
|
+
clearTimeout(timer);
|
|
1848
|
+
}, 10);
|
|
1822
1849
|
};
|
|
1823
1850
|
//重置底部输入框高度
|
|
1824
1851
|
const resettingBottomHei = ()=>{
|
|
@@ -2038,6 +2065,7 @@ const CustomerService = (props)=>{
|
|
|
2038
2065
|
if (ctrl && ctrl.current) {
|
|
2039
2066
|
ctrl.current.abort();
|
|
2040
2067
|
}
|
|
2068
|
+
finishedRef.current = true;
|
|
2041
2069
|
setFinished(true);
|
|
2042
2070
|
} catch (error) {}
|
|
2043
2071
|
setTimeout(()=>{
|
|
@@ -2064,60 +2092,59 @@ const CustomerService = (props)=>{
|
|
|
2064
2092
|
};
|
|
2065
2093
|
//渲染问答
|
|
2066
2094
|
const renderQuestion = ()=>{
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
if (
|
|
2079
|
-
|
|
2080
|
-
|
|
2095
|
+
function itemContent(index, item) {
|
|
2096
|
+
var _historyMessageList_findIndex;
|
|
2097
|
+
const i = (_historyMessageList_findIndex = historyMessageList.findIndex((x)=>x.id == item.id)) !== null && _historyMessageList_findIndex !== void 0 ? _historyMessageList_findIndex : index;
|
|
2098
|
+
let timeObj = parseDate(item.createdAt);
|
|
2099
|
+
// console.log(item.message);
|
|
2100
|
+
let message = item.message;
|
|
2101
|
+
let li;
|
|
2102
|
+
// 是否需要显示日期
|
|
2103
|
+
let itemIndex = historyMessageList.findIndex((ite)=>ite.id === item.id);
|
|
2104
|
+
let time = "";
|
|
2105
|
+
if (historyMessageList.length > 1) {
|
|
2106
|
+
if (itemIndex <= 0) {
|
|
2107
|
+
//第一项
|
|
2108
|
+
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
2109
|
+
} else {
|
|
2110
|
+
//非第一项 与上一项进行对比
|
|
2111
|
+
let beforeTime = historyMessageList[itemIndex - 1].createdAt;
|
|
2112
|
+
//判断与上一条数据 是否跨天
|
|
2113
|
+
let beforeTimeObj = parseDate(beforeTime);
|
|
2114
|
+
let beforeTimeStr = `${beforeTimeObj.year}-${beforeTimeObj.month}-${beforeTimeObj.day}`;
|
|
2115
|
+
let curTimeStr = `${timeObj.year}-${timeObj.month}-${timeObj.day}`;
|
|
2116
|
+
if (beforeTimeStr !== curTimeStr) {
|
|
2081
2117
|
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
2082
2118
|
} else {
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
let beforeTimeObj = parseDate(beforeTime);
|
|
2087
|
-
let beforeTimeStr = `${beforeTimeObj.year}-${beforeTimeObj.month}-${beforeTimeObj.day}`;
|
|
2088
|
-
let curTimeStr = `${timeObj.year}-${timeObj.month}-${timeObj.day}`;
|
|
2089
|
-
if (beforeTimeStr !== curTimeStr) {
|
|
2090
|
-
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
2091
|
-
} else {
|
|
2092
|
-
//没有跨天 判断是否相隔超过10分钟
|
|
2093
|
-
if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
2094
|
-
time = `${timeObj.hours}:${timeObj.minutes}`;
|
|
2095
|
-
}
|
|
2119
|
+
//没有跨天 判断是否相隔超过10分钟
|
|
2120
|
+
if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
2121
|
+
time = `${timeObj.hours}:${timeObj.minutes}`;
|
|
2096
2122
|
}
|
|
2097
2123
|
}
|
|
2098
2124
|
}
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2125
|
+
}
|
|
2126
|
+
let dataTime = time;
|
|
2127
|
+
// let code = message.split("```");
|
|
2128
|
+
// code = code[1];
|
|
2129
|
+
// console.log(code,888888888);
|
|
2130
|
+
if (lastId == item.id && keyWordProblem != "") {
|
|
2131
|
+
//点击历史记录时,找到关键字,防止关键字和标签名重复
|
|
2132
|
+
// let key_sign = 'sign_'+new Date().getTime();+'sign';
|
|
2133
|
+
// message = message.replaceAll(keyWordProblem, (e:any) => {
|
|
2134
|
+
// return key_sign;
|
|
2135
|
+
// });
|
|
2136
|
+
// message = remarkable.render(message);
|
|
2137
|
+
// message = message.replaceAll(key_sign, (e:any) => {
|
|
2138
|
+
// return `<span class=${styles.sign}>${keyWordProblem}</span>`;
|
|
2139
|
+
// });
|
|
2140
|
+
message = remarkReplaceKey(message, keyWordProblem);
|
|
2141
|
+
} else {
|
|
2142
|
+
message = remarkable.render(message);
|
|
2143
|
+
}
|
|
2144
|
+
let position = 0;
|
|
2145
|
+
message = message.replaceAll(new RegExp(`<pre`, "ig"), (i, index)=>{
|
|
2146
|
+
position++;
|
|
2147
|
+
let text = `<p class='${styles.copyCode} copyCodeFun' data-id=${item.id} data-position=${position}>
|
|
2121
2148
|
<span class='${styles.icon} copy' >
|
|
2122
2149
|
<svg
|
|
2123
2150
|
width="1em"
|
|
@@ -2151,99 +2178,347 @@ const CustomerService = (props)=>{
|
|
|
2151
2178
|
<path d="M11.2242 0.375687C11.4586 0.610002 11.4586 0.989901 11.2242 1.22422L4.82424 7.62422C4.58992 7.85853 4.21003 7.85853 3.97571 7.62422L0.775712 4.42422C0.541397 4.1899 0.541397 3.81 0.775712 3.57569C1.01003 3.34137 1.38993 3.34137 1.62424 3.57569L4.39998 6.35142L10.3757 0.375687C10.61 0.141373 10.9899 0.141373 11.2242 0.375687Z" />
|
|
2152
2179
|
</svg>
|
|
2153
2180
|
</span><span class="copyCode">复制代码</span></p><pre`;
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2181
|
+
return text;
|
|
2182
|
+
});
|
|
2183
|
+
if (item.sender == mid) {
|
|
2184
|
+
//只有引用和复制功能
|
|
2185
|
+
li = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2186
|
+
children: [
|
|
2187
|
+
dataTime ? /*#__PURE__*/ _jsx("li", {
|
|
2188
|
+
className: `${styles.itemcontent} ${styles.time}`,
|
|
2189
|
+
children: dataTime
|
|
2190
|
+
}) : "",
|
|
2191
|
+
/*#__PURE__*/ _jsxs("li", {
|
|
2192
|
+
className: `${styles.itemcontent} ${styles.left}`,
|
|
2193
|
+
id: lastId == item.id ? "li_flag" : "",
|
|
2194
|
+
children: [
|
|
2195
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2196
|
+
className: styles.main,
|
|
2197
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
2198
|
+
className: styles.main_content,
|
|
2199
|
+
children: [
|
|
2200
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2201
|
+
className: styles.main_content_flag,
|
|
2202
|
+
children: [
|
|
2203
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2204
|
+
className: styles.operate_modal,
|
|
2205
|
+
children: /*#__PURE__*/ _jsxs("p", {
|
|
2206
|
+
className: styles.operate,
|
|
2207
|
+
children: [
|
|
2208
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2209
|
+
className: "yinyong_quote1",
|
|
2210
|
+
onClick: ()=>{
|
|
2211
|
+
setCitationContent({
|
|
2212
|
+
content: item.message,
|
|
2213
|
+
id: item.id,
|
|
2214
|
+
imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ""
|
|
2215
|
+
});
|
|
2216
|
+
resettingBottomHei();
|
|
2217
|
+
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
2218
|
+
},
|
|
2219
|
+
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
2220
|
+
}),
|
|
2221
|
+
copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
|
|
2222
|
+
className: `tongyong-xuanzhongdui`,
|
|
2223
|
+
children: /*#__PURE__*/ _jsx(CustomDuihao, {})
|
|
2224
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
2225
|
+
className: "fuzhi21",
|
|
2226
|
+
onClick: ()=>{
|
|
2227
|
+
let bol = copyText(item.message);
|
|
2228
|
+
if (bol) {
|
|
2229
|
+
let obj = copyTextOBJ;
|
|
2230
|
+
obj = obj.filter((list)=>list != item.id);
|
|
2231
|
+
obj.push(item.id);
|
|
2232
|
+
setCopyTextObj(obj);
|
|
2233
|
+
}
|
|
2234
|
+
setTimeout(()=>{
|
|
2235
|
+
let obj = copyTextOBJ;
|
|
2236
|
+
obj = obj.filter((list)=>list != item.id);
|
|
2237
|
+
setCopyTextObj(obj);
|
|
2238
|
+
}, 3000);
|
|
2239
|
+
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
2240
|
+
},
|
|
2241
|
+
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
2242
|
+
})
|
|
2243
|
+
]
|
|
2244
|
+
})
|
|
2245
|
+
}),
|
|
2246
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2247
|
+
className: styles.content,
|
|
2248
|
+
children: [
|
|
2249
|
+
/*#__PURE__*/ _jsx("p", {
|
|
2250
|
+
dangerouslySetInnerHTML: {
|
|
2251
|
+
__html: message
|
|
2252
|
+
},
|
|
2253
|
+
className: styles.content_child
|
|
2254
|
+
}),
|
|
2255
|
+
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2256
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ""}`,
|
|
2180
2257
|
children: [
|
|
2181
|
-
/*#__PURE__*/ _jsx("
|
|
2182
|
-
|
|
2183
|
-
onClick: ()=>{
|
|
2184
|
-
setCitationContent({
|
|
2185
|
-
content: item.message,
|
|
2186
|
-
id: item.id,
|
|
2187
|
-
imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ''
|
|
2188
|
-
});
|
|
2189
|
-
resettingBottomHei();
|
|
2190
|
-
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
2191
|
-
},
|
|
2192
|
-
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
2258
|
+
/*#__PURE__*/ _jsx("img", {
|
|
2259
|
+
src: JSON.parse(item.extraInfo)[0].value
|
|
2193
2260
|
}),
|
|
2194
|
-
|
|
2195
|
-
className:
|
|
2196
|
-
children: /*#__PURE__*/ _jsx(
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
let bol = copyText(item.message);
|
|
2201
|
-
if (bol) {
|
|
2202
|
-
let obj = copyTextOBJ;
|
|
2203
|
-
obj = obj.filter((list)=>list != item.id);
|
|
2204
|
-
obj.push(item.id);
|
|
2205
|
-
setCopyTextObj(obj);
|
|
2261
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2262
|
+
className: styles.mask_zoom,
|
|
2263
|
+
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2264
|
+
onClick: ()=>{
|
|
2265
|
+
setViewBase64(JSON.parse(item.extraInfo)[0].value);
|
|
2266
|
+
setVisible(true);
|
|
2206
2267
|
}
|
|
2207
|
-
|
|
2208
|
-
let obj = copyTextOBJ;
|
|
2209
|
-
obj = obj.filter((list)=>list != item.id);
|
|
2210
|
-
setCopyTextObj(obj);
|
|
2211
|
-
}, 3000);
|
|
2212
|
-
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
2213
|
-
},
|
|
2214
|
-
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
2268
|
+
})
|
|
2215
2269
|
})
|
|
2216
2270
|
]
|
|
2217
2271
|
})
|
|
2272
|
+
]
|
|
2273
|
+
})
|
|
2274
|
+
]
|
|
2275
|
+
}),
|
|
2276
|
+
//引用消息
|
|
2277
|
+
item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
|
|
2278
|
+
className: styles.citation_content,
|
|
2279
|
+
children: [
|
|
2280
|
+
getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
2281
|
+
overlayClassName: styles.popover_main_content,
|
|
2282
|
+
title: item.quotedMessage,
|
|
2283
|
+
placement: "leftTop",
|
|
2284
|
+
children: /*#__PURE__*/ _jsxs("p", {
|
|
2285
|
+
className: styles.text_exceed,
|
|
2286
|
+
children: [
|
|
2287
|
+
item.quotedMessage,
|
|
2288
|
+
/*#__PURE__*/ _jsx(RightOutlined, {})
|
|
2289
|
+
]
|
|
2290
|
+
})
|
|
2291
|
+
}) : /*#__PURE__*/ _jsx("p", {
|
|
2292
|
+
children: item.quotedMessage
|
|
2293
|
+
}),
|
|
2294
|
+
item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2295
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ""}`,
|
|
2296
|
+
children: [
|
|
2297
|
+
/*#__PURE__*/ _jsx("img", {
|
|
2298
|
+
src: JSON.parse(item.extraInfo)[0].value
|
|
2299
|
+
}),
|
|
2300
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2301
|
+
className: styles.mask_zoom,
|
|
2302
|
+
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2303
|
+
onClick: ()=>{
|
|
2304
|
+
setViewBase64(JSON.parse(item.extraInfo)[0].value);
|
|
2305
|
+
setVisible(true);
|
|
2306
|
+
}
|
|
2307
|
+
})
|
|
2308
|
+
})
|
|
2309
|
+
]
|
|
2310
|
+
})
|
|
2311
|
+
]
|
|
2312
|
+
})
|
|
2313
|
+
]
|
|
2314
|
+
})
|
|
2315
|
+
}),
|
|
2316
|
+
(showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
|
|
2317
|
+
className: styles.head_sculpture,
|
|
2318
|
+
style: {
|
|
2319
|
+
marginLeft: "12px"
|
|
2320
|
+
},
|
|
2321
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2322
|
+
src: userData.avatar
|
|
2323
|
+
})
|
|
2324
|
+
})
|
|
2325
|
+
]
|
|
2326
|
+
}, item.id)
|
|
2327
|
+
]
|
|
2328
|
+
});
|
|
2329
|
+
} else {
|
|
2330
|
+
//获取用户头像
|
|
2331
|
+
let headImg = "";
|
|
2332
|
+
let chatWindow = [];
|
|
2333
|
+
let isAiChatWindow;
|
|
2334
|
+
chatWindow = contactsList.filter((item)=>item.roomId == roomId);
|
|
2335
|
+
if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
|
|
2336
|
+
headImg = chatWindow[0].headImg;
|
|
2337
|
+
}
|
|
2338
|
+
// console.log(chatWindow,'chatWindowchatWindow')
|
|
2339
|
+
//是否在智能客服窗口
|
|
2340
|
+
isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
|
|
2341
|
+
let header = 2; //代表是ai头像
|
|
2342
|
+
if (isAiChatWindow && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
|
|
2343
|
+
//使用AI头像
|
|
2344
|
+
header = 1;
|
|
2345
|
+
}
|
|
2346
|
+
li = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2347
|
+
children: [
|
|
2348
|
+
dataTime ? /*#__PURE__*/ _jsx("li", {
|
|
2349
|
+
className: `${styles.itemcontent} ${styles.time}`,
|
|
2350
|
+
children: dataTime
|
|
2351
|
+
}) : "",
|
|
2352
|
+
/*#__PURE__*/ _jsxs("li", {
|
|
2353
|
+
className: `${styles.itemcontent} ${styles.right}`,
|
|
2354
|
+
id: lastId == item.id ? "li_flag" : item.id,
|
|
2355
|
+
children: [
|
|
2356
|
+
(showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
|
|
2357
|
+
className: styles.head_sculpture,
|
|
2358
|
+
style: {
|
|
2359
|
+
marginRight: "12px"
|
|
2360
|
+
},
|
|
2361
|
+
children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
|
|
2362
|
+
src: knowledge_icon
|
|
2363
|
+
}) : /*#__PURE__*/ _jsx("img", {
|
|
2364
|
+
src: headImg
|
|
2365
|
+
})
|
|
2366
|
+
}),
|
|
2367
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2368
|
+
className: styles.main,
|
|
2369
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
2370
|
+
className: styles.main_content,
|
|
2371
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
2372
|
+
className: styles.main_content_flag,
|
|
2373
|
+
onMouseEnter: ()=>{
|
|
2374
|
+
// onMouseEnter方法内:判断回答内容的气泡是否在可视区域内,动态判断点赞按钮显示的上下位置
|
|
2375
|
+
const isSmall = showType == 1 || showType == 3;
|
|
2376
|
+
const container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
|
|
2377
|
+
console.log('onMouseEnter1', container);
|
|
2378
|
+
if (container) {
|
|
2379
|
+
const dom = container.querySelector(`[id="${item.id}"]`);
|
|
2380
|
+
console.log('onMouseEnter2', dom);
|
|
2381
|
+
if (dom) {
|
|
2382
|
+
// const con_h=document.getElementById('chat_content').clientHeight-24;//滚动区域的高度
|
|
2383
|
+
const con_h = container.clientHeight - (isSmall ? 24 : 0); //滚动区域的高度;
|
|
2384
|
+
const rectY = dom.getBoundingClientRect().y - 48;
|
|
2385
|
+
const h = dom.clientHeight + (isSmall ? 24 : 0); //当前元素高度
|
|
2386
|
+
const topDom = dom.getElementsByClassName(styles.operate_modal_showtop)[0];
|
|
2387
|
+
const bottomDom = dom.getElementsByClassName(styles.operate_modal_showbottom)[0];
|
|
2388
|
+
console.log('onMouseEnter3', topDom, bottomDom);
|
|
2389
|
+
console.log('onMouseEnter4', {
|
|
2390
|
+
h,
|
|
2391
|
+
con_h,
|
|
2392
|
+
rectY,
|
|
2393
|
+
topDom,
|
|
2394
|
+
bottomDom
|
|
2395
|
+
});
|
|
2396
|
+
if (topDom && bottomDom) {
|
|
2397
|
+
if (rectY > 0) {
|
|
2398
|
+
//显示上边
|
|
2399
|
+
topDom.style.cssText = "visibility: visible";
|
|
2400
|
+
bottomDom.style.cssText = "visibility: hidden;";
|
|
2401
|
+
// 上下都能显示时,显示到下边
|
|
2402
|
+
if (h < con_h - rectY) {
|
|
2403
|
+
console.log("上下都能显示时,显示到下边");
|
|
2404
|
+
topDom.style.cssText = "visibility: hidden;";
|
|
2405
|
+
bottomDom.style.cssText = "visibility: visible";
|
|
2406
|
+
}
|
|
2407
|
+
} else {
|
|
2408
|
+
// 上下都不显示,下边的放到页的最上边
|
|
2409
|
+
if (h > con_h && h - con_h > Math.abs(rectY)) {
|
|
2410
|
+
console.log("上下都不显示");
|
|
2411
|
+
topDom.style.cssText = "visibility: hidden;";
|
|
2412
|
+
bottomDom.style.cssText = `top:${-(h + rectY - 51 - (isSmall ? 0 : 58))}px;visibility: visible;`;
|
|
2413
|
+
} else {
|
|
2414
|
+
console.log("12312312");
|
|
2415
|
+
//显示下边
|
|
2416
|
+
topDom.style.cssText = "visibility: hidden;";
|
|
2417
|
+
bottomDom.style.cssText = "visibility: visible";
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
},
|
|
2424
|
+
onMouseLeave: ()=>{
|
|
2425
|
+
const isSmall = showType == 1 || showType == 3;
|
|
2426
|
+
const container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
|
|
2427
|
+
if (container) {
|
|
2428
|
+
const dom = container.querySelector(`[id="${item.id}"]`);
|
|
2429
|
+
if (dom) {
|
|
2430
|
+
const topDom = dom.getElementsByClassName(styles.operate_modal_showtop)[0];
|
|
2431
|
+
const bottomDom = dom.getElementsByClassName(styles.operate_modal_showbottom)[0];
|
|
2432
|
+
if (topDom) {
|
|
2433
|
+
topDom.style.cssText = "visibility: hidden;";
|
|
2434
|
+
}
|
|
2435
|
+
if (bottomDom) {
|
|
2436
|
+
bottomDom.style.cssText = "visibility: hidden;";
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
},
|
|
2441
|
+
children: [
|
|
2442
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2443
|
+
className: `${styles.operate_modal} ${styles.operate_modal_showtop}`,
|
|
2444
|
+
children: // 不是最后一行,
|
|
2445
|
+
historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
|
|
2446
|
+
}),
|
|
2447
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2448
|
+
className: styles.content,
|
|
2449
|
+
children: [
|
|
2450
|
+
item.message != "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsx("p", {
|
|
2451
|
+
dangerouslySetInnerHTML: {
|
|
2452
|
+
__html: message
|
|
2453
|
+
},
|
|
2454
|
+
className: styles.content_child
|
|
2218
2455
|
}),
|
|
2219
|
-
/*#__PURE__*/ _jsxs("
|
|
2220
|
-
className: styles.content,
|
|
2456
|
+
item.message == "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsxs("p", {
|
|
2221
2457
|
children: [
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2458
|
+
"AI助手繁忙,请稍后再提问或",
|
|
2459
|
+
/*#__PURE__*/ _jsx("span", {
|
|
2460
|
+
className: styles.find_teacher_con,
|
|
2461
|
+
onClick: ()=>{
|
|
2462
|
+
let extraInfo = historyMessageList[i - 1].extraInfo;
|
|
2463
|
+
let url = "";
|
|
2464
|
+
if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
|
|
2465
|
+
url = JSON.parse(extraInfo)[0].value;
|
|
2466
|
+
}
|
|
2467
|
+
setProblem({
|
|
2468
|
+
question: historyMessageList[i - 1].message,
|
|
2469
|
+
url
|
|
2470
|
+
});
|
|
2471
|
+
setShowTeacherList(true);
|
|
2225
2472
|
},
|
|
2226
|
-
|
|
2473
|
+
children: "召唤老师回答"
|
|
2474
|
+
})
|
|
2475
|
+
]
|
|
2476
|
+
}),
|
|
2477
|
+
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2478
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ""}`,
|
|
2479
|
+
children: [
|
|
2480
|
+
/*#__PURE__*/ _jsx("img", {
|
|
2481
|
+
src: JSON.parse(item.extraInfo)[0].value
|
|
2482
|
+
}),
|
|
2483
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2484
|
+
className: styles.mask_zoom,
|
|
2485
|
+
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2486
|
+
onClick: ()=>{
|
|
2487
|
+
setViewBase64(JSON.parse(item.extraInfo)[0].value);
|
|
2488
|
+
setVisible(true);
|
|
2489
|
+
}
|
|
2490
|
+
})
|
|
2491
|
+
})
|
|
2492
|
+
]
|
|
2493
|
+
}),
|
|
2494
|
+
item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsxs("ul", {
|
|
2495
|
+
className: `${styles.association_problem} ${item.message == "抱歉,我暂时无法回答这样的问题。" ? styles.association_problem_flag : ""}`,
|
|
2496
|
+
children: [
|
|
2497
|
+
item.message == "抱歉,我暂时无法回答这样的问题。" && /*#__PURE__*/ _jsx("li", {
|
|
2498
|
+
className: styles.related_issues_flag,
|
|
2499
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
2500
|
+
children: "相关问题"
|
|
2501
|
+
})
|
|
2227
2502
|
}),
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
children:
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
}
|
|
2241
|
-
})
|
|
2503
|
+
JSON.parse(item.extraInfo).map((list, index)=>{
|
|
2504
|
+
return /*#__PURE__*/ _jsx("li", {
|
|
2505
|
+
onClick: ()=>{
|
|
2506
|
+
sendMessage(list, 1);
|
|
2507
|
+
setBottomRecommendationQuestions([]);
|
|
2508
|
+
resettingBottomHei();
|
|
2509
|
+
},
|
|
2510
|
+
children: item.message == "抱歉,我暂时无法回答这样的问题。" ? list.question : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2511
|
+
children: [
|
|
2512
|
+
JSON.parse(item.extraInfo).length > 1 ? index + 1 + "." : "",
|
|
2513
|
+
list.question
|
|
2514
|
+
]
|
|
2242
2515
|
})
|
|
2243
|
-
|
|
2516
|
+
}, i + "_" + index + "_" + list.value);
|
|
2244
2517
|
})
|
|
2245
2518
|
]
|
|
2246
|
-
})
|
|
2519
|
+
}),
|
|
2520
|
+
//findTeacher//是否在召唤老师过程中,是否是最后一条消息
|
|
2521
|
+
!item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != "123456_date" && renderLastOperateBtn(item, isAiChatWindow, i)
|
|
2247
2522
|
]
|
|
2248
2523
|
}),
|
|
2249
2524
|
//引用消息
|
|
@@ -2253,7 +2528,7 @@ const CustomerService = (props)=>{
|
|
|
2253
2528
|
getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
2254
2529
|
overlayClassName: styles.popover_main_content,
|
|
2255
2530
|
title: item.quotedMessage,
|
|
2256
|
-
placement: "
|
|
2531
|
+
placement: "rightTop",
|
|
2257
2532
|
children: /*#__PURE__*/ _jsxs("p", {
|
|
2258
2533
|
className: styles.text_exceed,
|
|
2259
2534
|
children: [
|
|
@@ -2265,7 +2540,7 @@ const CustomerService = (props)=>{
|
|
|
2265
2540
|
children: item.quotedMessage
|
|
2266
2541
|
}),
|
|
2267
2542
|
item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2268
|
-
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 :
|
|
2543
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ""}`,
|
|
2269
2544
|
children: [
|
|
2270
2545
|
/*#__PURE__*/ _jsx("img", {
|
|
2271
2546
|
src: JSON.parse(item.extraInfo)[0].value
|
|
@@ -2282,248 +2557,106 @@ const CustomerService = (props)=>{
|
|
|
2282
2557
|
]
|
|
2283
2558
|
})
|
|
2284
2559
|
]
|
|
2560
|
+
}),
|
|
2561
|
+
historyMessageList.length - 1 !== i && /*#__PURE__*/ _jsx("div", {
|
|
2562
|
+
className: `${styles.operate_modal} ${styles.bottom} ${styles.operate_modal_showbottom}`,
|
|
2563
|
+
children: // 不是最后一行,
|
|
2564
|
+
renderOperateBtn(item, isAiChatWindow, i)
|
|
2285
2565
|
})
|
|
2286
2566
|
]
|
|
2287
2567
|
})
|
|
2288
|
-
}),
|
|
2289
|
-
(showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
|
|
2290
|
-
className: styles.head_sculpture,
|
|
2291
|
-
style: {
|
|
2292
|
-
marginLeft: "12px"
|
|
2293
|
-
},
|
|
2294
|
-
children: /*#__PURE__*/ _jsx("img", {
|
|
2295
|
-
src: userData.avatar
|
|
2296
|
-
})
|
|
2297
2568
|
})
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2569
|
+
})
|
|
2570
|
+
]
|
|
2571
|
+
}, item.id)
|
|
2572
|
+
]
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
return /*#__PURE__*/ _jsx(React.Fragment, {
|
|
2576
|
+
children: li
|
|
2577
|
+
}, item.id);
|
|
2578
|
+
}
|
|
2579
|
+
return /*#__PURE__*/ _jsx("ul", {
|
|
2580
|
+
className: styles.message_con,
|
|
2581
|
+
style: {
|
|
2582
|
+
height: historyMessageListVirtuosoHeight
|
|
2583
|
+
},
|
|
2584
|
+
children: /*#__PURE__*/ _jsx(Virtuoso, {
|
|
2585
|
+
ref: historyMessageListVirtuosoRef,
|
|
2586
|
+
data: historyMessageList,
|
|
2587
|
+
itemContent: itemContent,
|
|
2588
|
+
totalCount: historyMessageList.length,
|
|
2589
|
+
style: {
|
|
2590
|
+
height: "100%"
|
|
2591
|
+
},
|
|
2592
|
+
// initialTopMostItemIndex={isPositionState? { index: "LAST", align: "end" }:undefined}
|
|
2593
|
+
startReached: ()=>{
|
|
2594
|
+
if (pageCount > pageNum && pageCount > 0) {
|
|
2595
|
+
let number = pageNum + 1;
|
|
2596
|
+
setPageNum((pageNum)=>{
|
|
2597
|
+
return pageNum + 1;
|
|
2598
|
+
});
|
|
2599
|
+
setLoading(true);
|
|
2600
|
+
listTimer.current = setTimeout(()=>{
|
|
2601
|
+
getHistoryMessage(number, 2);
|
|
2602
|
+
}, 1000);
|
|
2310
2603
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2604
|
+
},
|
|
2605
|
+
endReached: ()=>{
|
|
2606
|
+
if (pageNumHistory > 1) {
|
|
2607
|
+
let number = pageNumHistory - 1;
|
|
2608
|
+
setPageNumHistory(number);
|
|
2609
|
+
clearTimeout(listTimer.current);
|
|
2610
|
+
listTimer.current = setTimeout(()=>{
|
|
2611
|
+
if (number > 0) {
|
|
2612
|
+
setBottomLoading(true);
|
|
2613
|
+
getHistoryMessage(number, 4);
|
|
2614
|
+
setLastId("");
|
|
2615
|
+
} else {
|
|
2616
|
+
setPageNumHistory(0);
|
|
2617
|
+
}
|
|
2618
|
+
}, 1000);
|
|
2619
|
+
}
|
|
2620
|
+
},
|
|
2621
|
+
context: {
|
|
2622
|
+
loading
|
|
2623
|
+
},
|
|
2624
|
+
firstItemIndex: firstItemIndex,
|
|
2625
|
+
increaseViewportBy: 200,
|
|
2626
|
+
overscan: 10,
|
|
2627
|
+
logLevel: 0,
|
|
2628
|
+
onScroll: (e)=>{
|
|
2629
|
+
//生成答案过程中
|
|
2630
|
+
if (!finishedRef.current) {
|
|
2631
|
+
var _container, _container1, _container2;
|
|
2632
|
+
const container = e.target;
|
|
2633
|
+
var _container_scrollTop;
|
|
2634
|
+
const scrollTop = (_container_scrollTop = (_container = container) === null || _container === void 0 ? void 0 : _container.scrollTop) !== null && _container_scrollTop !== void 0 ? _container_scrollTop : 0;
|
|
2635
|
+
var _container_clientHeight;
|
|
2636
|
+
const clientHeight = (_container_clientHeight = (_container1 = container) === null || _container1 === void 0 ? void 0 : _container1.clientHeight) !== null && _container_clientHeight !== void 0 ? _container_clientHeight : 0;
|
|
2637
|
+
var _container_scrollHeight;
|
|
2638
|
+
const scrollHeight = (_container_scrollHeight = (_container2 = container) === null || _container2 === void 0 ? void 0 : _container2.scrollHeight) !== null && _container_scrollHeight !== void 0 ? _container_scrollHeight : 0;
|
|
2639
|
+
const distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
|
|
2640
|
+
if (distanceFromBottom > 10) {
|
|
2641
|
+
// 距离底部超过10像素才认为是主动向上滚动
|
|
2642
|
+
isPosition.current = false;
|
|
2643
|
+
setIsPositionState(false);
|
|
2644
|
+
} else if (distanceFromBottom < 10) {
|
|
2645
|
+
// 距离底部很近时恢复自动滚动
|
|
2646
|
+
isPosition.current = true;
|
|
2647
|
+
setIsPositionState(true);
|
|
2648
|
+
}
|
|
2649
|
+
console.log("Scroll-onScroll", {
|
|
2650
|
+
container,
|
|
2651
|
+
scrollTop,
|
|
2652
|
+
clientHeight,
|
|
2653
|
+
scrollHeight,
|
|
2654
|
+
isPosition: isPosition.current
|
|
2655
|
+
});
|
|
2318
2656
|
}
|
|
2319
|
-
li = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2320
|
-
children: [
|
|
2321
|
-
dataTime ? /*#__PURE__*/ _jsx("li", {
|
|
2322
|
-
className: styles.time,
|
|
2323
|
-
children: dataTime
|
|
2324
|
-
}) : "",
|
|
2325
|
-
/*#__PURE__*/ _jsxs("li", {
|
|
2326
|
-
className: styles.right,
|
|
2327
|
-
id: lastId == item.id ? "li_flag" : item.id,
|
|
2328
|
-
children: [
|
|
2329
|
-
(showType == 2 || showType == 4) && /*#__PURE__*/ _jsx("div", {
|
|
2330
|
-
className: styles.head_sculpture,
|
|
2331
|
-
style: {
|
|
2332
|
-
marginRight: "12px"
|
|
2333
|
-
},
|
|
2334
|
-
children: isAiChatWindow ? item.extraInfo == null || header == 1 ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
|
|
2335
|
-
src: knowledge_icon
|
|
2336
|
-
}) : /*#__PURE__*/ _jsx("img", {
|
|
2337
|
-
src: headImg
|
|
2338
|
-
})
|
|
2339
|
-
}),
|
|
2340
|
-
/*#__PURE__*/ _jsx("div", {
|
|
2341
|
-
className: styles.main,
|
|
2342
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
2343
|
-
className: styles.main_content,
|
|
2344
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
2345
|
-
className: styles.main_content_flag,
|
|
2346
|
-
onMouseEnter: ()=>{
|
|
2347
|
-
const isSmall = showType == 1 || showType == 3;
|
|
2348
|
-
const container = document.getElementById(isSmall ? "chat_content" : "chat_content_modal");
|
|
2349
|
-
if (container) {
|
|
2350
|
-
const dom = container.querySelector(`[id="${item.id}"]`);
|
|
2351
|
-
if (dom) {
|
|
2352
|
-
// const con_h=document.getElementById('chat_content').clientHeight-24;//滚动区域的高度
|
|
2353
|
-
const con_h = container.clientHeight - (isSmall ? 24 : 0); //滚动区域的高度;
|
|
2354
|
-
const rectY = dom.getBoundingClientRect().y - 48;
|
|
2355
|
-
const h = dom.clientHeight + (isSmall ? 24 : 0); //当前元素高度
|
|
2356
|
-
const topDom = dom.getElementsByClassName('operate_modal_showtop')[0];
|
|
2357
|
-
const bottomDom = dom.getElementsByClassName('operate_modal_showbottom')[0];
|
|
2358
|
-
// console.log({h,con_h,rectY,topDom,bottomDom})
|
|
2359
|
-
if (topDom && bottomDom) {
|
|
2360
|
-
if (rectY > 0) {
|
|
2361
|
-
topDom.style.cssText = "";
|
|
2362
|
-
bottomDom.style.cssText = "visibility: hidden;";
|
|
2363
|
-
// 上下都能显示时,显示到下边
|
|
2364
|
-
if (h < con_h - rectY) {
|
|
2365
|
-
console.log('上下都能显示时,显示到下边');
|
|
2366
|
-
topDom.style.cssText = "visibility: hidden;";
|
|
2367
|
-
bottomDom.style.cssText = "";
|
|
2368
|
-
}
|
|
2369
|
-
} else {
|
|
2370
|
-
// 上下都不显示
|
|
2371
|
-
if (h > con_h && h - con_h > Math.abs(rectY)) {
|
|
2372
|
-
console.log('上下都不显示');
|
|
2373
|
-
topDom.style.cssText = "visibility: hidden;";
|
|
2374
|
-
bottomDom.style.cssText = `top:${-(h + rectY - 51 - (isSmall ? 0 : 58))}px;`;
|
|
2375
|
-
} else {
|
|
2376
|
-
console.log('12312312');
|
|
2377
|
-
topDom.style.cssText = "visibility: hidden;";
|
|
2378
|
-
bottomDom.style.cssText = "";
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
},
|
|
2385
|
-
children: [
|
|
2386
|
-
/*#__PURE__*/ _jsx("div", {
|
|
2387
|
-
className: `${styles.operate_modal} operate_modal_showtop`,
|
|
2388
|
-
children: // 不是最后一行,
|
|
2389
|
-
historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
|
|
2390
|
-
}),
|
|
2391
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
2392
|
-
className: styles.content,
|
|
2393
|
-
children: [
|
|
2394
|
-
item.message != 'AI助手繁忙,请稍后再提问或' && /*#__PURE__*/ _jsx("p", {
|
|
2395
|
-
dangerouslySetInnerHTML: {
|
|
2396
|
-
__html: message
|
|
2397
|
-
},
|
|
2398
|
-
className: styles.content_child
|
|
2399
|
-
}),
|
|
2400
|
-
item.message == 'AI助手繁忙,请稍后再提问或' && /*#__PURE__*/ _jsxs("p", {
|
|
2401
|
-
children: [
|
|
2402
|
-
"AI助手繁忙,请稍后再提问或",
|
|
2403
|
-
/*#__PURE__*/ _jsx("span", {
|
|
2404
|
-
className: styles.find_teacher_con,
|
|
2405
|
-
onClick: ()=>{
|
|
2406
|
-
let extraInfo = historyMessageList[i - 1].extraInfo;
|
|
2407
|
-
let url = '';
|
|
2408
|
-
if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
|
|
2409
|
-
url = JSON.parse(extraInfo)[0].value;
|
|
2410
|
-
}
|
|
2411
|
-
setProblem({
|
|
2412
|
-
question: historyMessageList[i - 1].message,
|
|
2413
|
-
url
|
|
2414
|
-
});
|
|
2415
|
-
setShowTeacherList(true);
|
|
2416
|
-
},
|
|
2417
|
-
children: "召唤老师回答"
|
|
2418
|
-
})
|
|
2419
|
-
]
|
|
2420
|
-
}),
|
|
2421
|
-
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2422
|
-
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ''}`,
|
|
2423
|
-
children: [
|
|
2424
|
-
/*#__PURE__*/ _jsx("img", {
|
|
2425
|
-
src: JSON.parse(item.extraInfo)[0].value
|
|
2426
|
-
}),
|
|
2427
|
-
/*#__PURE__*/ _jsx("div", {
|
|
2428
|
-
className: styles.mask_zoom,
|
|
2429
|
-
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2430
|
-
onClick: ()=>{
|
|
2431
|
-
setViewBase64(JSON.parse(item.extraInfo)[0].value);
|
|
2432
|
-
setVisible(true);
|
|
2433
|
-
}
|
|
2434
|
-
})
|
|
2435
|
-
})
|
|
2436
|
-
]
|
|
2437
|
-
}),
|
|
2438
|
-
item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsxs("ul", {
|
|
2439
|
-
className: `${styles.association_problem} ${item.message == '抱歉,我暂时无法回答这样的问题。' ? styles.association_problem_flag : ''}`,
|
|
2440
|
-
children: [
|
|
2441
|
-
item.message == '抱歉,我暂时无法回答这样的问题。' && /*#__PURE__*/ _jsx("li", {
|
|
2442
|
-
className: styles.related_issues_flag,
|
|
2443
|
-
children: /*#__PURE__*/ _jsx("span", {
|
|
2444
|
-
children: "相关问题"
|
|
2445
|
-
})
|
|
2446
|
-
}),
|
|
2447
|
-
JSON.parse(item.extraInfo).map((list, index)=>{
|
|
2448
|
-
return /*#__PURE__*/ _jsx("li", {
|
|
2449
|
-
onClick: ()=>{
|
|
2450
|
-
sendMessage(list, 1);
|
|
2451
|
-
setBottomRecommendationQuestions([]);
|
|
2452
|
-
resettingBottomHei();
|
|
2453
|
-
},
|
|
2454
|
-
children: item.message == '抱歉,我暂时无法回答这样的问题。' ? list.question : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2455
|
-
children: [
|
|
2456
|
-
JSON.parse(item.extraInfo).length > 1 ? index + 1 + '.' : '',
|
|
2457
|
-
list.question
|
|
2458
|
-
]
|
|
2459
|
-
})
|
|
2460
|
-
}, i + "_" + index + "_" + list.value);
|
|
2461
|
-
})
|
|
2462
|
-
]
|
|
2463
|
-
}),
|
|
2464
|
-
//findTeacher//是否在召唤老师过程中,是否是最后一条消息
|
|
2465
|
-
!item.findTeacher && historyMessageList.length - 1 == i && item.id != "123456" && item.id != '123456_date' && renderLastOperateBtn(item, isAiChatWindow, i)
|
|
2466
|
-
]
|
|
2467
|
-
}),
|
|
2468
|
-
//引用消息
|
|
2469
|
-
item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
|
|
2470
|
-
className: styles.citation_content,
|
|
2471
|
-
children: [
|
|
2472
|
-
getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
2473
|
-
overlayClassName: styles.popover_main_content,
|
|
2474
|
-
title: item.quotedMessage,
|
|
2475
|
-
placement: "rightTop",
|
|
2476
|
-
children: /*#__PURE__*/ _jsxs("p", {
|
|
2477
|
-
className: styles.text_exceed,
|
|
2478
|
-
children: [
|
|
2479
|
-
item.quotedMessage,
|
|
2480
|
-
/*#__PURE__*/ _jsx(RightOutlined, {})
|
|
2481
|
-
]
|
|
2482
|
-
})
|
|
2483
|
-
}) : /*#__PURE__*/ _jsx("p", {
|
|
2484
|
-
children: item.quotedMessage
|
|
2485
|
-
}),
|
|
2486
|
-
item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" && /*#__PURE__*/ _jsxs("p", {
|
|
2487
|
-
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ''}`,
|
|
2488
|
-
children: [
|
|
2489
|
-
/*#__PURE__*/ _jsx("img", {
|
|
2490
|
-
src: JSON.parse(item.extraInfo)[0].value
|
|
2491
|
-
}),
|
|
2492
|
-
/*#__PURE__*/ _jsx("div", {
|
|
2493
|
-
className: styles.mask_zoom,
|
|
2494
|
-
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2495
|
-
onClick: ()=>{
|
|
2496
|
-
setViewBase64(JSON.parse(item.extraInfo)[0].value);
|
|
2497
|
-
setVisible(true);
|
|
2498
|
-
}
|
|
2499
|
-
})
|
|
2500
|
-
})
|
|
2501
|
-
]
|
|
2502
|
-
})
|
|
2503
|
-
]
|
|
2504
|
-
}),
|
|
2505
|
-
historyMessageList.length - 1 !== i && /*#__PURE__*/ _jsx("div", {
|
|
2506
|
-
className: `${styles.operate_modal} ${styles.bottom} operate_modal_showbottom`,
|
|
2507
|
-
children: // 不是最后一行,
|
|
2508
|
-
renderOperateBtn(item, isAiChatWindow, i)
|
|
2509
|
-
})
|
|
2510
|
-
]
|
|
2511
|
-
})
|
|
2512
|
-
})
|
|
2513
|
-
})
|
|
2514
|
-
]
|
|
2515
|
-
}, item.id)
|
|
2516
|
-
]
|
|
2517
|
-
});
|
|
2518
2657
|
}
|
|
2519
|
-
return /*#__PURE__*/ _jsx(React.Fragment, {
|
|
2520
|
-
children: li
|
|
2521
|
-
}, item.id);
|
|
2522
2658
|
})
|
|
2523
2659
|
});
|
|
2524
|
-
// } else {
|
|
2525
|
-
// return "";
|
|
2526
|
-
// }
|
|
2527
2660
|
};
|
|
2528
2661
|
//渲染相关操作按钮 header == 1 ai ,== 2 知识库
|
|
2529
2662
|
const renderOperateBtn = (item, isAiChatWindow, i)=>{
|
|
@@ -2540,9 +2673,9 @@ const CustomerService = (props)=>{
|
|
|
2540
2673
|
isAiChatWindow && userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("span", {
|
|
2541
2674
|
className: styles.ask_question,
|
|
2542
2675
|
onClick: ()=>{
|
|
2543
|
-
console.log(historyMessageList[i - 1], 4444444);
|
|
2676
|
+
// console.log(historyMessageList[i - 1], 4444444);
|
|
2544
2677
|
let extraInfo = historyMessageList[i - 1].extraInfo;
|
|
2545
|
-
let url =
|
|
2678
|
+
let url = "";
|
|
2546
2679
|
if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
|
|
2547
2680
|
url = JSON.parse(extraInfo)[0].value;
|
|
2548
2681
|
}
|
|
@@ -2683,14 +2816,12 @@ const CustomerService = (props)=>{
|
|
|
2683
2816
|
}
|
|
2684
2817
|
} catch (error) {}
|
|
2685
2818
|
clearTimeout(receiveMessageTimer.current);
|
|
2819
|
+
clearTimeout(renderAiAnswerTimer.current);
|
|
2686
2820
|
setHistoryMessageList((historyMessageList)=>{
|
|
2687
2821
|
return historyMessageList.filter((item)=>item.id != "123456");
|
|
2688
2822
|
});
|
|
2689
|
-
|
|
2690
|
-
setFinished(
|
|
2691
|
-
finishedRef.current = true;
|
|
2692
|
-
return finishedRef.current;
|
|
2693
|
-
});
|
|
2823
|
+
finishedRef.current = true;
|
|
2824
|
+
setFinished(true);
|
|
2694
2825
|
onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
|
|
2695
2826
|
}
|
|
2696
2827
|
}),
|
|
@@ -2703,14 +2834,12 @@ const CustomerService = (props)=>{
|
|
|
2703
2834
|
}
|
|
2704
2835
|
} catch (error) {}
|
|
2705
2836
|
clearTimeout(receiveMessageTimer.current);
|
|
2837
|
+
clearTimeout(renderAiAnswerTimer.current);
|
|
2706
2838
|
setHistoryMessageList((historyMessageList)=>{
|
|
2707
2839
|
return historyMessageList.filter((item)=>item.id != "123456");
|
|
2708
2840
|
});
|
|
2709
|
-
|
|
2710
|
-
setFinished(
|
|
2711
|
-
finishedRef.current = true;
|
|
2712
|
-
return finishedRef.current;
|
|
2713
|
-
});
|
|
2841
|
+
finishedRef.current = true;
|
|
2842
|
+
setFinished(true);
|
|
2714
2843
|
onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
|
|
2715
2844
|
},
|
|
2716
2845
|
children: "停止生成"
|
|
@@ -2722,7 +2851,7 @@ const CustomerService = (props)=>{
|
|
|
2722
2851
|
className: styles.find_teacher,
|
|
2723
2852
|
onClick: ()=>{
|
|
2724
2853
|
let extraInfo = historyMessageList[i - 1].extraInfo;
|
|
2725
|
-
let url =
|
|
2854
|
+
let url = "";
|
|
2726
2855
|
if (extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value) {
|
|
2727
2856
|
url = JSON.parse(extraInfo)[0].value;
|
|
2728
2857
|
}
|
|
@@ -2741,6 +2870,7 @@ const CustomerService = (props)=>{
|
|
|
2741
2870
|
children: [
|
|
2742
2871
|
regenerationBtn && /*#__PURE__*/ _jsx("i", {
|
|
2743
2872
|
onClick: ()=>{
|
|
2873
|
+
finishedRef.current = false;
|
|
2744
2874
|
setFinished(false);
|
|
2745
2875
|
aiSendQuestions(2, {
|
|
2746
2876
|
roomId: roomId,
|
|
@@ -2799,7 +2929,7 @@ const CustomerService = (props)=>{
|
|
|
2799
2929
|
if (!isAiChatWindow) return;
|
|
2800
2930
|
//只有最后一条回答,支持发送点赞或踩
|
|
2801
2931
|
if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
2802
|
-
console.log("判断是AI还是智能问答", item);
|
|
2932
|
+
// console.log("判断是AI还是智能问答", item);
|
|
2803
2933
|
if (!item.extraInfo && item.sender == "AI") {
|
|
2804
2934
|
aiSendQuestions(1, {
|
|
2805
2935
|
roomId: roomId,
|
|
@@ -2809,7 +2939,7 @@ const CustomerService = (props)=>{
|
|
|
2809
2939
|
generateUpvoteOrDownvoteMessage: true
|
|
2810
2940
|
}, 1);
|
|
2811
2941
|
} else {
|
|
2812
|
-
console.log("AI回答2255555");
|
|
2942
|
+
// console.log("AI回答2255555");
|
|
2813
2943
|
sendGreetingMessage(2);
|
|
2814
2944
|
}
|
|
2815
2945
|
}
|
|
@@ -2823,10 +2953,10 @@ const CustomerService = (props)=>{
|
|
|
2823
2953
|
//老师的聊天窗口中不需要点赞和踩消息
|
|
2824
2954
|
if (!isAiChatWindow) return;
|
|
2825
2955
|
//只有最后一条回答,支持发送点赞或踩
|
|
2826
|
-
console.log(item, "dlfkvmdflkv");
|
|
2956
|
+
// console.log(item, "dlfkvmdflkv");
|
|
2827
2957
|
if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
2828
2958
|
if (!item.extraInfo && item.sender == "AI") {
|
|
2829
|
-
console.log("AI回答2222");
|
|
2959
|
+
// console.log("AI回答2222");
|
|
2830
2960
|
//AI回答
|
|
2831
2961
|
aiSendQuestions(1, {
|
|
2832
2962
|
roomId: roomId,
|
|
@@ -2972,7 +3102,7 @@ const CustomerService = (props)=>{
|
|
|
2972
3102
|
/*#__PURE__*/ _jsx("span", {
|
|
2973
3103
|
className: styles.icon_close,
|
|
2974
3104
|
onClick: ()=>{
|
|
2975
|
-
setScreenshotBese64(
|
|
3105
|
+
setScreenshotBese64("");
|
|
2976
3106
|
resettingBottomHei();
|
|
2977
3107
|
},
|
|
2978
3108
|
children: /*#__PURE__*/ _jsx(CustomRoundClose, {})
|
|
@@ -2991,7 +3121,7 @@ const CustomerService = (props)=>{
|
|
|
2991
3121
|
children: [
|
|
2992
3122
|
/*#__PURE__*/ _jsxs("p", {
|
|
2993
3123
|
onClick: ()=>{
|
|
2994
|
-
sendScreenshotData(
|
|
3124
|
+
sendScreenshotData("讲解图片里的知识点");
|
|
2995
3125
|
},
|
|
2996
3126
|
children: [
|
|
2997
3127
|
/*#__PURE__*/ _jsx(CustomKnowledgeContent, {}),
|
|
@@ -3001,11 +3131,12 @@ const CustomerService = (props)=>{
|
|
|
3001
3131
|
/*#__PURE__*/ _jsx("br", {}),
|
|
3002
3132
|
/*#__PURE__*/ _jsxs("p", {
|
|
3003
3133
|
onClick: ()=>{
|
|
3004
|
-
sendScreenshotData(
|
|
3134
|
+
sendScreenshotData("总结图片内容 ");
|
|
3005
3135
|
},
|
|
3006
3136
|
children: [
|
|
3007
3137
|
/*#__PURE__*/ _jsx(CustomWenhaoRound, {}),
|
|
3008
|
-
"总结图片内容
|
|
3138
|
+
"总结图片内容",
|
|
3139
|
+
" "
|
|
3009
3140
|
]
|
|
3010
3141
|
})
|
|
3011
3142
|
]
|
|
@@ -3055,6 +3186,7 @@ const CustomerService = (props)=>{
|
|
|
3055
3186
|
if (contactsList.length > 0 && contactsList[0].roomId != roomId) {
|
|
3056
3187
|
sendToTeacher(2);
|
|
3057
3188
|
} else {
|
|
3189
|
+
finishedRef.current = false;
|
|
3058
3190
|
setFinished(false);
|
|
3059
3191
|
setQuestionsList([]);
|
|
3060
3192
|
sendMessage("", 0);
|
|
@@ -3190,9 +3322,9 @@ const CustomerService = (props)=>{
|
|
|
3190
3322
|
bottom: `${buttomHei + 6}px`
|
|
3191
3323
|
},
|
|
3192
3324
|
children: questionsList.map((item, i)=>{
|
|
3193
|
-
if (i > 4) return
|
|
3325
|
+
if (i > 4) return "";
|
|
3194
3326
|
let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
|
|
3195
|
-
let span =
|
|
3327
|
+
let span = "";
|
|
3196
3328
|
//搜索内容是否有特殊字符
|
|
3197
3329
|
if (reg.test(keyWord)) {
|
|
3198
3330
|
span = item.question.replaceAll(keyWord, (e)=>{
|
|
@@ -3237,7 +3369,7 @@ const CustomerService = (props)=>{
|
|
|
3237
3369
|
/*#__PURE__*/ _jsx("p", {
|
|
3238
3370
|
onClick: ()=>{
|
|
3239
3371
|
sendMessage(item, 1);
|
|
3240
|
-
if (config && config.type ==
|
|
3372
|
+
if (config && config.type == "video") {
|
|
3241
3373
|
setBottomRecommendationQuestions([]);
|
|
3242
3374
|
resettingBottomHei();
|
|
3243
3375
|
}
|
|
@@ -3263,7 +3395,7 @@ const CustomerService = (props)=>{
|
|
|
3263
3395
|
/*#__PURE__*/ _jsx("p", {
|
|
3264
3396
|
onClick: ()=>{
|
|
3265
3397
|
sendMessage(item, 1);
|
|
3266
|
-
if (config && config.type ==
|
|
3398
|
+
if (config && config.type == "video") {
|
|
3267
3399
|
setBottomRecommendationQuestions([]);
|
|
3268
3400
|
resettingBottomHei();
|
|
3269
3401
|
}
|
|
@@ -3430,7 +3562,7 @@ const CustomerService = (props)=>{
|
|
|
3430
3562
|
/*#__PURE__*/ _jsxs("div", {
|
|
3431
3563
|
className: `${styles.Drawer_wrap_main}`,
|
|
3432
3564
|
onClick: ()=>{
|
|
3433
|
-
setKeyWordProblem(
|
|
3565
|
+
setKeyWordProblem("");
|
|
3434
3566
|
},
|
|
3435
3567
|
children: [
|
|
3436
3568
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -3510,7 +3642,7 @@ const CustomerService = (props)=>{
|
|
|
3510
3642
|
className: `${styles.ChatWindow_Drawer}`,
|
|
3511
3643
|
id: "",
|
|
3512
3644
|
onClick: ()=>{
|
|
3513
|
-
setKeyWordProblem(
|
|
3645
|
+
setKeyWordProblem("");
|
|
3514
3646
|
},
|
|
3515
3647
|
children: [
|
|
3516
3648
|
/*#__PURE__*/ _jsx("div", {
|