bhd-components 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/1bddec89.esm.es5.production.js +72 -0
- package/dist/535fc6c5.esm.es5.development.js +95493 -0
- package/dist/CustomerService.esm.es5.development.css +2827 -0
- package/dist/CustomerService.esm.es5.development.js +3823 -0
- package/dist/CustomerService.esm.es5.production.css +1 -0
- package/dist/CustomerService.esm.es5.production.js +1 -0
- package/dist/vendor.esm.es5.development.esm.es5.development.css +117 -0
- package/dist/vendor.esm.es5.production.esm.es5.production.css +9 -0
- package/es2017/customerService/contactsList/index.d.ts +13 -0
- package/es2017/customerService/contactsList/index.js +313 -0
- package/es2017/customerService/contactsList/index.module.less +187 -0
- package/es2017/customerService/function.d.ts +17 -0
- package/es2017/customerService/function.js +67 -0
- package/es2017/customerService/historyFun/index.d.ts +13 -0
- package/es2017/customerService/historyFun/index.js +241 -0
- package/es2017/customerService/historyFun/index.module.less +189 -0
- package/es2017/customerService/images/knowledge_icon.png +0 -0
- package/es2017/customerService/images/voice_btn.gif +0 -0
- package/es2017/customerService/index.d.ts +16 -0
- package/es2017/customerService/index.js +2493 -0
- package/es2017/customerService/index.module.less +727 -0
- package/es2017/customerService/useMediaRecorder.d.ts +9 -0
- package/es2017/customerService/useMediaRecorder.js +78 -0
- package/es2017/customerService/voice_btn.gif +0 -0
- package/es2017/icons/components/custom-ai_icon.d.ts +4 -0
- package/es2017/icons/components/custom-ai_icon.js +58 -0
- package/es2017/icons/components/custom-contacts.d.ts +4 -0
- package/es2017/icons/components/custom-contacts.js +29 -0
- package/es2017/icons/components/custom-copy.d.ts +4 -0
- package/es2017/icons/components/custom-copy.js +36 -0
- package/es2017/icons/components/custom-dislike.d.ts +4 -0
- package/es2017/icons/components/custom-dislike.js +22 -0
- package/es2017/icons/components/custom-duihao.d.ts +4 -0
- package/es2017/icons/components/custom-duihao.js +22 -0
- package/es2017/icons/components/custom-exit_full_screen.d.ts +4 -0
- package/es2017/icons/components/custom-exit_full_screen.js +26 -0
- package/es2017/icons/components/custom-full_screen.d.ts +4 -0
- package/es2017/icons/components/custom-full_screen.js +22 -0
- package/es2017/icons/components/custom-like.d.ts +4 -0
- package/es2017/icons/components/custom-like.js +22 -0
- package/es2017/icons/components/custom-quote.d.ts +4 -0
- package/es2017/icons/components/custom-quote.js +31 -0
- package/es2017/icons/components/custom-record.d.ts +4 -0
- package/es2017/icons/components/custom-record.js +37 -0
- package/es2017/icons/components/custom-reloading.d.ts +4 -0
- package/es2017/icons/components/custom-reloading.js +26 -0
- package/es2017/icons/components/custom-retract.d.ts +4 -0
- package/es2017/icons/components/custom-retract.js +27 -0
- package/es2017/icons/components/custom-round_close.d.ts +4 -0
- package/es2017/icons/components/custom-round_close.js +24 -0
- package/es2017/icons/components/custom-sending.d.ts +4 -0
- package/es2017/icons/components/custom-sending.js +22 -0
- package/es2017/icons/components/custom-sound_recording.d.ts +4 -0
- package/es2017/icons/components/custom-sound_recording.js +22 -0
- package/es2017/icons/components/index.d.ts +15 -0
- package/es2017/icons/components/index.js +15 -0
- package/es2017/index.d.ts +1 -0
- package/es2017/index.js +1 -0
- package/esm/customerService/contactsList/index.d.ts +13 -0
- package/esm/customerService/contactsList/index.js +326 -0
- package/esm/customerService/contactsList/index.module.less +187 -0
- package/esm/customerService/function.d.ts +17 -0
- package/esm/customerService/function.js +69 -0
- package/esm/customerService/historyFun/index.d.ts +13 -0
- package/esm/customerService/historyFun/index.js +256 -0
- package/esm/customerService/historyFun/index.module.less +189 -0
- package/esm/customerService/images/knowledge_icon.png +0 -0
- package/esm/customerService/images/voice_btn.gif +0 -0
- package/esm/customerService/index.d.ts +16 -0
- package/esm/customerService/index.js +2576 -0
- package/esm/customerService/index.module.less +727 -0
- package/esm/customerService/useMediaRecorder.d.ts +9 -0
- package/esm/customerService/useMediaRecorder.js +121 -0
- package/esm/customerService/voice_btn.gif +0 -0
- package/esm/icons/components/custom-ai_icon.d.ts +4 -0
- package/esm/icons/components/custom-ai_icon.js +60 -0
- package/esm/icons/components/custom-contacts.d.ts +4 -0
- package/esm/icons/components/custom-contacts.js +31 -0
- package/esm/icons/components/custom-copy.d.ts +4 -0
- package/esm/icons/components/custom-copy.js +38 -0
- package/esm/icons/components/custom-dislike.d.ts +4 -0
- package/esm/icons/components/custom-dislike.js +24 -0
- package/esm/icons/components/custom-duihao.d.ts +4 -0
- package/esm/icons/components/custom-duihao.js +24 -0
- package/esm/icons/components/custom-exit_full_screen.d.ts +4 -0
- package/esm/icons/components/custom-exit_full_screen.js +28 -0
- package/esm/icons/components/custom-full_screen.d.ts +4 -0
- package/esm/icons/components/custom-full_screen.js +24 -0
- package/esm/icons/components/custom-like.d.ts +4 -0
- package/esm/icons/components/custom-like.js +24 -0
- package/esm/icons/components/custom-quote.d.ts +4 -0
- package/esm/icons/components/custom-quote.js +33 -0
- package/esm/icons/components/custom-record.d.ts +4 -0
- package/esm/icons/components/custom-record.js +39 -0
- package/esm/icons/components/custom-reloading.d.ts +4 -0
- package/esm/icons/components/custom-reloading.js +28 -0
- package/esm/icons/components/custom-retract.d.ts +4 -0
- package/esm/icons/components/custom-retract.js +29 -0
- package/esm/icons/components/custom-round_close.d.ts +4 -0
- package/esm/icons/components/custom-round_close.js +26 -0
- package/esm/icons/components/custom-sending.d.ts +4 -0
- package/esm/icons/components/custom-sending.js +24 -0
- package/esm/icons/components/custom-sound_recording.d.ts +4 -0
- package/esm/icons/components/custom-sound_recording.js +24 -0
- package/esm/icons/components/index.d.ts +15 -0
- package/esm/icons/components/index.js +15 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/package.json +10 -2
- package/dist/1951bd5c.esm.es5.development.js +0 -45417
- package/dist/28cd83d3.esm.es5.production.js +0 -256
- package/dist/table.esm.es5.development.css +0 -772
- package/dist/table.esm.es5.development.js +0 -289
- package/dist/table.esm.es5.production.css +0 -1
- package/dist/table.esm.es5.production.js +0 -1
|
@@ -0,0 +1,2493 @@
|
|
|
1
|
+
/* eslint-disable import/first */ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
4
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
5
|
+
import styles from "./index.module.less";
|
|
6
|
+
import { Modal, Drawer, Input, Tooltip } from "antd";
|
|
7
|
+
import { CustomAiIcon, CustomRecord, CustomFullScreen, CustomExitFullScreen, CustomReloading, CustomCopy, CustomLike, CustomDislike, CustomQuote, CustomSending, CustomContacts, CustomDuihao, CustomSoundRecording, CustomRoundClose } from "../icons/index";
|
|
8
|
+
import { CloseOutlined } from "@ant-design/icons";
|
|
9
|
+
import HistoryFun from "./historyFun/index";
|
|
10
|
+
import ContactsList from "./contactsList/index";
|
|
11
|
+
// import { fetchEventSource } from "@microsoft/fetch-event-source";
|
|
12
|
+
import dayjs from "dayjs";
|
|
13
|
+
import { Remarkable } from "remarkable";
|
|
14
|
+
import hljs from "highlight.js";
|
|
15
|
+
import "highlight.js/styles/default.css";
|
|
16
|
+
import { render } from "react-dom";
|
|
17
|
+
import Provider from "../provider";
|
|
18
|
+
const { TextArea } = Input;
|
|
19
|
+
import knowledge_icon from "./images/knowledge_icon.png";
|
|
20
|
+
import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
|
|
21
|
+
import { readMessage, getByteLen, serverUrl, copyText, getDataTime } from "./function"; //一些方法
|
|
22
|
+
const CustomerService = (props)=>{
|
|
23
|
+
let { userData , http , urllocation , onCancel , serverName , fetchEventSource , initShowType , onEvent , stepIds , stepId } = props;
|
|
24
|
+
// urllocation = "/zhong";
|
|
25
|
+
const [mid, setmid] = useState(props.userData.mid); //当前用户id
|
|
26
|
+
const { bese64String , startRecord , stopRecord } = useMediaRecorder(); //语音转文字
|
|
27
|
+
const [voiceRecordingStatus, setVoiceRecordingStatus] = useState(3); //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
|
|
28
|
+
const [copyTextOBJ, setCopyTextObj] = useState([]); //复制的消息id
|
|
29
|
+
const [citationContent, setCitationContent] = useState({}); //引用内容
|
|
30
|
+
const [roomId, setRoomId] = useState(""); //聊天室id
|
|
31
|
+
const [historyMessageList, setHistoryMessageList] = useState([]); //历史消息
|
|
32
|
+
const [keyWord, setKeyWord] = useState(""); //搜索内容
|
|
33
|
+
const [questionsList, setQuestionsList] = useState([]); //问题列表
|
|
34
|
+
const [hotQuestionsList, setHotQuestionsList] = useState([]); //热门问题
|
|
35
|
+
const [greetingMessage, setGreetingMessage] = useState(false); //聊天记录列表是否请求完成
|
|
36
|
+
const [pageNum, setPageNum] = useState(1); //页码
|
|
37
|
+
const [pageCount, setPageCount] = useState(0); //总页数
|
|
38
|
+
const [loading, setLoading] = useState(false); //是否显示加载图标
|
|
39
|
+
const [finished, setFinished] = useState(true); //是否结束生成
|
|
40
|
+
const [lastId, setLastId] = useState(""); //最后一条数据的id,可用于定位当前位置
|
|
41
|
+
const [chatWith, setChatWith] = useState({}); //聊天的老师id或ai
|
|
42
|
+
const [firstLoad, setFirstLoad] = useState(false); //第一次切换全屏时滚动到页面底部
|
|
43
|
+
const [buttomHei, setButtomHei] = useState(45); //底部输入框的高度
|
|
44
|
+
const [showHistory, setShowHistory] = useState(false); //是否显示历史记录
|
|
45
|
+
const [showContacts, setShowContacts] = useState(false); //是否显示关联老师
|
|
46
|
+
const [showType, setShowType] = useState(-1); //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
|
|
47
|
+
const [answerMode, setAnswerMode] = useState(-1); //设置回答模式。1,召唤老师回答
|
|
48
|
+
const [teacherList, setTeacherList] = useState([]); //老师列表
|
|
49
|
+
const [problem, setProblem] = useState({}); //召唤老师回答的问题
|
|
50
|
+
const [roomList, setRoomList] = useState([]); //聊天列表
|
|
51
|
+
const [chatObj, setChatObj] = useState([]); //聊天记录id保存,用来在实验报告中记录
|
|
52
|
+
const timer = useRef(null); //文本框输入时
|
|
53
|
+
let receiveMessageTimer = useRef(null); //接收ai发回的消息
|
|
54
|
+
let voiceCountdownTimer = useRef(null); //语音录制倒计时
|
|
55
|
+
let listTimer = useRef(null); // 请求列表倒计时
|
|
56
|
+
const ctrl = useRef(); //停止生成ai回答时使用
|
|
57
|
+
const remarkable = new Remarkable({
|
|
58
|
+
highlight: function(str, lang) {
|
|
59
|
+
if (lang && hljs.getLanguage(lang)) {
|
|
60
|
+
try {
|
|
61
|
+
return hljs.highlight(lang, str).value;
|
|
62
|
+
} catch (err) {}
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return hljs.highlightAuto(str).value;
|
|
66
|
+
} catch (err) {}
|
|
67
|
+
return ""; // use external default escaping
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
useEffect(()=>{
|
|
71
|
+
return ()=>{
|
|
72
|
+
clearTimeout(receiveMessageTimer.current);
|
|
73
|
+
clearTimeout(voiceCountdownTimer.current);
|
|
74
|
+
clearTimeout(listTimer.current);
|
|
75
|
+
clearTimeout(timer.current);
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
useEffect(()=>{
|
|
79
|
+
// console.log("重新加载",pageCount);
|
|
80
|
+
if (showType == 2 && !firstLoad && pageCount > 0) {
|
|
81
|
+
setFirstLoad(true);
|
|
82
|
+
setTimeout(()=>{
|
|
83
|
+
scrollToBottom();
|
|
84
|
+
}, 100);
|
|
85
|
+
}
|
|
86
|
+
function handleScroll() {
|
|
87
|
+
const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
88
|
+
const scrollTop = container.scrollTop;
|
|
89
|
+
// const scrollBottom = container.scroll;
|
|
90
|
+
// console.log(container,'sdcsdcsdcsdc');
|
|
91
|
+
container.onscroll = (e)=>{
|
|
92
|
+
//元素内部页面滚动到达底部
|
|
93
|
+
if (e.target.clientHeight + e.target.scrollTop >= e.target.scrollHeight) {
|
|
94
|
+
//console.log('元素内部页面滚动到达底部');
|
|
95
|
+
if (pageNum > 1) {
|
|
96
|
+
let number = pageNum - 1;
|
|
97
|
+
setPageNum((pageNum)=>{
|
|
98
|
+
return pageNum - 1;
|
|
99
|
+
});
|
|
100
|
+
clearTimeout(listTimer.current);
|
|
101
|
+
listTimer.current = setTimeout(()=>{
|
|
102
|
+
console.log("加载下一页", number);
|
|
103
|
+
getHistoryMessage(number, 2);
|
|
104
|
+
}, 1000);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
|
|
109
|
+
setLoading(true);
|
|
110
|
+
let number = pageNum + 1;
|
|
111
|
+
setPageNum((pageNum)=>{
|
|
112
|
+
return pageNum + 1;
|
|
113
|
+
});
|
|
114
|
+
clearTimeout(listTimer.current);
|
|
115
|
+
listTimer.current = setTimeout(()=>{
|
|
116
|
+
console.log("加载下一页", number);
|
|
117
|
+
getHistoryMessage(number, 0);
|
|
118
|
+
}, 1000);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
122
|
+
if (content) {
|
|
123
|
+
content.addEventListener("scroll", handleScroll);
|
|
124
|
+
}
|
|
125
|
+
return ()=>{
|
|
126
|
+
const content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
127
|
+
if (content) {
|
|
128
|
+
content.removeEventListener("scroll", handleScroll);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}, [
|
|
132
|
+
historyMessageList,
|
|
133
|
+
showType,
|
|
134
|
+
pageCount
|
|
135
|
+
]);
|
|
136
|
+
useEffect(()=>{
|
|
137
|
+
resettingBottomHei();
|
|
138
|
+
let dom = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
139
|
+
if (dom) {
|
|
140
|
+
if (showType == 1) {
|
|
141
|
+
dom.style.maxHeight = `${window.innerHeight - 60 - buttomHei}px`;
|
|
142
|
+
} else if (showType == 3) {
|
|
143
|
+
dom.style.maxHeight = `${window.innerHeight - 50 - buttomHei}px`;
|
|
144
|
+
} else {
|
|
145
|
+
dom.style.maxHeight = `${window.innerHeight - 160 - 60 - buttomHei}px`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, [
|
|
149
|
+
buttomHei,
|
|
150
|
+
showType
|
|
151
|
+
]);
|
|
152
|
+
useEffect(()=>{
|
|
153
|
+
console.log(props, 'lsdkcmsdlcksd');
|
|
154
|
+
getQuestiionsList("", 1);
|
|
155
|
+
scrollToBottom();
|
|
156
|
+
// less.modifyVars({ "@color-border-Tr": "#f4523b" });
|
|
157
|
+
// console.log("9999999", less);
|
|
158
|
+
// getRoomList();
|
|
159
|
+
setShowType(initShowType);
|
|
160
|
+
}, [
|
|
161
|
+
initShowType
|
|
162
|
+
]);
|
|
163
|
+
useEffect(()=>{
|
|
164
|
+
// console.log(roomId,1111111)
|
|
165
|
+
if (roomId != '') {
|
|
166
|
+
// console.log(roomId,2222222)
|
|
167
|
+
let num = pageNum != 1 ? pageNum : 1;
|
|
168
|
+
getHistoryMessage(num, 0);
|
|
169
|
+
scrollToBottom();
|
|
170
|
+
}
|
|
171
|
+
}, [
|
|
172
|
+
roomId
|
|
173
|
+
]);
|
|
174
|
+
useEffect(()=>{
|
|
175
|
+
console.log(roomList, 'roomListroomListroomListroomListroomList');
|
|
176
|
+
if (roomList.length > 0) {
|
|
177
|
+
//切换到有聊天的窗口
|
|
178
|
+
let message = roomList.filter((item)=>item.unreadCount > 0);
|
|
179
|
+
if (message.length > 0) {
|
|
180
|
+
setRoomId(message[0].roomId);
|
|
181
|
+
readMessage(message[0].roomId, urllocation, userData, http);
|
|
182
|
+
} else {
|
|
183
|
+
setRoomId(roomList[0].roomId);
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
createRooms("AI").then((res)=>{
|
|
187
|
+
// console.log(res.data,'dlfkvdlkfvmdf');
|
|
188
|
+
setRoomId(res.data.id);
|
|
189
|
+
setRoomList([
|
|
190
|
+
{
|
|
191
|
+
roomId: res.data.id,
|
|
192
|
+
unreadCount: 0,
|
|
193
|
+
uid: mid
|
|
194
|
+
}
|
|
195
|
+
]);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}, [
|
|
199
|
+
roomList
|
|
200
|
+
]);
|
|
201
|
+
//进入页面,发送打招呼信息
|
|
202
|
+
useEffect(()=>{
|
|
203
|
+
// console.log(historyMessageList, "dkjvndfkjvd33333f");
|
|
204
|
+
//老师的聊天窗口不发送打招呼信息
|
|
205
|
+
if (!(roomList.length > 0 && roomList[0].roomId != roomId)) {
|
|
206
|
+
//是否发送打招呼信息
|
|
207
|
+
if (greetingMessage && historyMessageList.length == 0) {
|
|
208
|
+
sendGreetingMessage(1);
|
|
209
|
+
} else {
|
|
210
|
+
try {
|
|
211
|
+
if (historyMessageList[historyMessageList.length - 1].extraInfo == null) {
|
|
212
|
+
sendGreetingMessage(1);
|
|
213
|
+
} else if (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo).length > 0 && (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].key == "questionId" || JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].value == "knowledgebase")) {
|
|
214
|
+
console.log(JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo, "sdklsdksd"));
|
|
215
|
+
sendGreetingMessage(1);
|
|
216
|
+
}
|
|
217
|
+
} catch (error) {}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
scrollToBottom();
|
|
221
|
+
}, [
|
|
222
|
+
greetingMessage,
|
|
223
|
+
hotQuestionsList
|
|
224
|
+
]);
|
|
225
|
+
//语音转文字
|
|
226
|
+
useEffect(()=>{
|
|
227
|
+
if (bese64String != "") {
|
|
228
|
+
speechToText();
|
|
229
|
+
}
|
|
230
|
+
//发送给后端语音brse64
|
|
231
|
+
}, [
|
|
232
|
+
bese64String
|
|
233
|
+
]);
|
|
234
|
+
//AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
|
|
235
|
+
const sendGreetingMessage = (type)=>{
|
|
236
|
+
let questionsList = [];
|
|
237
|
+
let obj = {};
|
|
238
|
+
if (type == 1) {
|
|
239
|
+
questionsList = hotQuestionsList.map((item, index)=>{
|
|
240
|
+
if (index < 3) {
|
|
241
|
+
return {
|
|
242
|
+
key: "messageSource",
|
|
243
|
+
value: item.id,
|
|
244
|
+
question: item.question,
|
|
245
|
+
answer: item.answer
|
|
246
|
+
};
|
|
247
|
+
} else {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
questionsList = questionsList.filter((i)=>i != null);
|
|
252
|
+
obj = {
|
|
253
|
+
roomId: roomId,
|
|
254
|
+
sender: "AI",
|
|
255
|
+
recevier: mid,
|
|
256
|
+
message: `Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?`,
|
|
257
|
+
extraInfos: questionsList
|
|
258
|
+
};
|
|
259
|
+
} else if (type == 2) {
|
|
260
|
+
obj = {
|
|
261
|
+
roomId: roomId,
|
|
262
|
+
sender: "AI",
|
|
263
|
+
recevier: mid,
|
|
264
|
+
message: `您的点赞是我最大的鼓励!`,
|
|
265
|
+
createdAt: getDataTime(-1),
|
|
266
|
+
extraInfos: [
|
|
267
|
+
{
|
|
268
|
+
key: "messageSource",
|
|
269
|
+
value: "knowledgebase"
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
} else if (type == 3) {
|
|
274
|
+
obj = {
|
|
275
|
+
roomId: roomId,
|
|
276
|
+
sender: "AI",
|
|
277
|
+
recevier: mid,
|
|
278
|
+
message: `谢谢您的反馈,我会努力改进的!`,
|
|
279
|
+
createdAt: getDataTime(-1),
|
|
280
|
+
extraInfos: [
|
|
281
|
+
{
|
|
282
|
+
key: "messageSource",
|
|
283
|
+
value: "knowledgebase"
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
};
|
|
287
|
+
} else if (type == 4) {
|
|
288
|
+
obj = {
|
|
289
|
+
roomId: roomId,
|
|
290
|
+
sender: mid,
|
|
291
|
+
recevier: "AI",
|
|
292
|
+
message: keyWord,
|
|
293
|
+
createdAt: getDataTime(-1),
|
|
294
|
+
quotedMessage: citationContent.content,
|
|
295
|
+
extraInfos: [
|
|
296
|
+
{
|
|
297
|
+
key: "messageSource",
|
|
298
|
+
value: "knowledgebase"
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
};
|
|
302
|
+
} else if (type == 5) {
|
|
303
|
+
obj = {
|
|
304
|
+
roomId: roomId,
|
|
305
|
+
sender: "AI",
|
|
306
|
+
recevier: mid,
|
|
307
|
+
message: "抱歉!您今日的提问量已经达到最大限额,请您明日再来提问。",
|
|
308
|
+
createdAt: getDataTime(-1),
|
|
309
|
+
quotedMessage: citationContent.content,
|
|
310
|
+
extraInfos: [
|
|
311
|
+
{
|
|
312
|
+
key: "messageSource",
|
|
313
|
+
value: "knowledgebase"
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
};
|
|
317
|
+
} else if (type == 6) {
|
|
318
|
+
questionsList = hotQuestionsList.map((item)=>{
|
|
319
|
+
return {
|
|
320
|
+
key: "messageSource",
|
|
321
|
+
value: item.id,
|
|
322
|
+
question: item.question,
|
|
323
|
+
answer: item.answer
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
obj = {
|
|
327
|
+
roomId: roomId,
|
|
328
|
+
sender: "AI",
|
|
329
|
+
recevier: mid,
|
|
330
|
+
message: `猜你想问:`,
|
|
331
|
+
extraInfos: questionsList
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
setKeyWord("");
|
|
335
|
+
setQuestionsList([]);
|
|
336
|
+
setCitationContent({});
|
|
337
|
+
http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj, {
|
|
338
|
+
headers: {
|
|
339
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
340
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
341
|
+
}
|
|
342
|
+
}).then((res)=>{
|
|
343
|
+
if (res.data.id) {
|
|
344
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
345
|
+
let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
346
|
+
id: res.data.id,
|
|
347
|
+
upvoted: false,
|
|
348
|
+
downvoted: false,
|
|
349
|
+
quotedMessage: "",
|
|
350
|
+
createdAt: getDataTime(-1),
|
|
351
|
+
extraInfo: JSON.stringify(obj.extraInfos)
|
|
352
|
+
}));
|
|
353
|
+
return newHistoryMessageList;
|
|
354
|
+
});
|
|
355
|
+
scrollToBottom();
|
|
356
|
+
if (type == 4) {
|
|
357
|
+
sendGreetingMessage(6);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}).catch((err)=>{
|
|
361
|
+
console.log(err);
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
//消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
|
|
365
|
+
const sendToTeacher = (type)=>{
|
|
366
|
+
console.log("消息发送给老师111");
|
|
367
|
+
let obj = {};
|
|
368
|
+
if (type == 1) {
|
|
369
|
+
obj = {
|
|
370
|
+
roomId: roomId,
|
|
371
|
+
sender: mid,
|
|
372
|
+
recevier: chatWith.uid,
|
|
373
|
+
message: problem.question
|
|
374
|
+
};
|
|
375
|
+
} else if (type == 2) {
|
|
376
|
+
let list = roomList.filter((item)=>item.roomId == roomId);
|
|
377
|
+
let recevier = '';
|
|
378
|
+
if (list.length > 0) {
|
|
379
|
+
recevier = list[0].sender;
|
|
380
|
+
}
|
|
381
|
+
obj = {
|
|
382
|
+
roomId: roomId,
|
|
383
|
+
sender: mid,
|
|
384
|
+
recevier: recevier,
|
|
385
|
+
message: keyWord
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
http.post(`${urllocation}/chat-service/public/v1.0/chat-with-user/messages`, obj, {
|
|
389
|
+
headers: {
|
|
390
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "TeacherAnswer").id,
|
|
391
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
392
|
+
}
|
|
393
|
+
}).then((res)=>{
|
|
394
|
+
if (res.data.id) {
|
|
395
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
396
|
+
let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
397
|
+
id: res.data.id,
|
|
398
|
+
upvoted: false,
|
|
399
|
+
downvoted: false,
|
|
400
|
+
quotedMessage: "",
|
|
401
|
+
createdAt: getDataTime(-1)
|
|
402
|
+
}));
|
|
403
|
+
return newHistoryMessageList;
|
|
404
|
+
});
|
|
405
|
+
scrollToBottom();
|
|
406
|
+
//记录一个问题id,用于记录老师和学生之间的聊天保存到实验报告中
|
|
407
|
+
if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
|
|
408
|
+
// setChatObj({'roomId':roomId,'id':res.data.id});
|
|
409
|
+
let obj = [
|
|
410
|
+
{
|
|
411
|
+
'roomId': roomId,
|
|
412
|
+
'id': res.data.id
|
|
413
|
+
}
|
|
414
|
+
];
|
|
415
|
+
setChatObj((list)=>{
|
|
416
|
+
let list2 = list.filter((item)=>item.id != obj[0].id);
|
|
417
|
+
return list2.concat(obj);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}).catch((err)=>{
|
|
422
|
+
console.log(err);
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
//发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息
|
|
426
|
+
const sendMessage = (item, flag)=>{
|
|
427
|
+
let questions = [];
|
|
428
|
+
if (item && flag) {
|
|
429
|
+
questions = [
|
|
430
|
+
item
|
|
431
|
+
];
|
|
432
|
+
}
|
|
433
|
+
//点击知识库的问题,或者是点击问候消息
|
|
434
|
+
if (questions.length > 0) {
|
|
435
|
+
questions = questions[0];
|
|
436
|
+
//向知识库发送问题 type 1,发送问题 2 发送答案 obj 需要的参数
|
|
437
|
+
let obj = {
|
|
438
|
+
roomId: roomId,
|
|
439
|
+
sender: mid,
|
|
440
|
+
recevier: "AI",
|
|
441
|
+
message: questions.question,
|
|
442
|
+
extraInfos: [
|
|
443
|
+
{
|
|
444
|
+
key: "questionId",
|
|
445
|
+
value: flag == 1 ? questions.value : questions.id
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
};
|
|
449
|
+
//发送问题 1 类型,发送问题需要的参数,问题的答案id等
|
|
450
|
+
sendingExistingIssues(1, obj, {
|
|
451
|
+
key: "questionId",
|
|
452
|
+
value: flag == 1 ? questions.value : questions.id,
|
|
453
|
+
answer: questions.answer
|
|
454
|
+
});
|
|
455
|
+
setKeyWord("");
|
|
456
|
+
setQuestionsList([]);
|
|
457
|
+
setCitationContent({});
|
|
458
|
+
} else if (userData.modules.some((item)=>item.short == "AIservice")) {
|
|
459
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
460
|
+
let newHistoryMessageList = historyMessageList.concat({
|
|
461
|
+
roomId: roomId,
|
|
462
|
+
sender: mid,
|
|
463
|
+
recevier: "AI",
|
|
464
|
+
message: keyWord,
|
|
465
|
+
quotedMessage: citationContent.content,
|
|
466
|
+
id: "654321",
|
|
467
|
+
upvoted: false,
|
|
468
|
+
downvoted: false,
|
|
469
|
+
createdAt: getDataTime(-1),
|
|
470
|
+
extraInfo: JSON.stringify([])
|
|
471
|
+
});
|
|
472
|
+
return newHistoryMessageList;
|
|
473
|
+
});
|
|
474
|
+
setFinished(false);
|
|
475
|
+
aiSendQuestions(3, {
|
|
476
|
+
//相关数据
|
|
477
|
+
roomId: roomId,
|
|
478
|
+
message: keyWord,
|
|
479
|
+
quotedMessage: citationContent.content || "",
|
|
480
|
+
regenerate: citationContent.content != "" ? false : true,
|
|
481
|
+
generateUpvoteOrDownvoteMessage: false
|
|
482
|
+
}, 1);
|
|
483
|
+
//存在AI客服
|
|
484
|
+
} else {
|
|
485
|
+
//不存在AI客服
|
|
486
|
+
sendGreetingMessage(4);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
//向知识库发送问题 或答案 type:1 发送问题 2 接受答案
|
|
490
|
+
const sendingExistingIssues = (type, obj, questions)=>{
|
|
491
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
492
|
+
let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
493
|
+
id: null,
|
|
494
|
+
upvoted: false,
|
|
495
|
+
downvoted: false,
|
|
496
|
+
createdAt: getDataTime(-1),
|
|
497
|
+
extraInfo: JSON.stringify(obj.extraInfos)
|
|
498
|
+
}));
|
|
499
|
+
return newHistoryMessageList;
|
|
500
|
+
});
|
|
501
|
+
scrollToBottom();
|
|
502
|
+
http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj, {
|
|
503
|
+
headers: {
|
|
504
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
505
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
506
|
+
}
|
|
507
|
+
}).then((res)=>{
|
|
508
|
+
if (res.data.id) {
|
|
509
|
+
//更新聊天记录id
|
|
510
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
511
|
+
let newHistoryMessageList = historyMessageList.map((item)=>{
|
|
512
|
+
if (item.id == null) {
|
|
513
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
514
|
+
id: res.data.id
|
|
515
|
+
});
|
|
516
|
+
} else {
|
|
517
|
+
return item;
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
return newHistoryMessageList;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (type == 1) {
|
|
524
|
+
//发送答案,调用自动回答
|
|
525
|
+
let dataObj = {
|
|
526
|
+
roomId: roomId,
|
|
527
|
+
sender: "AI",
|
|
528
|
+
recevier: mid,
|
|
529
|
+
message: questions.answer,
|
|
530
|
+
extraInfos: [
|
|
531
|
+
{
|
|
532
|
+
key: "questionId",
|
|
533
|
+
value: questions.value
|
|
534
|
+
}
|
|
535
|
+
]
|
|
536
|
+
};
|
|
537
|
+
sendingExistingIssues(2, dataObj, '');
|
|
538
|
+
testLabQuestion(obj.message, questions.answer, '');
|
|
539
|
+
}
|
|
540
|
+
}).then((res)=>{
|
|
541
|
+
console.log(res);
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
//向AI发送问题 type == 1 发送点赞或踩消息,type == 2 发送重新生成消息,type == 3 正常发送消息
|
|
545
|
+
let content = ''; //用于实验报告的问题记录
|
|
546
|
+
const aiSendQuestions = (type, obj, id)=>{
|
|
547
|
+
content = '';
|
|
548
|
+
// if (type == 3) {
|
|
549
|
+
// try {
|
|
550
|
+
// if (ctrl && ctrl.current) {
|
|
551
|
+
// ctrl.current.abort();
|
|
552
|
+
// }
|
|
553
|
+
// } catch (error) {}
|
|
554
|
+
// clearTimeout(receiveMessageTimer.current);
|
|
555
|
+
// setHistoryMessageList((historyMessageList) => {
|
|
556
|
+
// return historyMessageList.filter((item) => item.id != "123456");
|
|
557
|
+
// });
|
|
558
|
+
// setFinished(true);
|
|
559
|
+
// return;
|
|
560
|
+
// }
|
|
561
|
+
ctrl.current = new AbortController();
|
|
562
|
+
clearTimeout(receiveMessageTimer.current);
|
|
563
|
+
receiveMessageTimer.current = setTimeout(()=>{
|
|
564
|
+
// console.log('超时终止1111')
|
|
565
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
566
|
+
return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
|
|
567
|
+
});
|
|
568
|
+
setFinished(true);
|
|
569
|
+
ctrl.current.abort();
|
|
570
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
571
|
+
return historyMessageList.concat({
|
|
572
|
+
roomId: roomId,
|
|
573
|
+
sender: "AI",
|
|
574
|
+
recevier: mid,
|
|
575
|
+
message: "网络异常,请稍后重试!",
|
|
576
|
+
id: "123456",
|
|
577
|
+
createdAt: getDataTime(-1),
|
|
578
|
+
extraInfo: null
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
}, 60 * 1000);
|
|
582
|
+
let data = JSON.stringify(obj);
|
|
583
|
+
// if (type == 1 || type == 2) {
|
|
584
|
+
// data = JSON.stringify(obj);
|
|
585
|
+
// } else if(type == 3){
|
|
586
|
+
// data = JSON.stringify({
|
|
587
|
+
// //相关数据
|
|
588
|
+
// roomId: roomId,
|
|
589
|
+
// message: keyWord,
|
|
590
|
+
// quotedMessage: citationContent.content || "",
|
|
591
|
+
// regenerate: citationContent.content != "" ? false : true,
|
|
592
|
+
// generateUpvoteOrDownvoteMessage: false,
|
|
593
|
+
// });
|
|
594
|
+
// }
|
|
595
|
+
setKeyWord("");
|
|
596
|
+
setQuestionsList([]);
|
|
597
|
+
setTimeout(()=>{
|
|
598
|
+
setQuestionsList([]);
|
|
599
|
+
}, 2000);
|
|
600
|
+
//占位信息
|
|
601
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
602
|
+
if (type == 2) {
|
|
603
|
+
return historyMessageList.map((item)=>{
|
|
604
|
+
if (item.id == id) {
|
|
605
|
+
return {
|
|
606
|
+
roomId: roomId,
|
|
607
|
+
sender: "AI",
|
|
608
|
+
recevier: mid,
|
|
609
|
+
message: "正在输入...",
|
|
610
|
+
id: "123456",
|
|
611
|
+
createdAt: getDataTime(-1),
|
|
612
|
+
extraInfo: null
|
|
613
|
+
};
|
|
614
|
+
} else {
|
|
615
|
+
return item;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
} else {
|
|
619
|
+
return historyMessageList.concat({
|
|
620
|
+
roomId: roomId,
|
|
621
|
+
sender: "AI",
|
|
622
|
+
recevier: mid,
|
|
623
|
+
message: "正在输入...",
|
|
624
|
+
id: "123456",
|
|
625
|
+
createdAt: getDataTime(-1),
|
|
626
|
+
extraInfo: null
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
setTimeout(()=>{
|
|
631
|
+
scrollToBottom();
|
|
632
|
+
}, 10);
|
|
633
|
+
//使用fetchEventSource接收数据
|
|
634
|
+
const eventSource = fetchEventSource(`${urllocation}/chat-service/public/v1.0/chat-with-ai/messages`, {
|
|
635
|
+
method: "POST",
|
|
636
|
+
headers: {
|
|
637
|
+
"Content-Type": "application/json",
|
|
638
|
+
Accept: "text/event-stream,application/json",
|
|
639
|
+
"X-Auth-Jwt": window.localStorage.getItem("usertoken") || "",
|
|
640
|
+
"Auth-Token": userData.token,
|
|
641
|
+
"X-Module-Id": userData.modules.find((ele)=>ele.short == "AIservice").id
|
|
642
|
+
},
|
|
643
|
+
body: data,
|
|
644
|
+
signal: ctrl.current.signal,
|
|
645
|
+
openWhenHidden: true,
|
|
646
|
+
onopen (res) {
|
|
647
|
+
console.info("eventSource open: ", res);
|
|
648
|
+
clearTimeout(receiveMessageTimer.current);
|
|
649
|
+
if (res.status >= 300) {
|
|
650
|
+
console.log("sdckjsdncskdcjsdc", res.status);
|
|
651
|
+
setFinished(true);
|
|
652
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
653
|
+
return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
|
|
654
|
+
});
|
|
655
|
+
ctrl.current.abort();
|
|
656
|
+
}
|
|
657
|
+
if (res.status == 200) {
|
|
658
|
+
setFinished(false);
|
|
659
|
+
}
|
|
660
|
+
if (res.status == 401) {
|
|
661
|
+
//身份认证未通过,从新请求新的token后再次发送请求
|
|
662
|
+
verifyJWT(urllocation).then(()=>{
|
|
663
|
+
console.log("重新请求");
|
|
664
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
665
|
+
return historyMessageList.filter((item)=>item.id != "123456" && item.id != "654321");
|
|
666
|
+
});
|
|
667
|
+
aiSendQuestions(type, obj, id);
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
if (res.status == 403) {
|
|
671
|
+
//暂无权限
|
|
672
|
+
console.log("暂无权限");
|
|
673
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
674
|
+
return historyMessageList.concat({
|
|
675
|
+
roomId: roomId,
|
|
676
|
+
sender: "AI",
|
|
677
|
+
recevier: mid,
|
|
678
|
+
message: "暂无权限",
|
|
679
|
+
id: "123456",
|
|
680
|
+
createdAt: "",
|
|
681
|
+
extraInfo: null
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
if (res.status == 429) {
|
|
686
|
+
//同一时间只允许进行一个对话。
|
|
687
|
+
}
|
|
688
|
+
if (res.status == 429) {
|
|
689
|
+
//每天问答的 Token 数必须小于等于 10 万。
|
|
690
|
+
sendGreetingMessage(5);
|
|
691
|
+
}
|
|
692
|
+
if (res.status == 500) {
|
|
693
|
+
// 系统错误,请稍后再试。
|
|
694
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
695
|
+
return historyMessageList.concat({
|
|
696
|
+
roomId: roomId,
|
|
697
|
+
sender: "AI",
|
|
698
|
+
recevier: mid,
|
|
699
|
+
message: "系统出错了,请稍后重试!",
|
|
700
|
+
id: "123456",
|
|
701
|
+
createdAt: "",
|
|
702
|
+
extraInfo: null
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
onerror (err) {
|
|
708
|
+
console.log(err, "dflkvdmfvlkdfv");
|
|
709
|
+
let state = err.response;
|
|
710
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
711
|
+
return historyMessageList.concat({
|
|
712
|
+
roomId: roomId,
|
|
713
|
+
sender: "AI",
|
|
714
|
+
recevier: mid,
|
|
715
|
+
message: "系统出错了,请稍后重试!",
|
|
716
|
+
id: "123456",
|
|
717
|
+
createdAt: "",
|
|
718
|
+
extraInfo: null
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
},
|
|
722
|
+
onmessage (event) {
|
|
723
|
+
//识别的内容
|
|
724
|
+
// console.log("eventSource msg: ", event.data);
|
|
725
|
+
let msg = JSON.parse(event.data);
|
|
726
|
+
if (msg.message) {
|
|
727
|
+
content = content + msg.message;
|
|
728
|
+
renderAiAnswer(msg, id, type);
|
|
729
|
+
}
|
|
730
|
+
if (msg.finished) {
|
|
731
|
+
setFinished(true); //发送结束
|
|
732
|
+
console.log(content, JSON.parse(data), 'sdklcksdlcms');
|
|
733
|
+
testLabQuestion(JSON.parse(data).message, content, '');
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
onclose () {
|
|
737
|
+
setFinished(true); //发送结束
|
|
738
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
739
|
+
return historyMessageList.filter((item)=>item.id != "123456");
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
};
|
|
744
|
+
//渲染AI回答
|
|
745
|
+
const renderAiAnswer = (msg, message_id, type)=>{
|
|
746
|
+
// console.log(aiSendQuestions().abort(),'slkdsdsdsd')
|
|
747
|
+
let obj = msg;
|
|
748
|
+
let id = msg.messageId;
|
|
749
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
750
|
+
let list1 = historyMessageList;
|
|
751
|
+
//删除临时数据
|
|
752
|
+
list1 = list1.filter((item)=>{
|
|
753
|
+
return item.id != "123456";
|
|
754
|
+
});
|
|
755
|
+
//重新生成答案时,使用原来的消息
|
|
756
|
+
if (message_id != undefined) {
|
|
757
|
+
list1 = list1.filter((item)=>{
|
|
758
|
+
return item.id != message_id;
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
let list = historyMessageList.filter((item)=>{
|
|
762
|
+
return item.id == id;
|
|
763
|
+
});
|
|
764
|
+
let message = "";
|
|
765
|
+
if (list.length == 0) {
|
|
766
|
+
message = obj.message;
|
|
767
|
+
let newHistoryMessageList = list1.concat({
|
|
768
|
+
roomId: roomId,
|
|
769
|
+
sender: "AI",
|
|
770
|
+
recevier: mid,
|
|
771
|
+
message: message,
|
|
772
|
+
id: id,
|
|
773
|
+
upvoted: false,
|
|
774
|
+
downvoted: false,
|
|
775
|
+
createdAt: getDataTime(-1),
|
|
776
|
+
extraInfo: type == 1 ? JSON.stringify([
|
|
777
|
+
{
|
|
778
|
+
key: "isVoteMessage",
|
|
779
|
+
value: true
|
|
780
|
+
}
|
|
781
|
+
]) : null
|
|
782
|
+
});
|
|
783
|
+
return newHistoryMessageList;
|
|
784
|
+
} else {
|
|
785
|
+
let newHistoryMessageList2 = list1.map((item)=>{
|
|
786
|
+
message = item.message + obj.message;
|
|
787
|
+
if (item.id == id) {
|
|
788
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
789
|
+
message: message
|
|
790
|
+
});
|
|
791
|
+
} else {
|
|
792
|
+
return item;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
return newHistoryMessageList2;
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
setTimeout(()=>{
|
|
799
|
+
scrollToBottom();
|
|
800
|
+
}, 10);
|
|
801
|
+
};
|
|
802
|
+
//问题记录到实验报告中
|
|
803
|
+
const testLabQuestion = (title, content, teachId)=>{
|
|
804
|
+
console.log(title, content, '记录到实验报告中');
|
|
805
|
+
if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4)) {
|
|
806
|
+
http.post(`${urllocation}/sandboxes/public/v1.0/labquestion`, {
|
|
807
|
+
title: title,
|
|
808
|
+
content: content,
|
|
809
|
+
teachId: teachId != undefined ? teachId : chatWith.uid | mid,
|
|
810
|
+
stepId: stepId,
|
|
811
|
+
stepIds: stepIds
|
|
812
|
+
}, {
|
|
813
|
+
headers: {
|
|
814
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
815
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
//语音转文字
|
|
821
|
+
const speechToText = ()=>{
|
|
822
|
+
http.post(`${urllocation}/chat-service/public/v1.0/speech:recognize`, {
|
|
823
|
+
audio: bese64String
|
|
824
|
+
}, {
|
|
825
|
+
headers: {
|
|
826
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "AIservice").id,
|
|
827
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
828
|
+
}
|
|
829
|
+
}).then((res)=>{
|
|
830
|
+
setVoiceRecordingStatus(3);
|
|
831
|
+
if (res.data) {
|
|
832
|
+
setKeyWord(res.data.text);
|
|
833
|
+
resettingBottomHei();
|
|
834
|
+
}
|
|
835
|
+
}).catch((err)=>{
|
|
836
|
+
setKeyWord("");
|
|
837
|
+
setVoiceRecordingStatus(3);
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
//创建聊天室
|
|
841
|
+
const createRooms = (uid)=>{
|
|
842
|
+
return http.post(`${urllocation}/chat-service/public/v1.0/rooms`, {
|
|
843
|
+
chatWith: uid
|
|
844
|
+
}, {
|
|
845
|
+
headers: {
|
|
846
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
847
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
//获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
|
|
852
|
+
const getHistoryMessage = (pageNum, flag)=>{
|
|
853
|
+
console.log(pageNum, flag, "重新加载数据2222");
|
|
854
|
+
if (roomId == "") return;
|
|
855
|
+
return http.get(`${urllocation}/chat-service/public/v1.0/history-messages`, {
|
|
856
|
+
params: {
|
|
857
|
+
roomId: roomId,
|
|
858
|
+
page: pageNum != undefined && pageNum != -1 ? pageNum : 1,
|
|
859
|
+
maxPageSize: 30,
|
|
860
|
+
direction: "desc"
|
|
861
|
+
},
|
|
862
|
+
headers: {
|
|
863
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
864
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
865
|
+
}
|
|
866
|
+
}).then((res)=>{
|
|
867
|
+
if (res.data.messages.length > 0) {
|
|
868
|
+
clearTimeout(listTimer.current);
|
|
869
|
+
let last_id = "";
|
|
870
|
+
let total = res.data.total;
|
|
871
|
+
let maxPageSize = 30;
|
|
872
|
+
let dataList = res.data.messages.reverse();
|
|
873
|
+
setPageCount(Math.ceil(total / maxPageSize));
|
|
874
|
+
let newHistoryMessageList = [];
|
|
875
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
876
|
+
if (flag != 1 && historyMessageList.length > 0) {
|
|
877
|
+
if (flag == 2) {
|
|
878
|
+
last_id = historyMessageList[historyMessageList.length - 1].id;
|
|
879
|
+
} else {
|
|
880
|
+
last_id = historyMessageList[0].id;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
newHistoryMessageList = [];
|
|
884
|
+
//查找历史记录flag==1
|
|
885
|
+
if (pageNum == 1 || flag == 1 || flag == 3) {
|
|
886
|
+
newHistoryMessageList = dataList;
|
|
887
|
+
} else if (flag == 2) {
|
|
888
|
+
//下拉加载
|
|
889
|
+
newHistoryMessageList = historyMessageList.concat(dataList);
|
|
890
|
+
} else {
|
|
891
|
+
newHistoryMessageList = dataList.concat(historyMessageList);
|
|
892
|
+
}
|
|
893
|
+
let res = new Map();
|
|
894
|
+
newHistoryMessageList = newHistoryMessageList.filter((a)=>!res.has(a.id) && res.set(a.id, 1));
|
|
895
|
+
return newHistoryMessageList;
|
|
896
|
+
});
|
|
897
|
+
//如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
|
|
898
|
+
try {
|
|
899
|
+
if (stepIds != undefined && stepIds != '' && (showType == 3 || showType == 4) && roomList.length > 0 && roomList[0].roomId != roomId) {
|
|
900
|
+
fildChatRecords(newHistoryMessageList);
|
|
901
|
+
}
|
|
902
|
+
} catch (error) {}
|
|
903
|
+
if (flag != 1) {
|
|
904
|
+
setLastId(last_id);
|
|
905
|
+
}
|
|
906
|
+
if (pageNum == 1 && flag != 1 || flag == 3) {
|
|
907
|
+
scrollToBottom();
|
|
908
|
+
} else {
|
|
909
|
+
console.log("滚动到相应为止3333");
|
|
910
|
+
scrollTo("li_flag");
|
|
911
|
+
}
|
|
912
|
+
setGreetingMessage(true);
|
|
913
|
+
//召唤老师回答
|
|
914
|
+
console.log(problem, 8888888);
|
|
915
|
+
if (problem != undefined && problem.user != undefined && problem.question != undefined) {
|
|
916
|
+
console.log(problem, 77777);
|
|
917
|
+
sendToTeacher(1);
|
|
918
|
+
}
|
|
919
|
+
} else {
|
|
920
|
+
setPageCount(0);
|
|
921
|
+
setGreetingMessage(true);
|
|
922
|
+
setLoading(false);
|
|
923
|
+
setHistoryMessageList([]);
|
|
924
|
+
//召唤老师回答
|
|
925
|
+
console.log(problem, 8888888);
|
|
926
|
+
if (problem != undefined && problem.user != undefined && problem.question != undefined) {
|
|
927
|
+
console.log(problem, 77777);
|
|
928
|
+
sendToTeacher(1);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}).catch((res)=>{
|
|
932
|
+
setLoading(false);
|
|
933
|
+
});
|
|
934
|
+
};
|
|
935
|
+
//在聊天对话框中查找需要记录的问题及答案
|
|
936
|
+
const fildChatRecords = (newHistoryMessageList)=>{
|
|
937
|
+
//1、找到对应的聊天室
|
|
938
|
+
//2、找到与老师对话的新聊天
|
|
939
|
+
//3、保存聊天到实验报告
|
|
940
|
+
console.log('查找聊天111', chatObj);
|
|
941
|
+
let room = chatObj.filter((item)=>item.roomId == roomId);
|
|
942
|
+
if (room.length > 0) {
|
|
943
|
+
console.log(room, 'dfvdfvdfvdfv');
|
|
944
|
+
let roomIDnumber = room[0].roomId;
|
|
945
|
+
let chatID = room[0].id;
|
|
946
|
+
let index = -1;
|
|
947
|
+
newHistoryMessageList.forEach((item, i)=>{
|
|
948
|
+
console.log(item, item.id, 'lskdcmsldksdcsdc');
|
|
949
|
+
if (item.id == chatID) {
|
|
950
|
+
index = i;
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
//有新的消息
|
|
955
|
+
if (index != -1) {
|
|
956
|
+
let newMessage = newHistoryMessageList.slice(index);
|
|
957
|
+
console.log(newMessage, '需要记录的聊天');
|
|
958
|
+
//1、查找 sender发送者
|
|
959
|
+
let objList = [];
|
|
960
|
+
let obj = {};
|
|
961
|
+
let position = -1;
|
|
962
|
+
newMessage.map((item, i)=>{
|
|
963
|
+
if (item.sender == mid && position != i) {
|
|
964
|
+
objList.push(obj);
|
|
965
|
+
obj = {};
|
|
966
|
+
}
|
|
967
|
+
//发送者
|
|
968
|
+
if (item.sender == mid) {
|
|
969
|
+
obj.title = item.message;
|
|
970
|
+
position = i;
|
|
971
|
+
}
|
|
972
|
+
if (item.sender != mid) {
|
|
973
|
+
obj.con = item.message;
|
|
974
|
+
obj.teachId = item.receiver;
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
//需要保存的记录
|
|
978
|
+
objList = objList.filter((item)=>item.title != undefined);
|
|
979
|
+
objList.map((item)=>{
|
|
980
|
+
//保存聊天记录
|
|
981
|
+
testLabQuestion(item.title, item.con, item.teachId);
|
|
982
|
+
//删除已经保存的记录
|
|
983
|
+
setChatObj((list)=>{
|
|
984
|
+
return list.filter((a)=>a.roomId != roomIDnumber);
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
console.log(objList, 'sdkcjnsdkjcsd');
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
//点赞消息
|
|
992
|
+
const likeMessage = (id, state)=>{
|
|
993
|
+
let url = "";
|
|
994
|
+
//点赞状态
|
|
995
|
+
if (!state) {
|
|
996
|
+
url = `${urllocation}/chat-service/public/v1.0/history-messages:upvote`;
|
|
997
|
+
} else {
|
|
998
|
+
url = `${urllocation}/chat-service/public/v1.0/history-messages:cancelUpvote`;
|
|
999
|
+
}
|
|
1000
|
+
http.post(url, {
|
|
1001
|
+
messageId: id
|
|
1002
|
+
}, {
|
|
1003
|
+
headers: {
|
|
1004
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
1005
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
1006
|
+
}
|
|
1007
|
+
}).then((res)=>{
|
|
1008
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1009
|
+
let list = historyMessageList;
|
|
1010
|
+
list = list.map((item)=>{
|
|
1011
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
1012
|
+
upvoted: item.id == id ? !state : item.upvoted,
|
|
1013
|
+
downvoted: item.id == id && !state ? state : item.downvoted
|
|
1014
|
+
});
|
|
1015
|
+
});
|
|
1016
|
+
return list;
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
};
|
|
1020
|
+
//踩
|
|
1021
|
+
const disagreeMessage = (id, state)=>{
|
|
1022
|
+
let url = "";
|
|
1023
|
+
//点赞状态
|
|
1024
|
+
if (!state) {
|
|
1025
|
+
url = `${urllocation}/chat-service/public/v1.0/history-messages:downvote`;
|
|
1026
|
+
} else {
|
|
1027
|
+
url = `${urllocation}/chat-service/public/v1.0/history-messages:cancelDownvote`;
|
|
1028
|
+
}
|
|
1029
|
+
http.post(url, {
|
|
1030
|
+
messageId: id
|
|
1031
|
+
}, {
|
|
1032
|
+
headers: {
|
|
1033
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
1034
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
1035
|
+
}
|
|
1036
|
+
}).then((res)=>{
|
|
1037
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1038
|
+
let list = historyMessageList;
|
|
1039
|
+
list = list.map((item)=>{
|
|
1040
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
1041
|
+
downvoted: item.id == id ? !state : item.downvoted,
|
|
1042
|
+
upvoted: item.id == id && !state ? state : item.upvoted
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
return list;
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
//获取问题列表flag ==1 是问候消息 2,搜索列表 展示相关问题
|
|
1050
|
+
const getQuestiionsList = (value, flag)=>{
|
|
1051
|
+
let data = {};
|
|
1052
|
+
if (flag == 1) {
|
|
1053
|
+
data = {
|
|
1054
|
+
page: 1,
|
|
1055
|
+
maxPageSize: 5
|
|
1056
|
+
};
|
|
1057
|
+
} else {
|
|
1058
|
+
data = {
|
|
1059
|
+
page: 1,
|
|
1060
|
+
maxPageSize: 4,
|
|
1061
|
+
question: value
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
http.get(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions`, {
|
|
1065
|
+
params: data,
|
|
1066
|
+
headers: {
|
|
1067
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
|
|
1068
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
1069
|
+
}
|
|
1070
|
+
}).then((res)=>{
|
|
1071
|
+
if (res.data.questions) {
|
|
1072
|
+
if (flag == 1) {
|
|
1073
|
+
setHotQuestionsList(res.data.questions);
|
|
1074
|
+
} else {
|
|
1075
|
+
setQuestionsList(res.data.questions);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
//获取老师列表
|
|
1081
|
+
const getTeacherList = (keyWord)=>{
|
|
1082
|
+
http.get(`${urllocation}/chat-service/public/v1.0/teachers`, {
|
|
1083
|
+
params: {
|
|
1084
|
+
name: keyWord
|
|
1085
|
+
},
|
|
1086
|
+
headers: {
|
|
1087
|
+
"x-module-id": userData.modules.find((ele)=>ele.short == "TeacherAnswer").id,
|
|
1088
|
+
"x-auth-jwt": window.localStorage.getItem("usertoken") || ""
|
|
1089
|
+
}
|
|
1090
|
+
}).then((res)=>{
|
|
1091
|
+
console.log(res);
|
|
1092
|
+
if (res.data) {
|
|
1093
|
+
setTeacherList(res.data.teachers);
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
//设置滚动条滚动到底部
|
|
1098
|
+
const scrollToBottom = ()=>{
|
|
1099
|
+
console.log("滚动条滚动到底部");
|
|
1100
|
+
const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
1101
|
+
if (container) {
|
|
1102
|
+
container.scrollTop = container.scrollHeight;
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
const scrollTo = (id)=>{
|
|
1106
|
+
console.log(id, "滚动到指定位置");
|
|
1107
|
+
const container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
1108
|
+
const container2 = document.getElementById(id);
|
|
1109
|
+
// clearTimeout(listTimer.current)
|
|
1110
|
+
if (container && container2) {
|
|
1111
|
+
// container.scrollTop = container2.scrollHeight;
|
|
1112
|
+
// if(container2.scrollTop == 0){
|
|
1113
|
+
container.scrollTop = 60;
|
|
1114
|
+
setTimeout(()=>{
|
|
1115
|
+
let top = showType == 1 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
|
|
1116
|
+
$(`#${showType == 1 ? "chat_content" : "chat_content_modal"}`).animate({
|
|
1117
|
+
scrollTop: top
|
|
1118
|
+
}, 0);
|
|
1119
|
+
}, 10);
|
|
1120
|
+
// }
|
|
1121
|
+
// clearTimeout(listTimer.current)
|
|
1122
|
+
setLoading(false);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
// 获取新的JWT
|
|
1126
|
+
const verifyJWT = (url)=>{
|
|
1127
|
+
return new Promise((resolve)=>{
|
|
1128
|
+
http.get(`${url}/regusers/login/Refreshtoken`).then((res)=>{
|
|
1129
|
+
if (res.data.code == 200) {
|
|
1130
|
+
window.localStorage.setItem("usertoken", res.data.data);
|
|
1131
|
+
resolve(res.data.data);
|
|
1132
|
+
} else {
|
|
1133
|
+
throw new Error(res.data.code);
|
|
1134
|
+
}
|
|
1135
|
+
}).catch((err)=>{
|
|
1136
|
+
resolve(err);
|
|
1137
|
+
});
|
|
1138
|
+
});
|
|
1139
|
+
};
|
|
1140
|
+
//渲染头部
|
|
1141
|
+
const renderHeader = ()=>{
|
|
1142
|
+
if (showType == 4) {
|
|
1143
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
1144
|
+
className: styles.top,
|
|
1145
|
+
children: [
|
|
1146
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1147
|
+
className: styles.user,
|
|
1148
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1149
|
+
children: "智能回答"
|
|
1150
|
+
})
|
|
1151
|
+
}),
|
|
1152
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1153
|
+
className: styles.operate,
|
|
1154
|
+
children: [
|
|
1155
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1156
|
+
onClick: ()=>{
|
|
1157
|
+
setShowHistory(true);
|
|
1158
|
+
},
|
|
1159
|
+
children: /*#__PURE__*/ _jsx(CustomRecord, {})
|
|
1160
|
+
}),
|
|
1161
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1162
|
+
className: styles.line
|
|
1163
|
+
}),
|
|
1164
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1165
|
+
onClick: ()=>{
|
|
1166
|
+
onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
|
|
1167
|
+
setShowType(3);
|
|
1168
|
+
},
|
|
1169
|
+
children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
|
|
1170
|
+
}),
|
|
1171
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1172
|
+
onClick: ()=>{
|
|
1173
|
+
onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
|
|
1174
|
+
setShowType(3);
|
|
1175
|
+
},
|
|
1176
|
+
children: /*#__PURE__*/ _jsx(CloseOutlined, {})
|
|
1177
|
+
})
|
|
1178
|
+
]
|
|
1179
|
+
})
|
|
1180
|
+
]
|
|
1181
|
+
});
|
|
1182
|
+
} else if (showType == 3) {
|
|
1183
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
1184
|
+
className: styles.top,
|
|
1185
|
+
children: [
|
|
1186
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1187
|
+
className: styles.user,
|
|
1188
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1189
|
+
children: "智能回答"
|
|
1190
|
+
})
|
|
1191
|
+
}),
|
|
1192
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1193
|
+
className: styles.operate,
|
|
1194
|
+
children: [
|
|
1195
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1196
|
+
onClick: ()=>{
|
|
1197
|
+
setShowHistory(true);
|
|
1198
|
+
},
|
|
1199
|
+
children: /*#__PURE__*/ _jsx(CustomRecord, {})
|
|
1200
|
+
}),
|
|
1201
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1202
|
+
className: styles.line
|
|
1203
|
+
}),
|
|
1204
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1205
|
+
onClick: ()=>{
|
|
1206
|
+
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
1207
|
+
setShowType(4);
|
|
1208
|
+
},
|
|
1209
|
+
children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
|
|
1210
|
+
}),
|
|
1211
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1212
|
+
className: "lianxiren21",
|
|
1213
|
+
onClick: ()=>{
|
|
1214
|
+
setShowContacts(true);
|
|
1215
|
+
},
|
|
1216
|
+
children: /*#__PURE__*/ _jsx(CustomContacts, {})
|
|
1217
|
+
})
|
|
1218
|
+
]
|
|
1219
|
+
})
|
|
1220
|
+
]
|
|
1221
|
+
});
|
|
1222
|
+
} else {
|
|
1223
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
1224
|
+
className: styles.top,
|
|
1225
|
+
children: [
|
|
1226
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1227
|
+
className: styles.user,
|
|
1228
|
+
children: /*#__PURE__*/ _jsxs("p", {
|
|
1229
|
+
children: [
|
|
1230
|
+
showType == 1 && /*#__PURE__*/ _jsx("i", {
|
|
1231
|
+
className: "lianxiren21",
|
|
1232
|
+
onClick: ()=>{
|
|
1233
|
+
setShowContacts(true);
|
|
1234
|
+
},
|
|
1235
|
+
children: /*#__PURE__*/ _jsx(CustomContacts, {})
|
|
1236
|
+
}),
|
|
1237
|
+
"智能回答"
|
|
1238
|
+
]
|
|
1239
|
+
})
|
|
1240
|
+
}),
|
|
1241
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1242
|
+
className: styles.operate,
|
|
1243
|
+
children: [
|
|
1244
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1245
|
+
className: "_lishixiao22",
|
|
1246
|
+
onClick: ()=>{
|
|
1247
|
+
setShowHistory(true);
|
|
1248
|
+
},
|
|
1249
|
+
children: /*#__PURE__*/ _jsx(CustomRecord, {})
|
|
1250
|
+
}),
|
|
1251
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1252
|
+
className: styles.line
|
|
1253
|
+
}),
|
|
1254
|
+
showType == 1 ? /*#__PURE__*/ _jsx("i", {
|
|
1255
|
+
onClick: ()=>{
|
|
1256
|
+
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
1257
|
+
// switchDialogBox(3, true);
|
|
1258
|
+
setShowType(2);
|
|
1259
|
+
},
|
|
1260
|
+
children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
|
|
1261
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
1262
|
+
onClick: ()=>{
|
|
1263
|
+
onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
|
|
1264
|
+
// switchDialogBox(1, true);
|
|
1265
|
+
setShowType(1);
|
|
1266
|
+
},
|
|
1267
|
+
children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
|
|
1268
|
+
}),
|
|
1269
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1270
|
+
onClick: onCancel,
|
|
1271
|
+
children: /*#__PURE__*/ _jsx(CloseOutlined, {})
|
|
1272
|
+
})
|
|
1273
|
+
]
|
|
1274
|
+
})
|
|
1275
|
+
]
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
//重置底部输入框高度
|
|
1280
|
+
const resettingBottomHei = ()=>{
|
|
1281
|
+
setTimeout(()=>{
|
|
1282
|
+
if (showType == 1 || showType == 3) {
|
|
1283
|
+
let hei = document.getElementById("Drawer_buttom").offsetHeight;
|
|
1284
|
+
setButtomHei(hei);
|
|
1285
|
+
} else {
|
|
1286
|
+
let hei = document.getElementById("Drawer_buttom_modal").offsetHeight;
|
|
1287
|
+
setButtomHei(hei);
|
|
1288
|
+
}
|
|
1289
|
+
}, 50);
|
|
1290
|
+
};
|
|
1291
|
+
//切换聊天室 type == renew ,存在新消息
|
|
1292
|
+
const switchChatRoom = (id, type)=>{
|
|
1293
|
+
if (type == "renew") {
|
|
1294
|
+
getHistoryMessage(1, 3);
|
|
1295
|
+
}
|
|
1296
|
+
setRoomId(id);
|
|
1297
|
+
readMessage(id, urllocation, userData, http);
|
|
1298
|
+
};
|
|
1299
|
+
const saveContactsList = (list)=>{
|
|
1300
|
+
if (list != undefined) {
|
|
1301
|
+
setRoomList(list);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
//渲染问答
|
|
1305
|
+
const renderQuestion = ()=>{
|
|
1306
|
+
// console.log(mid, historyMessageList, "ddkfdscksdcs");
|
|
1307
|
+
if (historyMessageList.length > 0) {
|
|
1308
|
+
// let historyData = "";
|
|
1309
|
+
// let showData = true;
|
|
1310
|
+
return /*#__PURE__*/ _jsx("ul", {
|
|
1311
|
+
className: styles.message_con,
|
|
1312
|
+
children: historyMessageList.map((item, i)=>{
|
|
1313
|
+
// console.log(item.message);
|
|
1314
|
+
let message = item.message;
|
|
1315
|
+
let li;
|
|
1316
|
+
// 是否需要显示日期
|
|
1317
|
+
let itemIndex = historyMessageList.findIndex((ite)=>ite.id === item.id);
|
|
1318
|
+
let time = "";
|
|
1319
|
+
if (itemIndex <= 0) {
|
|
1320
|
+
//第一项
|
|
1321
|
+
time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
|
|
1322
|
+
} else {
|
|
1323
|
+
//非第一项 与上一项进行对比
|
|
1324
|
+
let beforeTime = historyMessageList[itemIndex - 1].createdAt;
|
|
1325
|
+
//判断与上一条数据 是否跨天
|
|
1326
|
+
if (dayjs(beforeTime).format("YYYY-MM-DD") !== dayjs(item.createdAt).format("YYYY-MM-DD")) {
|
|
1327
|
+
time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
|
|
1328
|
+
} else {
|
|
1329
|
+
//没有跨天 判断是否相隔超过10分钟
|
|
1330
|
+
if (dayjs(item.createdAt).valueOf() - dayjs(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
1331
|
+
time = dayjs(item.createdAt).format("HH:mm");
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
let dataTime = time;
|
|
1336
|
+
if (item.sender == mid) {
|
|
1337
|
+
//只有引用和复制功能
|
|
1338
|
+
li = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1339
|
+
children: [
|
|
1340
|
+
dataTime ? /*#__PURE__*/ _jsx("li", {
|
|
1341
|
+
className: styles.time,
|
|
1342
|
+
children: dataTime
|
|
1343
|
+
}) : "",
|
|
1344
|
+
/*#__PURE__*/ _jsxs("li", {
|
|
1345
|
+
className: styles.left,
|
|
1346
|
+
id: lastId == item.id ? "li_flag" : "",
|
|
1347
|
+
children: [
|
|
1348
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1349
|
+
className: styles.main,
|
|
1350
|
+
children: [
|
|
1351
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1352
|
+
className: styles.main_content,
|
|
1353
|
+
children: [
|
|
1354
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1355
|
+
className: styles.operate_modal,
|
|
1356
|
+
children: /*#__PURE__*/ _jsxs("p", {
|
|
1357
|
+
className: styles.operate,
|
|
1358
|
+
children: [
|
|
1359
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1360
|
+
className: "yinyong_quote1",
|
|
1361
|
+
onClick: ()=>{
|
|
1362
|
+
setCitationContent({
|
|
1363
|
+
content: item.message,
|
|
1364
|
+
id: item.id
|
|
1365
|
+
});
|
|
1366
|
+
resettingBottomHei();
|
|
1367
|
+
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
1368
|
+
},
|
|
1369
|
+
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
1370
|
+
}),
|
|
1371
|
+
copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
|
|
1372
|
+
className: `tongyong-xuanzhongdui`,
|
|
1373
|
+
children: /*#__PURE__*/ _jsx(CustomDuihao, {})
|
|
1374
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
1375
|
+
className: "fuzhi21",
|
|
1376
|
+
onClick: ()=>{
|
|
1377
|
+
let bol = copyText(item.message);
|
|
1378
|
+
if (bol) {
|
|
1379
|
+
let obj = copyTextOBJ;
|
|
1380
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1381
|
+
obj.push(item.id);
|
|
1382
|
+
setCopyTextObj(obj);
|
|
1383
|
+
}
|
|
1384
|
+
setTimeout(()=>{
|
|
1385
|
+
let obj = copyTextOBJ;
|
|
1386
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1387
|
+
setCopyTextObj(obj);
|
|
1388
|
+
}, 3000);
|
|
1389
|
+
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
1390
|
+
},
|
|
1391
|
+
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
1392
|
+
})
|
|
1393
|
+
]
|
|
1394
|
+
})
|
|
1395
|
+
}),
|
|
1396
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1397
|
+
className: styles.content,
|
|
1398
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1399
|
+
dangerouslySetInnerHTML: {
|
|
1400
|
+
__html: remarkable.render(message)
|
|
1401
|
+
},
|
|
1402
|
+
className: styles.content_child
|
|
1403
|
+
})
|
|
1404
|
+
})
|
|
1405
|
+
]
|
|
1406
|
+
}),
|
|
1407
|
+
//引用消息
|
|
1408
|
+
item.quotedMessage != "" && item.quotedMessage != null && item.quotedMessage != undefined ? /*#__PURE__*/ _jsx("div", {
|
|
1409
|
+
className: styles.citation_content,
|
|
1410
|
+
children: getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
1411
|
+
overlayClassName: styles.popover_main_content,
|
|
1412
|
+
title: item.quotedMessage,
|
|
1413
|
+
placement: "leftTop",
|
|
1414
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1415
|
+
children: item.quotedMessage
|
|
1416
|
+
})
|
|
1417
|
+
}) : /*#__PURE__*/ _jsx("p", {
|
|
1418
|
+
children: item.quotedMessage
|
|
1419
|
+
})
|
|
1420
|
+
}) : ""
|
|
1421
|
+
]
|
|
1422
|
+
}),
|
|
1423
|
+
showType == 2 || showType == 4 ? /*#__PURE__*/ _jsx("div", {
|
|
1424
|
+
className: styles.head_sculpture,
|
|
1425
|
+
style: {
|
|
1426
|
+
marginLeft: "12px"
|
|
1427
|
+
},
|
|
1428
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
1429
|
+
src: userData.avatar
|
|
1430
|
+
})
|
|
1431
|
+
}) : ""
|
|
1432
|
+
]
|
|
1433
|
+
}, item.id)
|
|
1434
|
+
]
|
|
1435
|
+
});
|
|
1436
|
+
} else {
|
|
1437
|
+
//获取用户头像
|
|
1438
|
+
let headImg = '';
|
|
1439
|
+
let chatWindow = roomList.filter((item)=>item.roomId == roomId);
|
|
1440
|
+
if (chatWindow.length > 0 && chatWindow[0].headImg != '') {
|
|
1441
|
+
headImg = chatWindow[0].headImg;
|
|
1442
|
+
}
|
|
1443
|
+
//是否在智能客服窗口
|
|
1444
|
+
let isAiChatWindow = chatWindow[0].sender == 'AI' ? true : false;
|
|
1445
|
+
li = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1446
|
+
children: [
|
|
1447
|
+
dataTime ? /*#__PURE__*/ _jsx("li", {
|
|
1448
|
+
className: styles.time,
|
|
1449
|
+
children: dataTime
|
|
1450
|
+
}) : "",
|
|
1451
|
+
/*#__PURE__*/ _jsxs("li", {
|
|
1452
|
+
className: styles.right,
|
|
1453
|
+
id: lastId == item.id ? "li_flag" : "",
|
|
1454
|
+
children: [
|
|
1455
|
+
showType == 2 || showType == 4 && /*#__PURE__*/ _jsx("div", {
|
|
1456
|
+
className: styles.head_sculpture,
|
|
1457
|
+
style: {
|
|
1458
|
+
marginRight: "12px"
|
|
1459
|
+
},
|
|
1460
|
+
children: isAiChatWindow ? item.extraInfo == null ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
|
|
1461
|
+
src: knowledge_icon
|
|
1462
|
+
}) : /*#__PURE__*/ _jsx("img", {
|
|
1463
|
+
src: headImg
|
|
1464
|
+
})
|
|
1465
|
+
}),
|
|
1466
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1467
|
+
className: styles.main,
|
|
1468
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
1469
|
+
className: styles.main_content,
|
|
1470
|
+
children: [
|
|
1471
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1472
|
+
className: styles.operate_modal,
|
|
1473
|
+
children: historyMessageList.length - 1 == i && item.extraInfo == null || item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs("p", {
|
|
1474
|
+
className: styles.operate,
|
|
1475
|
+
children: [
|
|
1476
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1477
|
+
className: styles.ask_question,
|
|
1478
|
+
onClick: ()=>{
|
|
1479
|
+
setAnswerMode(1);
|
|
1480
|
+
setProblem({
|
|
1481
|
+
question: historyMessageList[i - 1].message,
|
|
1482
|
+
user: problem.user
|
|
1483
|
+
});
|
|
1484
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1485
|
+
let newHistoryMessageList = historyMessageList.concat({
|
|
1486
|
+
id: -1,
|
|
1487
|
+
roomId: roomId,
|
|
1488
|
+
sender: "AI",
|
|
1489
|
+
recevier: mid,
|
|
1490
|
+
message: "请在输入框中输入您要召唤的老师的姓名",
|
|
1491
|
+
createdAt: getDataTime(-1),
|
|
1492
|
+
findTeacher: true
|
|
1493
|
+
});
|
|
1494
|
+
return newHistoryMessageList;
|
|
1495
|
+
});
|
|
1496
|
+
scrollToBottom();
|
|
1497
|
+
},
|
|
1498
|
+
children: "召唤老师回答"
|
|
1499
|
+
}),
|
|
1500
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1501
|
+
className: "yinyong_quote1",
|
|
1502
|
+
onClick: ()=>{
|
|
1503
|
+
setCitationContent({
|
|
1504
|
+
content: item.message,
|
|
1505
|
+
id: item.id
|
|
1506
|
+
});
|
|
1507
|
+
resettingBottomHei();
|
|
1508
|
+
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
1509
|
+
console.log("引用222222");
|
|
1510
|
+
},
|
|
1511
|
+
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
1512
|
+
}),
|
|
1513
|
+
copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
|
|
1514
|
+
className: `tongyong-xuanzhongdui`,
|
|
1515
|
+
children: /*#__PURE__*/ _jsx(CustomDuihao, {})
|
|
1516
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
1517
|
+
className: "fuzhi21",
|
|
1518
|
+
onClick: ()=>{
|
|
1519
|
+
let bol = copyText(item.message);
|
|
1520
|
+
if (bol) {
|
|
1521
|
+
let obj = copyTextOBJ;
|
|
1522
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1523
|
+
obj.push(item.id);
|
|
1524
|
+
setCopyTextObj(obj);
|
|
1525
|
+
}
|
|
1526
|
+
setTimeout(()=>{
|
|
1527
|
+
let obj = copyTextOBJ;
|
|
1528
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1529
|
+
setCopyTextObj(obj);
|
|
1530
|
+
}, 3000);
|
|
1531
|
+
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
1532
|
+
},
|
|
1533
|
+
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
1534
|
+
}),
|
|
1535
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1536
|
+
children: "|"
|
|
1537
|
+
}),
|
|
1538
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1539
|
+
className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
|
|
1540
|
+
onClick: ()=>{
|
|
1541
|
+
likeMessage(item.id, item.upvoted);
|
|
1542
|
+
console.log("判断是AI还是智能回答", item);
|
|
1543
|
+
//只有最后一条回答,支持发送点赞或踩
|
|
1544
|
+
if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
1545
|
+
console.log("判断是AI还是智能回答", item);
|
|
1546
|
+
if (!item.extraInfo && item.sender == "AI") {
|
|
1547
|
+
aiSendQuestions(1, {
|
|
1548
|
+
roomId: roomId,
|
|
1549
|
+
message: "你给出的答案我非常满意,赞!",
|
|
1550
|
+
quotedMessage: "",
|
|
1551
|
+
regenerate: false,
|
|
1552
|
+
generateUpvoteOrDownvoteMessage: true
|
|
1553
|
+
}, 1);
|
|
1554
|
+
} else {
|
|
1555
|
+
console.log("AI回答2255555");
|
|
1556
|
+
sendGreetingMessage(2);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
children: /*#__PURE__*/ _jsx(CustomLike, {})
|
|
1561
|
+
}),
|
|
1562
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1563
|
+
className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
|
|
1564
|
+
onClick: ()=>{
|
|
1565
|
+
disagreeMessage(item.id, item.downvoted);
|
|
1566
|
+
//只有最后一条回答,支持发送点赞或踩
|
|
1567
|
+
console.log(item, "dlfkvmdflkv");
|
|
1568
|
+
if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
1569
|
+
if (!item.extraInfo && item.sender == "AI") {
|
|
1570
|
+
aiSendQuestions(1, {
|
|
1571
|
+
roomId: roomId,
|
|
1572
|
+
message: "你给出的答案很糟糕,我不满意,踩!",
|
|
1573
|
+
quotedMessage: "",
|
|
1574
|
+
regenerate: false,
|
|
1575
|
+
generateUpvoteOrDownvoteMessage: true
|
|
1576
|
+
}, 1);
|
|
1577
|
+
} else {
|
|
1578
|
+
sendGreetingMessage(3);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
children: /*#__PURE__*/ _jsx(CustomDislike, {})
|
|
1583
|
+
})
|
|
1584
|
+
]
|
|
1585
|
+
})
|
|
1586
|
+
}),
|
|
1587
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1588
|
+
className: styles.content,
|
|
1589
|
+
children: [
|
|
1590
|
+
/*#__PURE__*/ _jsx("p", {
|
|
1591
|
+
dangerouslySetInnerHTML: {
|
|
1592
|
+
__html: remarkable.render(message)
|
|
1593
|
+
},
|
|
1594
|
+
className: styles.content_child
|
|
1595
|
+
}),
|
|
1596
|
+
item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" ? /*#__PURE__*/ _jsx("ul", {
|
|
1597
|
+
className: styles.association_problem,
|
|
1598
|
+
children: JSON.parse(item.extraInfo).map((list, index)=>{
|
|
1599
|
+
return /*#__PURE__*/ _jsxs("li", {
|
|
1600
|
+
onClick: ()=>{
|
|
1601
|
+
sendMessage(list, 1);
|
|
1602
|
+
},
|
|
1603
|
+
children: [
|
|
1604
|
+
index + 1,
|
|
1605
|
+
".",
|
|
1606
|
+
list.question
|
|
1607
|
+
]
|
|
1608
|
+
}, i + "_" + index + "_" + list.value);
|
|
1609
|
+
})
|
|
1610
|
+
}) : ""
|
|
1611
|
+
]
|
|
1612
|
+
}),
|
|
1613
|
+
!item.findTeacher && historyMessageList.length - 1 == i && item.extraInfo == null && item.id != "123456" ? /*#__PURE__*/ _jsx("div", {
|
|
1614
|
+
className: `${styles.operate_modal_bottom}`,
|
|
1615
|
+
children: item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1616
|
+
children: [
|
|
1617
|
+
/*#__PURE__*/ _jsx("p", {
|
|
1618
|
+
className: styles.stop_generate,
|
|
1619
|
+
children: !finished ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1620
|
+
children: [
|
|
1621
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1622
|
+
onClick: ()=>{
|
|
1623
|
+
// aiSendQuestions(3,{},1);
|
|
1624
|
+
// if (type == 3) {
|
|
1625
|
+
try {
|
|
1626
|
+
if (ctrl && ctrl.current) {
|
|
1627
|
+
ctrl.current.abort();
|
|
1628
|
+
}
|
|
1629
|
+
} catch (error) {}
|
|
1630
|
+
clearTimeout(receiveMessageTimer.current);
|
|
1631
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1632
|
+
return historyMessageList.filter((item)=>item.id != "123456");
|
|
1633
|
+
});
|
|
1634
|
+
setFinished(true);
|
|
1635
|
+
// return;
|
|
1636
|
+
// }
|
|
1637
|
+
onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
|
|
1638
|
+
}
|
|
1639
|
+
}),
|
|
1640
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1641
|
+
onClick: ()=>{
|
|
1642
|
+
// aiSendQuestions(3,{},1);
|
|
1643
|
+
try {
|
|
1644
|
+
if (ctrl && ctrl.current) {
|
|
1645
|
+
ctrl.current.abort();
|
|
1646
|
+
}
|
|
1647
|
+
} catch (error) {}
|
|
1648
|
+
clearTimeout(receiveMessageTimer.current);
|
|
1649
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1650
|
+
return historyMessageList.filter((item)=>item.id != "123456");
|
|
1651
|
+
});
|
|
1652
|
+
setFinished(true);
|
|
1653
|
+
onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
|
|
1654
|
+
},
|
|
1655
|
+
children: "停止生成"
|
|
1656
|
+
})
|
|
1657
|
+
]
|
|
1658
|
+
}) : ""
|
|
1659
|
+
}),
|
|
1660
|
+
finished ? /*#__PURE__*/ _jsxs("p", {
|
|
1661
|
+
className: `${styles.operate}`,
|
|
1662
|
+
children: [
|
|
1663
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1664
|
+
onClick: ()=>{
|
|
1665
|
+
setFinished(false);
|
|
1666
|
+
aiSendQuestions(2, {
|
|
1667
|
+
roomId: roomId,
|
|
1668
|
+
message: historyMessageList[i - 1].message,
|
|
1669
|
+
quotedMessage: citationContent.content || "",
|
|
1670
|
+
regenerate: true,
|
|
1671
|
+
generateUpvoteOrDownvoteMessage: false
|
|
1672
|
+
}, item.id);
|
|
1673
|
+
onEvent(serverName + serverUrl(), "click_智能问答_重新生成", "提交");
|
|
1674
|
+
},
|
|
1675
|
+
children: /*#__PURE__*/ _jsx(CustomReloading, {})
|
|
1676
|
+
}),
|
|
1677
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1678
|
+
className: "yinyong_quote1",
|
|
1679
|
+
onClick: ()=>{
|
|
1680
|
+
setCitationContent({
|
|
1681
|
+
content: item.message,
|
|
1682
|
+
id: item.id
|
|
1683
|
+
});
|
|
1684
|
+
resettingBottomHei();
|
|
1685
|
+
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
1686
|
+
},
|
|
1687
|
+
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
1688
|
+
}),
|
|
1689
|
+
copyTextOBJ.length > 0 && copyTextOBJ.some((list)=>list == item.id) ? /*#__PURE__*/ _jsx("i", {
|
|
1690
|
+
className: `tongyong-xuanzhongdui`,
|
|
1691
|
+
children: /*#__PURE__*/ _jsx(CustomDuihao, {})
|
|
1692
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
1693
|
+
className: "fuzhi21",
|
|
1694
|
+
onClick: ()=>{
|
|
1695
|
+
let bol = copyText(item.message);
|
|
1696
|
+
if (bol) {
|
|
1697
|
+
let obj = copyTextOBJ;
|
|
1698
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1699
|
+
obj.push(item.id);
|
|
1700
|
+
setCopyTextObj(obj);
|
|
1701
|
+
}
|
|
1702
|
+
setTimeout(()=>{
|
|
1703
|
+
let obj = copyTextOBJ;
|
|
1704
|
+
obj = obj.filter((list)=>list != item.id);
|
|
1705
|
+
setCopyTextObj(obj);
|
|
1706
|
+
}, 3000);
|
|
1707
|
+
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
1708
|
+
},
|
|
1709
|
+
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
1710
|
+
}),
|
|
1711
|
+
/*#__PURE__*/ _jsx("span", {
|
|
1712
|
+
children: "|"
|
|
1713
|
+
}),
|
|
1714
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1715
|
+
className: `Frame427319094 ${item.upvoted ? styles.active : ""}`,
|
|
1716
|
+
onClick: ()=>{
|
|
1717
|
+
likeMessage(item.id, item.upvoted);
|
|
1718
|
+
console.log("判断是AI还是智能回答", item);
|
|
1719
|
+
//只有最后一条回答,支持发送点赞或踩
|
|
1720
|
+
if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
1721
|
+
console.log("判断是AI还是智能回答", item);
|
|
1722
|
+
if (!item.extraInfo && item.sender == "AI") {
|
|
1723
|
+
aiSendQuestions(1, {
|
|
1724
|
+
roomId: roomId,
|
|
1725
|
+
message: "你给出的答案我非常满意,赞!",
|
|
1726
|
+
quotedMessage: "",
|
|
1727
|
+
regenerate: false,
|
|
1728
|
+
generateUpvoteOrDownvoteMessage: true
|
|
1729
|
+
}, 1);
|
|
1730
|
+
} else {
|
|
1731
|
+
console.log("AI回答2255555");
|
|
1732
|
+
sendGreetingMessage(2);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
children: /*#__PURE__*/ _jsx(CustomLike, {})
|
|
1737
|
+
}),
|
|
1738
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1739
|
+
className: `Frame427319095 ${item.downvoted ? styles.active : ""}`,
|
|
1740
|
+
onClick: ()=>{
|
|
1741
|
+
disagreeMessage(item.id, item.downvoted);
|
|
1742
|
+
//只有最后一条回答,支持发送点赞或踩
|
|
1743
|
+
console.log(item, "dlfkvmdflkv");
|
|
1744
|
+
if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
|
|
1745
|
+
if (!item.extraInfo && item.sender == "AI") {
|
|
1746
|
+
console.log("AI回答2222");
|
|
1747
|
+
//AI回答
|
|
1748
|
+
aiSendQuestions(1, {
|
|
1749
|
+
roomId: roomId,
|
|
1750
|
+
message: "你给出的答案很糟糕,我不满意,踩!",
|
|
1751
|
+
quotedMessage: "",
|
|
1752
|
+
regenerate: false,
|
|
1753
|
+
generateUpvoteOrDownvoteMessage: true
|
|
1754
|
+
}, 1);
|
|
1755
|
+
} else {
|
|
1756
|
+
sendGreetingMessage(3);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
children: /*#__PURE__*/ _jsx(CustomDislike, {})
|
|
1761
|
+
})
|
|
1762
|
+
]
|
|
1763
|
+
}) : ""
|
|
1764
|
+
]
|
|
1765
|
+
})
|
|
1766
|
+
}) : "",
|
|
1767
|
+
//召唤老师回答按钮
|
|
1768
|
+
item.findTeacher ? /*#__PURE__*/ _jsx("div", {
|
|
1769
|
+
className: `${styles.operate_modal_bottom}`,
|
|
1770
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1771
|
+
className: styles.stop_findTeacher,
|
|
1772
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
1773
|
+
onClick: ()=>{
|
|
1774
|
+
setAnswerMode(-1);
|
|
1775
|
+
setTeacherList([]);
|
|
1776
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
1777
|
+
return historyMessageList.filter((item)=>item.id != "-1");
|
|
1778
|
+
});
|
|
1779
|
+
},
|
|
1780
|
+
children: "停止召唤老师"
|
|
1781
|
+
})
|
|
1782
|
+
})
|
|
1783
|
+
}) : ''
|
|
1784
|
+
]
|
|
1785
|
+
})
|
|
1786
|
+
})
|
|
1787
|
+
]
|
|
1788
|
+
}, item.id)
|
|
1789
|
+
]
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
return li;
|
|
1793
|
+
})
|
|
1794
|
+
});
|
|
1795
|
+
} else {
|
|
1796
|
+
return "";
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
//渲染底部按钮
|
|
1800
|
+
const renderBottomAnt = ()=>{
|
|
1801
|
+
let placeholder = "";
|
|
1802
|
+
let disabled = false;
|
|
1803
|
+
if (voiceRecordingStatus == 2) {
|
|
1804
|
+
placeholder = "录制中...";
|
|
1805
|
+
} else if (voiceRecordingStatus == 1) {
|
|
1806
|
+
placeholder = "正在语音识别文字,请稍后...";
|
|
1807
|
+
} else if (!finished) {
|
|
1808
|
+
placeholder = "答案生成中,请稍后再发送...";
|
|
1809
|
+
} else {
|
|
1810
|
+
placeholder = "请输入问题,按Enter发送,Shift+Enter换行";
|
|
1811
|
+
disabled = true;
|
|
1812
|
+
}
|
|
1813
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1814
|
+
children: [
|
|
1815
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1816
|
+
className: styles.input_wrap,
|
|
1817
|
+
onChange: ()=>{
|
|
1818
|
+
resettingBottomHei();
|
|
1819
|
+
},
|
|
1820
|
+
children: [
|
|
1821
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1822
|
+
className: `${styles.input} ${userData.modules.some((item)=>item.short == "AIservice") ? "" : styles.no_AI}`,
|
|
1823
|
+
children: [
|
|
1824
|
+
/*#__PURE__*/ _jsx(TextArea, {
|
|
1825
|
+
placeholder: placeholder,
|
|
1826
|
+
autoSize: {
|
|
1827
|
+
minRows: 1,
|
|
1828
|
+
maxRows: 6
|
|
1829
|
+
},
|
|
1830
|
+
value: keyWord,
|
|
1831
|
+
onChange: (e)=>{
|
|
1832
|
+
setKeyWord(e.target.value);
|
|
1833
|
+
if (e.target.value == "") {
|
|
1834
|
+
setQuestionsList([]);
|
|
1835
|
+
clearTimeout(timer.current);
|
|
1836
|
+
} else {
|
|
1837
|
+
clearTimeout(timer.current);
|
|
1838
|
+
timer.current = setTimeout(()=>{
|
|
1839
|
+
if (answerMode == 1) {
|
|
1840
|
+
getTeacherList(String(e.target.value));
|
|
1841
|
+
} else {
|
|
1842
|
+
if (roomList.length > 0 && roomList[0].roomId != roomId) return;
|
|
1843
|
+
getQuestiionsList(String(e.target.value), 2);
|
|
1844
|
+
}
|
|
1845
|
+
}, 1000);
|
|
1846
|
+
}
|
|
1847
|
+
},
|
|
1848
|
+
onPressEnter: (e)=>{
|
|
1849
|
+
// console.log('发送内容22222',props)
|
|
1850
|
+
console.log(roomList, roomId, '发送内容22222wewewewewewewe');
|
|
1851
|
+
if (!e.shiftKey && !e.altKey && !e.ctrlKey && keyWord.trim() != "") {
|
|
1852
|
+
e.stopPropagation();
|
|
1853
|
+
e.preventDefault();
|
|
1854
|
+
clearTimeout(timer.current);
|
|
1855
|
+
setKeyWord('');
|
|
1856
|
+
setCitationContent({});
|
|
1857
|
+
//跟老师对话
|
|
1858
|
+
if (roomList.length > 0 && roomList[0].roomId != roomId) {
|
|
1859
|
+
sendToTeacher(2);
|
|
1860
|
+
} else {
|
|
1861
|
+
sendMessage();
|
|
1862
|
+
}
|
|
1863
|
+
setButtomHei(45);
|
|
1864
|
+
} else {
|
|
1865
|
+
console.log("回车事件");
|
|
1866
|
+
resettingBottomHei();
|
|
1867
|
+
}
|
|
1868
|
+
},
|
|
1869
|
+
onFocus: ()=>{
|
|
1870
|
+
onEvent(serverName + serverUrl(), "click_智能问答_输入框", "提交");
|
|
1871
|
+
},
|
|
1872
|
+
disabled: !disabled,
|
|
1873
|
+
maxLength: 1000
|
|
1874
|
+
}),
|
|
1875
|
+
citationContent.content != undefined && citationContent.content != "" ? /*#__PURE__*/ _jsxs("div", {
|
|
1876
|
+
className: styles.content_main,
|
|
1877
|
+
children: [
|
|
1878
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1879
|
+
className: styles.content_con,
|
|
1880
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1881
|
+
children: citationContent.content
|
|
1882
|
+
})
|
|
1883
|
+
}),
|
|
1884
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1885
|
+
className: styles.delete_quote,
|
|
1886
|
+
onClick: ()=>{
|
|
1887
|
+
setCitationContent({});
|
|
1888
|
+
resettingBottomHei();
|
|
1889
|
+
},
|
|
1890
|
+
children: /*#__PURE__*/ _jsx(CustomRoundClose, {})
|
|
1891
|
+
})
|
|
1892
|
+
]
|
|
1893
|
+
}) : ""
|
|
1894
|
+
]
|
|
1895
|
+
}),
|
|
1896
|
+
userData.modules.some((item)=>item.short == "AIservice") ? /*#__PURE__*/ _jsxs("p", {
|
|
1897
|
+
className: styles.voice,
|
|
1898
|
+
children: [
|
|
1899
|
+
voiceRecordingStatus == 1 || voiceRecordingStatus == 3 ? /*#__PURE__*/ _jsx("i", {
|
|
1900
|
+
className: "yuyin-kai12",
|
|
1901
|
+
style: {
|
|
1902
|
+
color: disabled ? "rgba(0, 0, 0, 0.65)" : "rgba(0, 0, 0, 0.25)"
|
|
1903
|
+
},
|
|
1904
|
+
onClick: ()=>{
|
|
1905
|
+
//开始录音
|
|
1906
|
+
if (!disabled) return;
|
|
1907
|
+
startRecord();
|
|
1908
|
+
setVoiceRecordingStatus(2);
|
|
1909
|
+
setKeyWord("");
|
|
1910
|
+
voiceCountdownTimer.current = setTimeout(()=>{
|
|
1911
|
+
stopRecord();
|
|
1912
|
+
setVoiceRecordingStatus(1);
|
|
1913
|
+
}, 120000);
|
|
1914
|
+
onEvent(serverName + serverUrl(), "click_智能问答_ 麦克风", "提交");
|
|
1915
|
+
},
|
|
1916
|
+
children: /*#__PURE__*/ _jsx(CustomSoundRecording, {})
|
|
1917
|
+
}) : "",
|
|
1918
|
+
voiceRecordingStatus == 2 ? /*#__PURE__*/ _jsx("img", {
|
|
1919
|
+
// src={Voice_btn}
|
|
1920
|
+
src: "/new_yun/images/aiService/voice_btn.gif",
|
|
1921
|
+
className: styles.voice_btn,
|
|
1922
|
+
onClick: ()=>{
|
|
1923
|
+
//结束录音
|
|
1924
|
+
// console.log(mediaRecorder,'3333333');
|
|
1925
|
+
// mediaRecorder.stop();
|
|
1926
|
+
stopRecord();
|
|
1927
|
+
setVoiceRecordingStatus(1);
|
|
1928
|
+
clearTimeout(voiceCountdownTimer.current);
|
|
1929
|
+
}
|
|
1930
|
+
}) : ""
|
|
1931
|
+
]
|
|
1932
|
+
}) : ""
|
|
1933
|
+
]
|
|
1934
|
+
}),
|
|
1935
|
+
/*#__PURE__*/ _jsx("p", {
|
|
1936
|
+
className: `${styles.sending}`,
|
|
1937
|
+
children: /*#__PURE__*/ _jsx("i", {
|
|
1938
|
+
className: `${!disabled ? styles.disabled : ''}`,
|
|
1939
|
+
onClick: ()=>{
|
|
1940
|
+
if (!disabled) return;
|
|
1941
|
+
setCitationContent({});
|
|
1942
|
+
setButtomHei(45);
|
|
1943
|
+
if (keyWord.trim() != "") {
|
|
1944
|
+
setKeyWord('');
|
|
1945
|
+
//跟老师对话
|
|
1946
|
+
if (roomList.length > 0 && roomList[0].roomId != roomId) {
|
|
1947
|
+
sendToTeacher(2);
|
|
1948
|
+
} else {
|
|
1949
|
+
sendMessage();
|
|
1950
|
+
}
|
|
1951
|
+
onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
|
|
1952
|
+
}
|
|
1953
|
+
},
|
|
1954
|
+
children: /*#__PURE__*/ _jsx(CustomSending, {})
|
|
1955
|
+
})
|
|
1956
|
+
})
|
|
1957
|
+
]
|
|
1958
|
+
});
|
|
1959
|
+
};
|
|
1960
|
+
//渲染联想问题及联想的老师名称
|
|
1961
|
+
const renderAssociationProblem = ()=>{
|
|
1962
|
+
if (answerMode == 1) {
|
|
1963
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
1964
|
+
className: `${styles.issues_list} ${styles.issues_list_teacherList}`,
|
|
1965
|
+
style: {
|
|
1966
|
+
bottom: `${buttomHei + 6}px`
|
|
1967
|
+
},
|
|
1968
|
+
children: teacherList.map((item)=>{
|
|
1969
|
+
let span = item.name.replaceAll(keyWord, ()=>{
|
|
1970
|
+
return `<span class=${styles.sign}>${keyWord}</span>`;
|
|
1971
|
+
});
|
|
1972
|
+
return /*#__PURE__*/ _jsx("p", {
|
|
1973
|
+
className: styles.item,
|
|
1974
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
1975
|
+
onClick: ()=>{
|
|
1976
|
+
setTeacherList([]);
|
|
1977
|
+
//提问的问题
|
|
1978
|
+
setProblem({
|
|
1979
|
+
question: problem.question,
|
|
1980
|
+
user: item.uid
|
|
1981
|
+
});
|
|
1982
|
+
setKeyWord("");
|
|
1983
|
+
//setUpdateRecords(true);
|
|
1984
|
+
setAnswerMode(-1);
|
|
1985
|
+
setChatWith(item);
|
|
1986
|
+
createRooms(item.uid).then((res)=>{
|
|
1987
|
+
let id = res.data.id;
|
|
1988
|
+
setRoomId(id); //新的聊天室id
|
|
1989
|
+
});
|
|
1990
|
+
},
|
|
1991
|
+
dangerouslySetInnerHTML: {
|
|
1992
|
+
__html: span
|
|
1993
|
+
}
|
|
1994
|
+
})
|
|
1995
|
+
});
|
|
1996
|
+
})
|
|
1997
|
+
});
|
|
1998
|
+
} else {
|
|
1999
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
2000
|
+
className: styles.issues_list,
|
|
2001
|
+
style: {
|
|
2002
|
+
bottom: `${buttomHei + 6}px`
|
|
2003
|
+
},
|
|
2004
|
+
children: questionsList.map((item)=>{
|
|
2005
|
+
console.log(item, 44444444);
|
|
2006
|
+
let span = item.question.replaceAll(keyWord, ()=>{
|
|
2007
|
+
return `<span class=${styles.sign}>${keyWord}</span>`;
|
|
2008
|
+
});
|
|
2009
|
+
return /*#__PURE__*/ _jsx("p", {
|
|
2010
|
+
className: styles.item,
|
|
2011
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
2012
|
+
onClick: ()=>{
|
|
2013
|
+
sendMessage(item, 2);
|
|
2014
|
+
setKeyWord("");
|
|
2015
|
+
onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
|
|
2016
|
+
},
|
|
2017
|
+
dangerouslySetInnerHTML: {
|
|
2018
|
+
__html: span
|
|
2019
|
+
}
|
|
2020
|
+
})
|
|
2021
|
+
});
|
|
2022
|
+
})
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
//加载指定数据,点击历史记录
|
|
2027
|
+
const loadSpecifiedData = (renewRoomId, page, id)=>{
|
|
2028
|
+
setPageNum(page);
|
|
2029
|
+
setLastId(id); //用于定位
|
|
2030
|
+
//如果是当前聊天室
|
|
2031
|
+
if (renewRoomId == roomId) {
|
|
2032
|
+
console.log("当前聊天窗口111111");
|
|
2033
|
+
getHistoryMessage(page, 1);
|
|
2034
|
+
} else {
|
|
2035
|
+
setRoomId(renewRoomId);
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2039
|
+
children: [
|
|
2040
|
+
/*#__PURE__*/ _jsxs(Drawer, {
|
|
2041
|
+
title: "智能回答",
|
|
2042
|
+
width: 560,
|
|
2043
|
+
onClose: ()=>{
|
|
2044
|
+
onCancel();
|
|
2045
|
+
onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
|
|
2046
|
+
},
|
|
2047
|
+
open: showType == 1 ? true : false,
|
|
2048
|
+
className: styles.ChatWindow_Drawer,
|
|
2049
|
+
mask: false,
|
|
2050
|
+
// maskClosable={false}
|
|
2051
|
+
rootClassName: styles.service_ChatWindow_Drawer,
|
|
2052
|
+
children: [
|
|
2053
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2054
|
+
style: {
|
|
2055
|
+
display: `${showContacts && roomId != "" ? "block" : "none"}`
|
|
2056
|
+
},
|
|
2057
|
+
children: /*#__PURE__*/ _jsx(ContactsList, {
|
|
2058
|
+
type: 1,
|
|
2059
|
+
roomId: roomId,
|
|
2060
|
+
userData: userData,
|
|
2061
|
+
http: http,
|
|
2062
|
+
urllocation: urllocation,
|
|
2063
|
+
onClose: ()=>{
|
|
2064
|
+
setShowContacts(false);
|
|
2065
|
+
},
|
|
2066
|
+
// roomIdAi={roomIdAi}
|
|
2067
|
+
switchChatRoom: switchChatRoom,
|
|
2068
|
+
saveContactsList: saveContactsList
|
|
2069
|
+
})
|
|
2070
|
+
}),
|
|
2071
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2072
|
+
className: styles.header_wrap,
|
|
2073
|
+
children: renderHeader()
|
|
2074
|
+
}),
|
|
2075
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2076
|
+
className: `${styles.Drawer_main}`,
|
|
2077
|
+
id: "chat_content",
|
|
2078
|
+
style: {
|
|
2079
|
+
maxHeight: `calc(100vh-${buttomHei + 48}px)`
|
|
2080
|
+
},
|
|
2081
|
+
children: [
|
|
2082
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
2083
|
+
className: styles.loading,
|
|
2084
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2085
|
+
src: "/new_yun/images/loading_d.gif",
|
|
2086
|
+
alt: ""
|
|
2087
|
+
})
|
|
2088
|
+
}) : "",
|
|
2089
|
+
renderQuestion()
|
|
2090
|
+
]
|
|
2091
|
+
}),
|
|
2092
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2093
|
+
className: styles.Drawer_buttom_Issues_List,
|
|
2094
|
+
children: [
|
|
2095
|
+
renderAssociationProblem(),
|
|
2096
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2097
|
+
className: styles.Drawer_buttom,
|
|
2098
|
+
id: "Drawer_buttom",
|
|
2099
|
+
children: renderBottomAnt()
|
|
2100
|
+
})
|
|
2101
|
+
]
|
|
2102
|
+
}),
|
|
2103
|
+
showType == 1 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
|
|
2104
|
+
type: 1,
|
|
2105
|
+
roomId: roomId,
|
|
2106
|
+
userData: userData,
|
|
2107
|
+
http: http,
|
|
2108
|
+
urllocation: urllocation,
|
|
2109
|
+
onClose: ()=>{
|
|
2110
|
+
setShowHistory(false);
|
|
2111
|
+
},
|
|
2112
|
+
loadSpecifiedData: loadSpecifiedData,
|
|
2113
|
+
roomList: roomList
|
|
2114
|
+
})
|
|
2115
|
+
]
|
|
2116
|
+
}),
|
|
2117
|
+
/*#__PURE__*/ _jsxs(Modal, {
|
|
2118
|
+
title: "智能回答",
|
|
2119
|
+
open: showType == 2 ? true : false,
|
|
2120
|
+
onCancel: ()=>{
|
|
2121
|
+
onCancel();
|
|
2122
|
+
onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
|
|
2123
|
+
},
|
|
2124
|
+
centered: true,
|
|
2125
|
+
width: 1014,
|
|
2126
|
+
height: window.innerHeight - 160,
|
|
2127
|
+
wrapClassName: styles.ChatWindow_Modal,
|
|
2128
|
+
footer: false,
|
|
2129
|
+
maskClosable: false,
|
|
2130
|
+
closeIcon: null,
|
|
2131
|
+
children: [
|
|
2132
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2133
|
+
className: styles.header_wrap,
|
|
2134
|
+
children: renderHeader()
|
|
2135
|
+
}),
|
|
2136
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2137
|
+
className: `${styles.Drawer_wrap_main}`,
|
|
2138
|
+
children: [
|
|
2139
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2140
|
+
className: `${styles.Drawer_main} ChatWindow_Modal_history_list`,
|
|
2141
|
+
id: "chat_content_modal",
|
|
2142
|
+
style: {
|
|
2143
|
+
maxHeight: `${window.innerHeight - 148 - buttomHei}px`
|
|
2144
|
+
},
|
|
2145
|
+
children: [
|
|
2146
|
+
/*#__PURE__*/ _jsx(ContactsList, {
|
|
2147
|
+
type: 2,
|
|
2148
|
+
roomId: roomId,
|
|
2149
|
+
userData: userData,
|
|
2150
|
+
http: http,
|
|
2151
|
+
urllocation: urllocation,
|
|
2152
|
+
onClose: ()=>{
|
|
2153
|
+
setShowContacts(false);
|
|
2154
|
+
},
|
|
2155
|
+
switchChatRoom: switchChatRoom,
|
|
2156
|
+
saveContactsList: saveContactsList
|
|
2157
|
+
}),
|
|
2158
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2159
|
+
className: styles.chat_content,
|
|
2160
|
+
children: [
|
|
2161
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
2162
|
+
className: styles.loading,
|
|
2163
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2164
|
+
src: "/new_yun/images/loading_d.gif",
|
|
2165
|
+
alt: ""
|
|
2166
|
+
})
|
|
2167
|
+
}) : "",
|
|
2168
|
+
renderQuestion()
|
|
2169
|
+
]
|
|
2170
|
+
})
|
|
2171
|
+
]
|
|
2172
|
+
}),
|
|
2173
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2174
|
+
className: styles.Drawer_buttom_Issues_List,
|
|
2175
|
+
children: [
|
|
2176
|
+
renderAssociationProblem(),
|
|
2177
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2178
|
+
className: styles.Drawer_buttom,
|
|
2179
|
+
id: "Drawer_buttom_modal",
|
|
2180
|
+
children: renderBottomAnt()
|
|
2181
|
+
})
|
|
2182
|
+
]
|
|
2183
|
+
}),
|
|
2184
|
+
showType == 2 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
|
|
2185
|
+
type: 2,
|
|
2186
|
+
roomId: roomId,
|
|
2187
|
+
userData: userData,
|
|
2188
|
+
http: http,
|
|
2189
|
+
urllocation: urllocation,
|
|
2190
|
+
onClose: ()=>{
|
|
2191
|
+
setShowHistory(false);
|
|
2192
|
+
},
|
|
2193
|
+
loadSpecifiedData: loadSpecifiedData,
|
|
2194
|
+
roomList: roomList
|
|
2195
|
+
})
|
|
2196
|
+
]
|
|
2197
|
+
})
|
|
2198
|
+
]
|
|
2199
|
+
}),
|
|
2200
|
+
showType == 3 && /*#__PURE__*/ _jsxs("div", {
|
|
2201
|
+
className: `${styles.ChatWindow_Drawer}`,
|
|
2202
|
+
id: "",
|
|
2203
|
+
children: [
|
|
2204
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2205
|
+
className: `${styles.header_wrap} ${styles.header_wrap_newlabo}`,
|
|
2206
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
2207
|
+
className: styles.top,
|
|
2208
|
+
children: [
|
|
2209
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2210
|
+
className: styles.user,
|
|
2211
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
2212
|
+
children: "智能回答"
|
|
2213
|
+
})
|
|
2214
|
+
}),
|
|
2215
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2216
|
+
className: styles.operate,
|
|
2217
|
+
children: [
|
|
2218
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2219
|
+
onClick: ()=>{
|
|
2220
|
+
setShowHistory(true);
|
|
2221
|
+
},
|
|
2222
|
+
children: /*#__PURE__*/ _jsx(CustomRecord, {})
|
|
2223
|
+
}),
|
|
2224
|
+
/*#__PURE__*/ _jsx("span", {
|
|
2225
|
+
className: styles.line
|
|
2226
|
+
}),
|
|
2227
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2228
|
+
onClick: ()=>{
|
|
2229
|
+
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
2230
|
+
setShowType(4);
|
|
2231
|
+
},
|
|
2232
|
+
children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
|
|
2233
|
+
}),
|
|
2234
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2235
|
+
className: "lianxiren21",
|
|
2236
|
+
onClick: ()=>{
|
|
2237
|
+
setShowContacts(true);
|
|
2238
|
+
},
|
|
2239
|
+
children: /*#__PURE__*/ _jsx(CustomContacts, {})
|
|
2240
|
+
})
|
|
2241
|
+
]
|
|
2242
|
+
})
|
|
2243
|
+
]
|
|
2244
|
+
})
|
|
2245
|
+
}),
|
|
2246
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2247
|
+
className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo}`,
|
|
2248
|
+
id: "chat_content",
|
|
2249
|
+
style: {
|
|
2250
|
+
maxHeight: `calc(100vh-${100}-${buttomHei}px)`
|
|
2251
|
+
},
|
|
2252
|
+
children: [
|
|
2253
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
2254
|
+
className: styles.loading,
|
|
2255
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2256
|
+
src: "/new_yun/images/loading_d.gif",
|
|
2257
|
+
alt: ""
|
|
2258
|
+
})
|
|
2259
|
+
}) : "",
|
|
2260
|
+
renderQuestion()
|
|
2261
|
+
]
|
|
2262
|
+
}),
|
|
2263
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2264
|
+
className: `${styles.Drawer_buttom_Issues_List} ${styles.Drawer_buttom_Issues_List_newlabo}`,
|
|
2265
|
+
children: [
|
|
2266
|
+
renderAssociationProblem(),
|
|
2267
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2268
|
+
className: styles.Drawer_buttom,
|
|
2269
|
+
id: "Drawer_buttom",
|
|
2270
|
+
children: renderBottomAnt()
|
|
2271
|
+
})
|
|
2272
|
+
]
|
|
2273
|
+
}),
|
|
2274
|
+
showType == 3 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
|
|
2275
|
+
type: 3,
|
|
2276
|
+
roomId: roomId,
|
|
2277
|
+
userData: userData,
|
|
2278
|
+
http: http,
|
|
2279
|
+
urllocation: urllocation,
|
|
2280
|
+
onClose: ()=>{
|
|
2281
|
+
setShowHistory(false);
|
|
2282
|
+
},
|
|
2283
|
+
loadSpecifiedData: loadSpecifiedData,
|
|
2284
|
+
roomList: roomList
|
|
2285
|
+
}),
|
|
2286
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2287
|
+
style: {
|
|
2288
|
+
display: `${showType == 3 && showContacts && roomId != "" ? "block" : "none"}`
|
|
2289
|
+
},
|
|
2290
|
+
children: /*#__PURE__*/ _jsx(ContactsList, {
|
|
2291
|
+
type: 3,
|
|
2292
|
+
roomId: roomId,
|
|
2293
|
+
userData: userData,
|
|
2294
|
+
http: http,
|
|
2295
|
+
urllocation: urllocation,
|
|
2296
|
+
onClose: ()=>{
|
|
2297
|
+
setShowContacts(false);
|
|
2298
|
+
},
|
|
2299
|
+
switchChatRoom: switchChatRoom,
|
|
2300
|
+
saveContactsList: saveContactsList
|
|
2301
|
+
})
|
|
2302
|
+
})
|
|
2303
|
+
]
|
|
2304
|
+
}),
|
|
2305
|
+
showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2306
|
+
children: [
|
|
2307
|
+
/*#__PURE__*/ _jsxs(Modal, {
|
|
2308
|
+
title: "智能回答",
|
|
2309
|
+
open: true,
|
|
2310
|
+
onCancel: ()=>{
|
|
2311
|
+
onCancel();
|
|
2312
|
+
onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
|
|
2313
|
+
},
|
|
2314
|
+
centered: true,
|
|
2315
|
+
width: 1014,
|
|
2316
|
+
height: window.innerHeight - 160,
|
|
2317
|
+
wrapClassName: `${styles.ChatWindow_Modal}`,
|
|
2318
|
+
footer: false,
|
|
2319
|
+
maskClosable: false,
|
|
2320
|
+
closeIcon: null,
|
|
2321
|
+
children: [
|
|
2322
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2323
|
+
className: styles.header_wrap,
|
|
2324
|
+
children: renderHeader()
|
|
2325
|
+
}),
|
|
2326
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2327
|
+
className: `${styles.Drawer_wrap_main}`,
|
|
2328
|
+
children: [
|
|
2329
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2330
|
+
className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo}`,
|
|
2331
|
+
id: "chat_content_modal",
|
|
2332
|
+
style: {
|
|
2333
|
+
maxHeight: `${window.innerHeight - 148 - buttomHei}px`
|
|
2334
|
+
},
|
|
2335
|
+
children: [
|
|
2336
|
+
/*#__PURE__*/ _jsx(ContactsList, {
|
|
2337
|
+
type: 4,
|
|
2338
|
+
roomId: roomId,
|
|
2339
|
+
userData: userData,
|
|
2340
|
+
http: http,
|
|
2341
|
+
urllocation: urllocation,
|
|
2342
|
+
onClose: ()=>{
|
|
2343
|
+
setShowContacts(false);
|
|
2344
|
+
},
|
|
2345
|
+
switchChatRoom: switchChatRoom,
|
|
2346
|
+
saveContactsList: saveContactsList
|
|
2347
|
+
}),
|
|
2348
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2349
|
+
className: styles.chat_content,
|
|
2350
|
+
children: [
|
|
2351
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
2352
|
+
className: styles.loading,
|
|
2353
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2354
|
+
src: "/new_yun/images/loading_d.gif",
|
|
2355
|
+
alt: ""
|
|
2356
|
+
})
|
|
2357
|
+
}) : "",
|
|
2358
|
+
renderQuestion()
|
|
2359
|
+
]
|
|
2360
|
+
})
|
|
2361
|
+
]
|
|
2362
|
+
}),
|
|
2363
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2364
|
+
className: styles.Drawer_buttom_Issues_List,
|
|
2365
|
+
children: [
|
|
2366
|
+
renderAssociationProblem(),
|
|
2367
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2368
|
+
className: styles.Drawer_buttom,
|
|
2369
|
+
id: "Drawer_buttom_modal",
|
|
2370
|
+
children: renderBottomAnt()
|
|
2371
|
+
})
|
|
2372
|
+
]
|
|
2373
|
+
}),
|
|
2374
|
+
showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
|
|
2375
|
+
type: 2,
|
|
2376
|
+
roomId: roomId,
|
|
2377
|
+
userData: userData,
|
|
2378
|
+
http: http,
|
|
2379
|
+
urllocation: urllocation,
|
|
2380
|
+
onClose: ()=>{
|
|
2381
|
+
setShowHistory(false);
|
|
2382
|
+
},
|
|
2383
|
+
loadSpecifiedData: loadSpecifiedData,
|
|
2384
|
+
roomList: roomList
|
|
2385
|
+
})
|
|
2386
|
+
]
|
|
2387
|
+
})
|
|
2388
|
+
]
|
|
2389
|
+
}),
|
|
2390
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2391
|
+
className: `${styles.ChatWindow_Drawer}`,
|
|
2392
|
+
id: "",
|
|
2393
|
+
children: [
|
|
2394
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2395
|
+
className: `${styles.header_wrap} ${styles.header_wrap_newlabo}`,
|
|
2396
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
2397
|
+
className: styles.top,
|
|
2398
|
+
children: [
|
|
2399
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2400
|
+
className: styles.user,
|
|
2401
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
2402
|
+
children: "智能回答"
|
|
2403
|
+
})
|
|
2404
|
+
}),
|
|
2405
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2406
|
+
className: styles.operate,
|
|
2407
|
+
children: [
|
|
2408
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2409
|
+
onClick: ()=>{
|
|
2410
|
+
setShowHistory(true);
|
|
2411
|
+
},
|
|
2412
|
+
children: /*#__PURE__*/ _jsx(CustomRecord, {})
|
|
2413
|
+
}),
|
|
2414
|
+
/*#__PURE__*/ _jsx("span", {
|
|
2415
|
+
className: styles.line
|
|
2416
|
+
}),
|
|
2417
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2418
|
+
onClick: ()=>{
|
|
2419
|
+
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
2420
|
+
setShowType(4);
|
|
2421
|
+
},
|
|
2422
|
+
children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
|
|
2423
|
+
}),
|
|
2424
|
+
/*#__PURE__*/ _jsx("i", {
|
|
2425
|
+
className: "lianxiren21",
|
|
2426
|
+
onClick: ()=>{
|
|
2427
|
+
setShowContacts(true);
|
|
2428
|
+
},
|
|
2429
|
+
children: /*#__PURE__*/ _jsx(CustomContacts, {})
|
|
2430
|
+
})
|
|
2431
|
+
]
|
|
2432
|
+
})
|
|
2433
|
+
]
|
|
2434
|
+
})
|
|
2435
|
+
}),
|
|
2436
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2437
|
+
className: `${styles.Drawer_main} ${styles.Drawer_main_newlabo}`,
|
|
2438
|
+
id: "chat_content",
|
|
2439
|
+
style: {
|
|
2440
|
+
maxHeight: `calc(100vh-${100}-${buttomHei}px)`
|
|
2441
|
+
},
|
|
2442
|
+
children: [
|
|
2443
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
2444
|
+
className: styles.loading,
|
|
2445
|
+
children: /*#__PURE__*/ _jsx("img", {
|
|
2446
|
+
src: "/new_yun/images/loading_d.gif",
|
|
2447
|
+
alt: ""
|
|
2448
|
+
})
|
|
2449
|
+
}) : "",
|
|
2450
|
+
renderQuestion()
|
|
2451
|
+
]
|
|
2452
|
+
}),
|
|
2453
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
2454
|
+
className: `${styles.Drawer_buttom_Issues_List} ${styles.Drawer_buttom_Issues_List_newlabo}`,
|
|
2455
|
+
children: [
|
|
2456
|
+
renderAssociationProblem(),
|
|
2457
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2458
|
+
className: styles.Drawer_buttom,
|
|
2459
|
+
id: "Drawer_buttom",
|
|
2460
|
+
children: renderBottomAnt()
|
|
2461
|
+
})
|
|
2462
|
+
]
|
|
2463
|
+
}),
|
|
2464
|
+
/*#__PURE__*/ _jsx("div", {
|
|
2465
|
+
style: {
|
|
2466
|
+
display: `${showContacts && roomId != "" ? "block" : "none"}`
|
|
2467
|
+
},
|
|
2468
|
+
children: /*#__PURE__*/ _jsx(ContactsList, {
|
|
2469
|
+
type: 3,
|
|
2470
|
+
roomId: roomId,
|
|
2471
|
+
userData: userData,
|
|
2472
|
+
http: http,
|
|
2473
|
+
urllocation: urllocation,
|
|
2474
|
+
onClose: ()=>{
|
|
2475
|
+
setShowContacts(false);
|
|
2476
|
+
},
|
|
2477
|
+
switchChatRoom: switchChatRoom,
|
|
2478
|
+
saveContactsList: saveContactsList
|
|
2479
|
+
})
|
|
2480
|
+
})
|
|
2481
|
+
]
|
|
2482
|
+
})
|
|
2483
|
+
]
|
|
2484
|
+
})
|
|
2485
|
+
]
|
|
2486
|
+
});
|
|
2487
|
+
};
|
|
2488
|
+
window.appendDom = (root, props)=>{
|
|
2489
|
+
render(/*#__PURE__*/ _jsx(Provider.Component, {
|
|
2490
|
+
children: /*#__PURE__*/ _jsx(CustomerService, _object_spread({}, props))
|
|
2491
|
+
}), root);
|
|
2492
|
+
};
|
|
2493
|
+
export default CustomerService;
|