bhd-components 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{bd8fe330.esm.es5.development.js → 072bdcac.esm.es5.development.js} +83 -7903
- package/dist/d634a723.esm.es5.production.js +468 -0
- package/dist/index.esm.es5.development.css +960 -958
- package/dist/index.esm.es5.development.js +124 -45
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/customerService/html2canvas.test.js +8580 -0
- package/es2017/customerService/index.d.ts +2 -0
- package/es2017/customerService/index.js +116 -40
- package/es2017/customerService/index.module.less +1 -1
- package/esm/customerService/html2canvas.test.js +8581 -0
- package/esm/customerService/index.d.ts +2 -0
- package/esm/customerService/index.js +123 -43
- package/esm/customerService/index.module.less +1 -1
- package/package.json +1 -1
- package/dist/989240e2.esm.es5.production.js +0 -485
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "highlight.js/styles/default.css";
|
|
3
|
+
import './html2canvas.test.js';
|
|
3
4
|
interface Service {
|
|
4
5
|
type: string;
|
|
5
6
|
params: any;
|
|
@@ -14,6 +15,7 @@ interface Service {
|
|
|
14
15
|
stepId?: string | number;
|
|
15
16
|
onEvent: (a: string, b: string, c: string) => {};
|
|
16
17
|
config: any;
|
|
18
|
+
screenshotAreaId: string;
|
|
17
19
|
}
|
|
18
20
|
declare const CustomerService: (props: Service) => JSX.Element;
|
|
19
21
|
export default CustomerService;
|
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
|
|
|
6
6
|
import React, { useEffect, useState, useRef } from "react";
|
|
7
7
|
import { Modal, Drawer, Input, Tooltip } from "antd";
|
|
8
8
|
import { ViewImage } from "bhd-components";
|
|
9
|
-
import html2canvas from "html2canvas";
|
|
9
|
+
// import html2canvas from "html2canvas";
|
|
10
10
|
import cssStyle from "./index.module.less";
|
|
11
11
|
import cssStyleOnline from "./index2.module.less";
|
|
12
12
|
var styles = cssStyle;
|
|
@@ -25,11 +25,12 @@ import "highlight.js/styles/default.css";
|
|
|
25
25
|
import { render } from "react-dom";
|
|
26
26
|
import Provider from "../provider";
|
|
27
27
|
var TextArea = Input.TextArea;
|
|
28
|
+
import "./html2canvas.test.js";
|
|
28
29
|
import knowledge_icon from "./images/knowledge_icon.png";
|
|
29
30
|
// import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
|
|
30
31
|
import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate } from "./function"; //一些方法
|
|
31
32
|
var CustomerService = function(props) {
|
|
32
|
-
var userData = props.userData, http = props.http, urllocation = props.urllocation, onCancel = props.onCancel, serverName = props.serverName, fetchEventSource = props.fetchEventSource, initShowType = props.initShowType, onEvent = props.onEvent, stepIds = props.stepIds, stepId = props.stepId, config = props.config;
|
|
33
|
+
var userData = props.userData, http = props.http, urllocation = props.urllocation, onCancel = props.onCancel, serverName = props.serverName, fetchEventSource = props.fetchEventSource, initShowType = props.initShowType, onEvent = props.onEvent, stepIds = props.stepIds, stepId = props.stepId, screenshotAreaId = props.screenshotAreaId, config = props.config;
|
|
33
34
|
// const { bese64String, startRecord, stopRecord } = useMediaRecorder(); //语音转文字
|
|
34
35
|
// const [voiceRecordingStatus, setVoiceRecordingStatus] = useState(3); //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
|
|
35
36
|
var _useState = _sliced_to_array(useState([]), 2), copyTextOBJ = _useState[0], setCopyTextObj = _useState[1]; //复制的消息id
|
|
@@ -138,28 +139,58 @@ var CustomerService = function(props) {
|
|
|
138
139
|
scrollTopHei.current = scrollTop;
|
|
139
140
|
};
|
|
140
141
|
if (showType == 5) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
142
|
+
// 获取屏幕流
|
|
143
|
+
// 获取 video 元素和 canvas 元素
|
|
144
|
+
// var video = document.getElementById('container_html5_api');
|
|
145
|
+
// // const canvas = document.createElement('canvas');
|
|
146
|
+
// const canvas = document.getElementById('canvas_test');
|
|
147
|
+
// var context = canvas.getContext('2d');
|
|
148
|
+
// // 设置 canvas 尺寸
|
|
149
|
+
// canvas.width = video.videoWidth/4;
|
|
150
|
+
// canvas.height = video.videoHeight/4;
|
|
151
|
+
// // 在 canvas 上绘制 video 的当前帧
|
|
152
|
+
// context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
153
|
+
// // 使用 html2canvas 对 canvas 进行截图
|
|
154
|
+
// html2canvas(canvas,{
|
|
155
|
+
// scale: 1,
|
|
156
|
+
// useCORS: true,
|
|
157
|
+
// logging: true,
|
|
158
|
+
// }).then(function(screenshot) {
|
|
159
|
+
// // 将截图显示在页面上,或者进行其他操作
|
|
160
|
+
// document.body.appendChild(screenshot);
|
|
161
|
+
// setTimeout(()=>{
|
|
162
|
+
// let url = screenshot.toDataURL('image/png');
|
|
163
|
+
// console.log(url);
|
|
164
|
+
// },3000)
|
|
165
|
+
// // console.log("container_html5_apicontainer_html5_api",screenshot)
|
|
166
|
+
// // console.log(screenshot.toDataURL('image/jpeg'))
|
|
167
|
+
// });
|
|
168
|
+
// // 显示图片或者做其他操作
|
|
169
|
+
try {
|
|
170
|
+
setImgBese64("");
|
|
171
|
+
html2canvas(document.getElementsByTagName("html")[0]).then(function(canvas) {
|
|
172
|
+
console.log(canvas, 22222);
|
|
173
|
+
setTimeout(function() {
|
|
174
|
+
var dom = document.getElementById(screenshotAreaId);
|
|
175
|
+
//let dom = document.getElementById("container_html5_api");
|
|
176
|
+
//let dom = document.getElementsByTagName('html')[0];
|
|
177
|
+
html2canvas(dom, {
|
|
178
|
+
useCORS: true,
|
|
179
|
+
// allowTaint: true, // 污染处理
|
|
180
|
+
scale: 1
|
|
181
|
+
}).then(function(canvas) {
|
|
182
|
+
// document.body.appendChild(canvas);
|
|
183
|
+
// document.body.appendChild(canvas);
|
|
184
|
+
console.log(canvas, 4444444);
|
|
185
|
+
// var base64URL = canvas.toDataURL('image/jpeg')
|
|
186
|
+
var base64URL = canvas.toDataURL("image/jpg", 1.0);
|
|
187
|
+
setImgBese64(base64URL);
|
|
188
|
+
});
|
|
189
|
+
}, 100);
|
|
190
|
+
});
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.log(error);
|
|
193
|
+
}
|
|
163
194
|
}
|
|
164
195
|
if (showType != 1 && !firstLoad && pageCount > 0) {
|
|
165
196
|
setFirstLoad(true);
|
|
@@ -332,8 +363,11 @@ var CustomerService = function(props) {
|
|
|
332
363
|
};
|
|
333
364
|
if (pageNumHistory <= 1) {
|
|
334
365
|
setHistoryMessageList(function(historyMessageList) {
|
|
335
|
-
var newHistoryMessageList = historyMessageList.
|
|
336
|
-
|
|
366
|
+
var newHistoryMessageList = historyMessageList.filter(function(e) {
|
|
367
|
+
return e.id != "123456_date";
|
|
368
|
+
});
|
|
369
|
+
newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
|
|
370
|
+
id: "123456_date",
|
|
337
371
|
upvoted: false,
|
|
338
372
|
downvoted: false,
|
|
339
373
|
quotedMessage: "",
|
|
@@ -538,6 +572,40 @@ var CustomerService = function(props) {
|
|
|
538
572
|
//点击知识库的问题,或者是点击问候消息
|
|
539
573
|
if (questions.length > 0) {
|
|
540
574
|
questions = questions[0];
|
|
575
|
+
//知识库联想的问题没有答案
|
|
576
|
+
if (!questions.answer && userData.modules.some(function(item) {
|
|
577
|
+
return item.short == "AIservice";
|
|
578
|
+
})) {
|
|
579
|
+
var sendData = {
|
|
580
|
+
//相关数据
|
|
581
|
+
roomId: roomId,
|
|
582
|
+
message: questions.question,
|
|
583
|
+
quotedMessage: "",
|
|
584
|
+
regenerate: true,
|
|
585
|
+
generateUpvoteOrDownvoteMessage: false
|
|
586
|
+
};
|
|
587
|
+
if (pageNumHistory <= 1) {
|
|
588
|
+
setHistoryMessageList(function(historyMessageList) {
|
|
589
|
+
var newHistoryMessageList = historyMessageList.concat({
|
|
590
|
+
roomId: roomId,
|
|
591
|
+
sender: mid,
|
|
592
|
+
recevier: "AI",
|
|
593
|
+
message: questions.question,
|
|
594
|
+
quotedMessage: "",
|
|
595
|
+
id: "654321",
|
|
596
|
+
upvoted: false,
|
|
597
|
+
downvoted: false,
|
|
598
|
+
createdAt: getDataTime(-1),
|
|
599
|
+
extraInfo: JSON.stringify([])
|
|
600
|
+
});
|
|
601
|
+
return newHistoryMessageList;
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
setFinished(false);
|
|
605
|
+
aiSendQuestions(3, sendData, 1);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
console.log(questions, "知识库内容11111");
|
|
541
609
|
//向知识库发送问题 type 1,发送问题 2 发送答案 obj 需要的参数
|
|
542
610
|
var obj = {
|
|
543
611
|
roomId: roomId,
|
|
@@ -563,7 +631,7 @@ var CustomerService = function(props) {
|
|
|
563
631
|
} else if (userData.modules.some(function(item) {
|
|
564
632
|
return item.short == "AIservice";
|
|
565
633
|
})) {
|
|
566
|
-
var
|
|
634
|
+
var sendData1 = {
|
|
567
635
|
//相关数据
|
|
568
636
|
roomId: roomId,
|
|
569
637
|
message: keyWord,
|
|
@@ -572,16 +640,8 @@ var CustomerService = function(props) {
|
|
|
572
640
|
generateUpvoteOrDownvoteMessage: false
|
|
573
641
|
};
|
|
574
642
|
var imageUrl = "";
|
|
575
|
-
// if(citationContent.imageUrl){
|
|
576
|
-
// sendData.image = citationContent.imageUrl;
|
|
577
|
-
// imageUrl = citationContent.imageUrl;
|
|
578
|
-
// getBase64Image(citationContent.imageUrl).then((res)=>{
|
|
579
|
-
// console.log(res,33333);
|
|
580
|
-
// });
|
|
581
|
-
// console.log(imageUrl,'转换的bese64');
|
|
582
|
-
// }
|
|
583
643
|
if (screenshotBese64) {
|
|
584
|
-
|
|
644
|
+
sendData1.image = screenshotBese64;
|
|
585
645
|
imageUrl = screenshotBese64;
|
|
586
646
|
}
|
|
587
647
|
if (pageNumHistory <= 1) {
|
|
@@ -607,7 +667,7 @@ var CustomerService = function(props) {
|
|
|
607
667
|
});
|
|
608
668
|
}
|
|
609
669
|
setFinished(false);
|
|
610
|
-
aiSendQuestions(3,
|
|
670
|
+
aiSendQuestions(3, sendData1, 1);
|
|
611
671
|
setScreenshotBese64("");
|
|
612
672
|
//存在AI客服
|
|
613
673
|
} else {
|
|
@@ -698,6 +758,22 @@ var CustomerService = function(props) {
|
|
|
698
758
|
});
|
|
699
759
|
});
|
|
700
760
|
}, 60 * 1000);
|
|
761
|
+
if (props.config && props.config.type == "video" && props.config.params) {
|
|
762
|
+
var params = props.config.params;
|
|
763
|
+
var videoId = params.videoId;
|
|
764
|
+
var watchTime = params.videoProgress;
|
|
765
|
+
var courseId = getQuery("yc_id");
|
|
766
|
+
var sectionId = params.VideoBriefSummaryId;
|
|
767
|
+
obj.contexts = [
|
|
768
|
+
{
|
|
769
|
+
"type": "VIDEO",
|
|
770
|
+
"courseId": courseId,
|
|
771
|
+
"sectionId": sectionId,
|
|
772
|
+
"videoId": videoId,
|
|
773
|
+
"watchTime": watchTime
|
|
774
|
+
}
|
|
775
|
+
];
|
|
776
|
+
}
|
|
701
777
|
var data = JSON.stringify(obj);
|
|
702
778
|
setKeyWord("");
|
|
703
779
|
setQuestionsList([]);
|
|
@@ -1245,8 +1321,7 @@ var CustomerService = function(props) {
|
|
|
1245
1321
|
} else if (flag == 4) {
|
|
1246
1322
|
data = {
|
|
1247
1323
|
page: 1,
|
|
1248
|
-
maxPageSize: 4
|
|
1249
|
-
question: value
|
|
1324
|
+
maxPageSize: 4
|
|
1250
1325
|
};
|
|
1251
1326
|
} else {
|
|
1252
1327
|
data = {
|
|
@@ -1263,7 +1338,7 @@ var CustomerService = function(props) {
|
|
|
1263
1338
|
if (flag == 1) {
|
|
1264
1339
|
setHotQuestionsList(questionList);
|
|
1265
1340
|
} else if (flag == 4) {
|
|
1266
|
-
|
|
1341
|
+
setHotQuestionsList(function(questionList) {
|
|
1267
1342
|
return _to_consumable_array(questionList).concat(_to_consumable_array(res.data.questions));
|
|
1268
1343
|
});
|
|
1269
1344
|
} else {
|
|
@@ -1287,9 +1362,8 @@ var CustomerService = function(props) {
|
|
|
1287
1362
|
var videoId = params.videoId;
|
|
1288
1363
|
var watchTime = params.videoProgress;
|
|
1289
1364
|
var courseId = getQuery("yc_id");
|
|
1290
|
-
var sectionId =
|
|
1291
|
-
if (videoId &&
|
|
1292
|
-
console.log("请求接口2222", config);
|
|
1365
|
+
var sectionId = params.VideoBriefSummaryId;
|
|
1366
|
+
if (videoId && courseId && sectionId) {
|
|
1293
1367
|
http.post("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions:recommend"), {
|
|
1294
1368
|
"recommendedQuestions": flag == 2 ? recommendeQuestionID.current : [
|
|
1295
1369
|
""
|
|
@@ -1316,6 +1390,9 @@ var CustomerService = function(props) {
|
|
|
1316
1390
|
resettingBottomHei();
|
|
1317
1391
|
scrollToBottom();
|
|
1318
1392
|
console.log(data, 99999);
|
|
1393
|
+
if (data.length < 4) {
|
|
1394
|
+
getQuestiionsList("", 4);
|
|
1395
|
+
}
|
|
1319
1396
|
}
|
|
1320
1397
|
}).catch(function() {});
|
|
1321
1398
|
}
|
|
@@ -1700,6 +1777,9 @@ var CustomerService = function(props) {
|
|
|
1700
1777
|
var timeObj = parseDate(item.createdAt);
|
|
1701
1778
|
// console.log(item.message);
|
|
1702
1779
|
var message = item.message;
|
|
1780
|
+
if (message == "抱歉,我暂时无法回答这样的问题。" && props.config && props.config.type == "video") {
|
|
1781
|
+
videoPageQuestiionsList(2);
|
|
1782
|
+
}
|
|
1703
1783
|
var li;
|
|
1704
1784
|
// 是否需要显示日期
|
|
1705
1785
|
var itemIndex = historyMessageList.findIndex(function(ite) {
|