bhd-components 0.7.7 → 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.
@@ -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;
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
4
4
  import React, { useEffect, useState, useRef } from "react";
5
5
  import { Modal, Drawer, Input, Tooltip } from "antd";
6
6
  import { ViewImage } from "bhd-components";
7
- import html2canvas from "html2canvas";
7
+ // import html2canvas from "html2canvas";
8
8
  import cssStyle from "./index.module.less";
9
9
  import cssStyleOnline from "./index2.module.less";
10
10
  let styles = cssStyle;
@@ -23,11 +23,12 @@ import "highlight.js/styles/default.css";
23
23
  import { render } from "react-dom";
24
24
  import Provider from "../provider";
25
25
  const { TextArea } = Input;
26
+ import "./html2canvas.test.js";
26
27
  import knowledge_icon from "./images/knowledge_icon.png";
27
28
  // import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
28
29
  import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate } from "./function"; //一些方法
29
30
  const CustomerService = (props)=>{
30
- let { userData , http , urllocation , onCancel , serverName , fetchEventSource , initShowType , onEvent , stepIds , stepId , config } = props;
31
+ let { userData , http , urllocation , onCancel , serverName , fetchEventSource , initShowType , onEvent , stepIds , stepId , screenshotAreaId , config } = props;
31
32
  // const { bese64String, startRecord, stopRecord } = useMediaRecorder(); //语音转文字
32
33
  // const [voiceRecordingStatus, setVoiceRecordingStatus] = useState(3); //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
33
34
  const [copyTextOBJ, setCopyTextObj] = useState([]); //复制的消息id
@@ -90,28 +91,58 @@ const CustomerService = (props)=>{
90
91
  });
