bhd-components 0.5.8 → 0.5.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/dist/{f2b01b9c.esm.es5.development.js → 4a44b71b.esm.es5.development.js} +1 -1
- package/dist/{5764783e.esm.es5.production.js → e7b4aef5.esm.es5.production.js} +1 -1
- package/dist/index.esm.es5.development.js +52 -6
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/customerService/index.js +22 -35
- package/es2017/utils/Date.d.ts +9 -0
- package/es2017/utils/Date.js +18 -0
- package/esm/customerService/index.js +22 -35
- package/esm/utils/Date.d.ts +9 -0
- package/esm/utils/Date.js +18 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import { CustomAiIcon, CustomRecord, CustomFullScreen, CustomExitFullScreen, Cus
|
|
|
9
9
|
import { CloseOutlined } from "@ant-design/icons";
|
|
10
10
|
import HistoryFun from "./historyFun/index";
|
|
11
11
|
import ContactsList from "./contactsList/index";
|
|
12
|
-
|
|
12
|
+
import { parseDate } from "../utils/Date";
|
|
13
13
|
import { Remarkable } from "remarkable";
|
|
14
14
|
import hljs from "highlight.js";
|
|
15
15
|
import "highlight.js/styles/default.css";
|
|
@@ -21,7 +21,6 @@ import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
|
|
|
21
21
|
import { readMessage, getByteLen, serverUrl, copyText, getDataTime } from "./function"; //一些方法
|
|
22
22
|
const CustomerService = (props)=>{
|
|
23
23
|
let { userData , http , urllocation , onCancel , serverName , fetchEventSource , initShowType , onEvent , stepIds , stepId } = props;
|
|
24
|
-
// urllocation = "/zhong";
|
|
25
24
|
const [mid, setmid] = useState(props.userData.mid); //当前用户id
|
|
26
25
|
const { bese64String , startRecord , stopRecord } = useMediaRecorder(); //语音转文字
|
|
27
26
|
const [voiceRecordingStatus, setVoiceRecordingStatus] = useState(3); //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
|
|
@@ -1364,51 +1363,39 @@ const CustomerService = (props)=>{
|
|
|
1364
1363
|
};
|
|
1365
1364
|
//渲染问答
|
|
1366
1365
|
const renderQuestion = ()=>{
|
|
1366
|
+
// 2023-12-01T14:34:07
|
|
1367
1367
|
// console.log(lastId,'lastIdlastIdlastId')
|
|
1368
1368
|
// console.log(mid, historyMessageList, "ddkfdscksdcs");
|
|
1369
1369
|
if (historyMessageList.length > 0) {
|
|
1370
1370
|
return /*#__PURE__*/ _jsx("ul", {
|
|
1371
1371
|
className: styles.message_con,
|
|
1372
1372
|
children: historyMessageList.map((item, i)=>{
|
|
1373
|
+
let timeObj = parseDate(item.createdAt);
|
|
1373
1374
|
// console.log(item.message);
|
|
1374
1375
|
let message = item.message;
|
|
1375
1376
|
let li;
|
|
1376
1377
|
// 是否需要显示日期
|
|
1377
1378
|
let itemIndex = historyMessageList.findIndex((ite)=>ite.id === item.id);
|
|
1378
1379
|
let time = "";
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
// dayjs(item.createdAt).format("YYYY-MM-DD")
|
|
1399
|
-
// ) {
|
|
1400
|
-
// time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
|
|
1401
|
-
// } else {
|
|
1402
|
-
// //没有跨天 判断是否相隔超过10分钟
|
|
1403
|
-
// if (
|
|
1404
|
-
// dayjs(item.createdAt).valueOf() -
|
|
1405
|
-
// dayjs(beforeTime).valueOf() >
|
|
1406
|
-
// 10 * 60 * 1000
|
|
1407
|
-
// ) {
|
|
1408
|
-
// time = dayjs(item.createdAt).format("HH:mm");
|
|
1409
|
-
// }
|
|
1410
|
-
// }
|
|
1411
|
-
// }
|
|
1380
|
+
if (itemIndex <= 0) {
|
|
1381
|
+
//第一项
|
|
1382
|
+
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
1383
|
+
} else {
|
|
1384
|
+
//非第一项 与上一项进行对比
|
|
1385
|
+
let beforeTime = historyMessageList[itemIndex - 1].createdAt;
|
|
1386
|
+
//判断与上一条数据 是否跨天
|
|
1387
|
+
let beforeTimeObj = parseDate(beforeTime);
|
|
1388
|
+
let beforeTimeStr = `${beforeTimeObj.year}-${beforeTimeObj.month}-${beforeTimeObj.day}`;
|
|
1389
|
+
let curTimeStr = `${timeObj.year}-${timeObj.month}-${timeObj.day}`;
|
|
1390
|
+
if (beforeTimeStr !== curTimeStr) {
|
|
1391
|
+
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
1392
|
+
} else {
|
|
1393
|
+
//没有跨天 判断是否相隔超过10分钟
|
|
1394
|
+
if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
1395
|
+
time = `${timeObj.minutes}:${timeObj.seconds}`;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1412
1399
|
let dataTime = time;
|
|
1413
1400
|
if (item.sender == mid) {
|
|
1414
1401
|
//只有引用和复制功能
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const parseDate = (dateStr)=>{
|
|
2
|
+
const date = new Date(dateStr); // 创建一个日期对象,表示当前时间
|
|
3
|
+
const year = date.getFullYear().toString(); // 获取年份
|
|
4
|
+
const month = String(date.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
|
|
5
|
+
const day = String(date.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
|
|
6
|
+
const hours = String(date.getHours()).padStart(2, "0"); // 获取小时,并补齐两位数
|
|
7
|
+
const minutes = String(date.getMinutes()).padStart(2, "0"); // 获取分钟,并补齐两位数
|
|
8
|
+
const seconds = String(date.getSeconds()).padStart(2, "0"); // 获取秒数,并补齐两位数
|
|
9
|
+
return {
|
|
10
|
+
year,
|
|
11
|
+
month,
|
|
12
|
+
day,
|
|
13
|
+
hours,
|
|
14
|
+
minutes,
|
|
15
|
+
seconds
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export { parseDate };
|
|
@@ -10,7 +10,7 @@ import { CustomAiIcon, CustomRecord, CustomFullScreen, CustomExitFullScreen, Cus
|
|
|
10
10
|
import { CloseOutlined } from "@ant-design/icons";
|
|
11
11
|
import HistoryFun from "./historyFun/index";
|
|
12
12
|
import ContactsList from "./contactsList/index";
|
|
13
|
-
|
|
13
|
+
import { parseDate } from "../utils/Date";
|
|
14
14
|
import { Remarkable } from "remarkable";
|
|
15
15
|
import hljs from "highlight.js";
|
|
16
16
|
import "highlight.js/styles/default.css";
|
|
@@ -22,7 +22,6 @@ import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
|
|
|
22
22
|
import { readMessage, getByteLen, serverUrl, copyText, getDataTime } from "./function"; //一些方法
|
|
23
23
|
var CustomerService = function(props) {
|
|
24
24
|
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;
|
|
25
|
-
// urllocation = "/zhong";
|
|
26
25
|
var _useState = _sliced_to_array(useState(props.userData.mid), 2), mid = _useState[0], setmid = _useState[1]; //当前用户id
|
|
27
26
|
var _useMediaRecorder = useMediaRecorder(), bese64String = _useMediaRecorder.bese64String, startRecord = _useMediaRecorder.startRecord, stopRecord = _useMediaRecorder.stopRecord; //语音转文字
|
|
28
27
|
var _useState1 = _sliced_to_array(useState(3), 2), voiceRecordingStatus = _useState1[0], setVoiceRecordingStatus = _useState1[1]; //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
|
|
@@ -1420,12 +1419,14 @@ var CustomerService = function(props) {
|
|
|
1420
1419
|
};
|
|
1421
1420
|
//渲染问答
|
|
1422
1421
|
var renderQuestion = function() {
|
|
1422
|
+
// 2023-12-01T14:34:07
|
|
1423
1423
|
// console.log(lastId,'lastIdlastIdlastId')
|
|
1424
1424
|
// console.log(mid, historyMessageList, "ddkfdscksdcs");
|
|
1425
1425
|
if (historyMessageList.length > 0) {
|
|
1426
1426
|
return /*#__PURE__*/ _jsx("ul", {
|
|
1427
1427
|
className: styles.message_con,
|
|
1428
1428
|
children: historyMessageList.map(function(item, i) {
|
|
1429
|
+
var timeObj = parseDate(item.createdAt);
|
|
1429
1430
|
// console.log(item.message);
|
|
1430
1431
|
var message = item.message;
|
|
1431
1432
|
var li;
|
|
@@ -1434,39 +1435,25 @@ var CustomerService = function(props) {
|
|
|
1434
1435
|
return ite.id === item.id;
|
|
1435
1436
|
});
|
|
1436
1437
|
var time = "";
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
// dayjs(item.createdAt).format("YYYY-MM-DD")
|
|
1457
|
-
// ) {
|
|
1458
|
-
// time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
|
|
1459
|
-
// } else {
|
|
1460
|
-
// //没有跨天 判断是否相隔超过10分钟
|
|
1461
|
-
// if (
|
|
1462
|
-
// dayjs(item.createdAt).valueOf() -
|
|
1463
|
-
// dayjs(beforeTime).valueOf() >
|
|
1464
|
-
// 10 * 60 * 1000
|
|
1465
|
-
// ) {
|
|
1466
|
-
// time = dayjs(item.createdAt).format("HH:mm");
|
|
1467
|
-
// }
|
|
1468
|
-
// }
|
|
1469
|
-
// }
|
|
1438
|
+
if (itemIndex <= 0) {
|
|
1439
|
+
//第一项
|
|
1440
|
+
time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
|
|
1441
|
+
} else {
|
|
1442
|
+
//非第一项 与上一项进行对比
|
|
1443
|
+
var beforeTime = historyMessageList[itemIndex - 1].createdAt;
|
|
1444
|
+
//判断与上一条数据 是否跨天
|
|
1445
|
+
var beforeTimeObj = parseDate(beforeTime);
|
|
1446
|
+
var beforeTimeStr = "".concat(beforeTimeObj.year, "-").concat(beforeTimeObj.month, "-").concat(beforeTimeObj.day);
|
|
1447
|
+
var curTimeStr = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day);
|
|
1448
|
+
if (beforeTimeStr !== curTimeStr) {
|
|
1449
|
+
time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
|
|
1450
|
+
} else {
|
|
1451
|
+
//没有跨天 判断是否相隔超过10分钟
|
|
1452
|
+
if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
1453
|
+
time = "".concat(timeObj.minutes, ":").concat(timeObj.seconds);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1470
1457
|
var dataTime = time;
|
|
1471
1458
|
if (item.sender == mid) {
|
|
1472
1459
|
//只有引用和复制功能
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var parseDate = function(dateStr) {
|
|
2
|
+
var date = new Date(dateStr); // 创建一个日期对象,表示当前时间
|
|
3
|
+
var year = date.getFullYear().toString(); // 获取年份
|
|
4
|
+
var month = String(date.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
|
|
5
|
+
var day = String(date.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
|
|
6
|
+
var hours = String(date.getHours()).padStart(2, "0"); // 获取小时,并补齐两位数
|
|
7
|
+
var minutes = String(date.getMinutes()).padStart(2, "0"); // 获取分钟,并补齐两位数
|
|
8
|
+
var seconds = String(date.getSeconds()).padStart(2, "0"); // 获取秒数,并补齐两位数
|
|
9
|
+
return {
|
|
10
|
+
year: year,
|
|
11
|
+
month: month,
|
|
12
|
+
day: day,
|
|
13
|
+
hours: hours,
|
|
14
|
+
minutes: minutes,
|
|
15
|
+
seconds: seconds
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export { parseDate };
|