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.
@@ -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
- // import dayjs from 'dayjs';
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
- // if(historyMessageList[i+1] != undefined && historyMessageList[i+1].createdAt != undefined && item.createdAt != undefined && item.createdAt != historyMessageList[i+1].createdAt){
1380
- // time = getDataTime(item.createdAt);
1381
- // }else{
1382
- // time = getDataTime(item.createdAt);
1383
- // }
1384
- // let time1;
1385
- // if(item.createdAt != undefined){
1386
- // time1 = Date.parse(item.createdAt);
1387
- // }
1388
- // let time2 = Date.parse(historyMessageList[i+1]);
1389
- // if (itemIndex <= 0) {
1390
- // //第一项
1391
- // time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1392
- // } else {
1393
- // //非第一项 与上一项进行对比
1394
- // let beforeTime = historyMessageList[itemIndex - 1].createdAt;
1395
- // //判断与上一条数据 是否跨天
1396
- // if (
1397
- // dayjs(beforeTime).format("YYYY-MM-DD") !==
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,9 @@
1
+ declare const parseDate: (dateStr: string) => {
2
+ year: string;
3
+ month: string;
4
+ day: string;
5
+ hours: string;
6
+ minutes: string;
7
+ seconds: string;
8
+ };
9
+ export { parseDate };
@@ -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
- // import dayjs from 'dayjs';
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
- // if(historyMessageList[i+1] != undefined && historyMessageList[i+1].createdAt != undefined && item.createdAt != undefined && item.createdAt != historyMessageList[i+1].createdAt){
1438
- // time = getDataTime(item.createdAt);
1439
- // }else{
1440
- // time = getDataTime(item.createdAt);
1441
- // }
1442
- // let time1;
1443
- // if(item.createdAt != undefined){
1444
- // time1 = Date.parse(item.createdAt);
1445
- // }
1446
- // let time2 = Date.parse(historyMessageList[i+1]);
1447
- // if (itemIndex <= 0) {
1448
- // //第一项
1449
- // time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1450
- // } else {
1451
- // //非第一项 与上一项进行对比
1452
- // let beforeTime = historyMessageList[itemIndex - 1].createdAt;
1453
- // //判断与上一条数据 是否跨天
1454
- // if (
1455
- // dayjs(beforeTime).format("YYYY-MM-DD") !==
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,9 @@
1
+ declare const parseDate: (dateStr: string) => {
2
+ year: string;
3
+ month: string;
4
+ day: string;
5
+ hours: string;
6
+ minutes: string;
7
+ seconds: string;
8
+ };
9
+ export { parseDate };
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",