91
92
  useEffect(()=>{
92
93
  if (showType == 5) {
93
- setImgBese64('');
94
- html2canvas(document.getElementsByTagName('html')[0]).then((canvas)=>{
95
- console.log(canvas, 22222);
96
- setTimeout(()=>{
97
- let dom = document.getElementById("container_html5_api");
98
- // let dom = document.getElementById("__docusaurus");
99
- html2canvas(dom, {
100
- backgroundColor: null,
101
- useCORS: true,
102
- allowTaint: true,
103
- scale: 1,
104
- logging: false
105
- }).then(function(canvas) {
106
- // document.body.appendChild(canvas);
107
- console.log(canvas, 4444444);
108
- // var base64URL = canvas.toDataURL('image/jpeg')
109
- // let base64URL=canvas.toDataURL("image/jpg", 1.0)
110
- let base64URL = canvas.toDataURL("image/png");
111
- setImgBese64(base64URL);
112
- });
113
- }, 100);
114
- });
94
+ // 获取屏幕流
95
+ // 获取 video 元素和 canvas 元素
96
+ // var video = document.getElementById('container_html5_api');
97
+ // // const canvas = document.createElement('canvas');
98
+ // const canvas = document.getElementById('canvas_test');
99
+ // var context = canvas.getContext('2d');
100
+ // // 设置 canvas 尺寸
101
+ // canvas.width = video.videoWidth/4;
102
+ // canvas.height = video.videoHeight/4;
103
+ // // 在 canvas 上绘制 video 的当前帧
104
+ // context.drawImage(video, 0, 0, canvas.width, canvas.height);
105
+ // // 使用 html2canvas 对 canvas 进行截图
106
+ // html2canvas(canvas,{
107
+ // scale: 1,
108
+ // useCORS: true,
109
+ // logging: true,
110
+ // }).then(function(screenshot) {
111
+ // // 将截图显示在页面上,或者进行其他操作
112
+ // document.body.appendChild(screenshot);
113
+ // setTimeout(()=>{
114
+ // let url = screenshot.toDataURL('image/png');
115
+ // console.log(url);
116
+ // },3000)
117
+ // // console.log("container_html5_apicontainer_html5_api",screenshot)
118
+ // // console.log(screenshot.toDataURL('image/jpeg'))
119
+ // });
120
+ // // 显示图片或者做其他操作
121
+ try {
122
+ setImgBese64('');
123
+ html2canvas(document.getElementsByTagName('html')[0]).then((canvas)=>{
124
+ console.log(canvas, 22222);
125
+ setTimeout(()=>{
126
+ let dom = document.getElementById(screenshotAreaId);
127
+ //let dom = document.getElementById("container_html5_api");
128
+ //let dom = document.getElementsByTagName('html')[0];
129
+ html2canvas(dom, {
130
+ useCORS: true,
131
+ // allowTaint: true, // 污染处理
132
+ scale: 1
133
+ }).then(function(canvas) {
134
+ // document.body.appendChild(canvas);
135
+ // document.body.appendChild(canvas);
136
+ console.log(canvas, 4444444);
137
+ // var base64URL = canvas.toDataURL('image/jpeg')
138
+ let base64URL = canvas.toDataURL("image/jpg", 1.0);
139
+ setImgBese64(base64URL);
140
+ });
141
+ }, 100);
142
+ });
143
+ } catch (error) {
144
+ console.log(error);
145
+ }
115
146
  }
116
147
  if (showType != 1 && !firstLoad && pageCount > 0) {
117
148
  setFirstLoad(true);
@@ -326,8 +357,9 @@ const CustomerService = (props)=>{
326
357
  };
327
358
  if (pageNumHistory <= 1) {
328
359
  setHistoryMessageList((historyMessageList)=>{
329
- let newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
330
- id: new Date().getTime() + 'dede',
360
+ let newHistoryMessageList = historyMessageList.filter((e)=>e.id != '123456_date');
361
+ newHistoryMessageList.push(_object_spread_props(_object_spread({}, obj), {
362
+ id: '123456_date',
331
363
  upvoted: false,
332
364
  downvoted: false,
333
365
  quotedMessage: "",
@@ -528,6 +560,38 @@ const CustomerService = (props)=>{
528
560
  //点击知识库的问题,或者是点击问候消息
529
561
  if (questions.length > 0) {
530
562
  questions = questions[0];
563
+ //知识库联想的问题没有答案
564
+ if (!questions.answer && userData.modules.some((item)=>item.short == "AIservice")) {
565
+ let sendData = {
566
+ //相关数据
567
+ roomId: roomId,
568
+ message: questions.question,
569
+ quotedMessage: '',
570
+ regenerate: true,
571
+ generateUpvoteOrDownvoteMessage: false
572
+ };
573
+ if (pageNumHistory <= 1) {
574
+ setHistoryMessageList((historyMessageList)=>{
575
+ let newHistoryMessageList = historyMessageList.concat({
576
+ roomId: roomId,
577
+ sender: mid,
578
+ recevier: "AI",
579
+ message: questions.question,
580
+ quotedMessage: '',
581
+ id: "654321",
582
+ upvoted: false,
583
+ downvoted: false,
584
+ createdAt: getDataTime(-1),
585
+ extraInfo: JSON.stringify([])
586
+ });
587
+ return newHistoryMessageList;
588
+ });
589
+ }
590
+ setFinished(false);
591
+ aiSendQuestions(3, sendData, 1);
592
+ return;
593
+ }
594
+ console.log(questions, '知识库内容11111');
531
595
  //向知识库发送问题 type 1,发送问题 2 发送答案 obj 需要的参数
532
596
  let obj = {
533
597
  roomId: roomId,
@@ -560,14 +624,6 @@ const CustomerService = (props)=>{
560
624
  generateUpvoteOrDownvoteMessage: false
561
625
  };
562
626
  let imageUrl = '';
563
- // if(citationContent.imageUrl){
564
- // sendData.image = citationContent.imageUrl;
565
- // imageUrl = citationContent.imageUrl;
566
- // getBase64Image(citationContent.imageUrl).then((res)=>{
567
- // console.log(res,33333);
568
- // });
569
- // console.log(imageUrl,'转换的bese64');
570
- // }
571
627
  if (screenshotBese64) {
572
628
  sendData.image = screenshotBese64;
573
629
  imageUrl = screenshotBese64;
@@ -684,6 +740,22 @@ const CustomerService = (props)=>{
684
740
  });
685
741
  });
686
742
  }, 60 * 1000);
743
+ if (props.config && props.config.type == 'video' && props.config.params) {
744
+ let params = props.config.params;
745
+ let videoId = params.videoId;
746
+ let watchTime = params.videoProgress;
747
+ let courseId = getQuery('yc_id');
748
+ let sectionId = params.VideoBriefSummaryId;
749
+ obj.contexts = [
750
+ {
751
+ "type": "VIDEO",
752
+ "courseId": courseId,
753
+ "sectionId": sectionId,
754
+ "videoId": videoId,
755
+ "watchTime": watchTime
756
+ }
757
+ ];
758
+ }
687
759
  let data = JSON.stringify(obj);
688
760
  setKeyWord("");
689
761
  setQuestionsList([]);
@@ -1212,8 +1284,7 @@ const CustomerService = (props)=>{
1212
1284
  } else if (flag == 4) {
1213
1285
  data = {
1214
1286
  page: 1,
1215
- maxPageSize: 4,
1216
- question: value
1287
+ maxPageSize: 4
1217
1288
  };
1218
1289
  } else {
1219
1290
  data = {
@@ -1230,7 +1301,7 @@ const CustomerService = (props)=>{
1230
1301
  if (flag == 1) {
1231
1302
  setHotQuestionsList(questionList);
1232
1303
  } else if (flag == 4) {
1233
- setQuestionsList((questionList)=>{
1304
+ setHotQuestionsList((questionList)=>{
1234
1305
  return [
1235
1306
  ...questionList,
1236
1307
  ...res.data.questions
@@ -1256,9 +1327,8 @@ const CustomerService = (props)=>{
1256
1327
  let videoId = params.videoId;
1257
1328
  let watchTime = params.videoProgress;
1258
1329
  let courseId = getQuery('yc_id');
1259
- let sectionId = getQuery('s_id');
1260
- if (videoId && watchTime && courseId && sectionId) {
1261
- console.log('请求接口2222', config);
1330
+ let sectionId = params.VideoBriefSummaryId;
1331
+ if (videoId && courseId && sectionId) {
1262
1332
  http.post(`${urllocation}/chat-service/public/v1.0/knowledge-base/questions:recommend`, {
1263
1333
  "recommendedQuestions": flag == 2 ? recommendeQuestionID.current : [
1264
1334
  ''
@@ -1285,6 +1355,9 @@ const CustomerService = (props)=>{
1285
1355
  resettingBottomHei();
1286
1356
  scrollToBottom();
1287
1357
  console.log(data, 99999);
1358
+ if (data.length < 4) {
1359
+ getQuestiionsList('', 4);
1360
+ }
1288
1361
  }
1289
1362
  }).catch(()=>{});
1290
1363
  }
@@ -1655,6 +1728,9 @@ const CustomerService = (props)=>{
1655
1728
  let timeObj = parseDate(item.createdAt);
1656
1729
  // console.log(item.message);
1657
1730
  let message = item.message;
1731
+ if (message == '抱歉,我暂时无法回答这样的问题。' && props.config && props.config.type == 'video') {
1732
+ videoPageQuestiionsList(2);
1733
+ }
1658
1734
  let li;
1659
1735
  // 是否需要显示日期
1660
1736
  let itemIndex = historyMessageList.findIndex((ite)=>ite.id === item.id);
@@ -910,7 +910,7 @@
910
910
  margin: 0 16px;
911
911
  // padding-bottom: 4px;
912
912
  line-height: 1;
913
- // padding-top: 24px;
913
+ padding-top: 24px;
914
914
  p{
915
915
  padding: 8px 16px;
916
916
  background-color: #fff;