bhd-components 0.7.20 → 0.7.22
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/{d70309d9.esm.es5.production.js → cf6d2143.esm.es5.production.js} +1 -1
- package/dist/{519bd9ca.esm.es5.development.js → fcb57c77.esm.es5.development.js} +1 -1
- package/dist/index.esm.es5.development.css +505 -10887
- package/dist/index.esm.es5.development.js +758 -1396
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/customerService/contactsList.js +6 -21
- package/es2017/customerService/function.d.ts +3 -1
- package/es2017/customerService/function.js +45 -1
- package/es2017/customerService/historyFun.js +17 -23
- package/es2017/customerService/index.js +214 -318
- package/es2017/customerService/index.module.less +14 -1
- package/es2017/customerService/teacherList.d.ts +11 -0
- package/es2017/customerService/teacherList.js +258 -0
- package/esm/customerService/contactsList.js +6 -21
- package/esm/customerService/function.d.ts +3 -1
- package/esm/customerService/function.js +45 -1
- package/esm/customerService/historyFun.js +17 -23
- package/esm/customerService/index.js +231 -344
- package/esm/customerService/index.module.less +14 -1
- package/esm/customerService/teacherList.d.ts +11 -0
- package/esm/customerService/teacherList.js +273 -0
- package/package.json +1 -1
|
@@ -4,19 +4,12 @@ import styles from "./index.module.less";
|
|
|
4
4
|
import { Tooltip } from "antd";
|
|
5
5
|
import { CustomAiIcon, CustomRetract } from "../icons/index";
|
|
6
6
|
import { CloseOutlined } from "@ant-design/icons";
|
|
7
|
-
import {
|
|
7
|
+
import { getByteLen, formatDate } from "./function"; //录音使用文件
|
|
8
8
|
const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
9
9
|
let { type , roomId , userData , http , urllocation , onClose , switchChatRoom , contactsList } = props;
|
|
10
|
-
// useImperativeHandle(ref, () => ({
|
|
11
|
-
// roomsListTimer: () => {
|
|
12
|
-
// return roomsListTimer();
|
|
13
|
-
// },
|
|
14
|
-
// roomsList:contactsList,
|
|
15
|
-
// }),[contactsList]);
|
|
16
10
|
//删除聊天室
|
|
17
11
|
const deleteRoom = (roomId)=>{
|
|
18
|
-
http.delete(`${urllocation}/chat-service/public/v1.0/rooms/${roomId}`, {
|
|
19
|
-
}).then((res)=>{
|
|
12
|
+
http.delete(`${urllocation}/chat-service/public/v1.0/rooms/${roomId}`, {}).then((res)=>{
|
|
20
13
|
// roomsListTimer();
|
|
21
14
|
switchChatRoom(roomId, '1');
|
|
22
15
|
});
|
|
@@ -41,7 +34,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
41
34
|
userData.modules.some((ele)=>ele.short == "AIservice") ? "AI助手" : "智能问答",
|
|
42
35
|
/*#__PURE__*/ _jsx("span", {
|
|
43
36
|
className: styles.time,
|
|
44
|
-
children: contactsList.length > 0 && contactsList[0].createdAt != undefined &&
|
|
37
|
+
children: contactsList.length > 0 && contactsList[0].createdAt != undefined && formatDate(contactsList[0].createdAt)
|
|
45
38
|
})
|
|
46
39
|
]
|
|
47
40
|
}),
|
|
@@ -54,18 +47,10 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
54
47
|
]
|
|
55
48
|
})
|
|
56
49
|
}),
|
|
57
|
-
userData.modules.some((item)=>item.short == "TeacherAnswer")
|
|
50
|
+
userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("div", {
|
|
58
51
|
className: styles.bottom,
|
|
59
52
|
children: contactsList.map((item, index)=>{
|
|
60
53
|
if (index != 0) {
|
|
61
|
-
let time = '';
|
|
62
|
-
let currentTime = getDataTime(-1, 1); //当前时间
|
|
63
|
-
let updatedAt = getDataTime(item.createdAt, 1);
|
|
64
|
-
if (currentTime == updatedAt) {
|
|
65
|
-
time = getDataTime(item.createdAt, 2);
|
|
66
|
-
} else {
|
|
67
|
-
time = getDataTime(item.createdAt);
|
|
68
|
-
}
|
|
69
54
|
return /*#__PURE__*/ _jsxs("div", {
|
|
70
55
|
className: `${styles.ai} ${item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""}`,
|
|
71
56
|
onClick: ()=>{
|
|
@@ -93,7 +78,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
93
78
|
}),
|
|
94
79
|
/*#__PURE__*/ _jsx("span", {
|
|
95
80
|
className: styles.time,
|
|
96
|
-
children:
|
|
81
|
+
children: formatDate(item.createdAt)
|
|
97
82
|
})
|
|
98
83
|
]
|
|
99
84
|
}),
|
|
@@ -109,7 +94,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
109
94
|
return null;
|
|
110
95
|
}
|
|
111
96
|
})
|
|
112
|
-
})
|
|
97
|
+
})
|
|
113
98
|
]
|
|
114
99
|
}) : /*#__PURE__*/ _jsxs("div", {
|
|
115
100
|
className: `${styles.teacher_layout} ${type == 3 ? styles.teacher_layout_newlabo : ""}`,
|
|
@@ -19,4 +19,6 @@ declare const getQuery: (name: string) => string;
|
|
|
19
19
|
declare const findParent: (e: any, className: string) => any;
|
|
20
20
|
declare const delegate: (element: any, eventType: string, selector: string, callback: any) => void;
|
|
21
21
|
declare const getBase64Image: (src: any) => Promise<unknown>;
|
|
22
|
-
|
|
22
|
+
declare const formatDate: (dateStr: any) => any;
|
|
23
|
+
declare const urlToBase64: (url: string) => Promise<unknown>;
|
|
24
|
+
export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
|
|
@@ -133,4 +133,48 @@ const getBase64Image = (src)=>{
|
|
|
133
133
|
};
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
|
-
|
|
136
|
+
const formatDate = (dateStr)=>{
|
|
137
|
+
const today = new Date();
|
|
138
|
+
const date = new Date(dateStr);
|
|
139
|
+
const dayDiff = Math.ceil((today - date) / (1000 * 60 * 60 * 24)); // 计算天数差
|
|
140
|
+
// console.log(dayDiff,'dayDiffdayDiff',today,'___',date);
|
|
141
|
+
if (dayDiff === 0 || dayDiff === 1) {
|
|
142
|
+
// 今天
|
|
143
|
+
return date.toLocaleTimeString('zh-CN', {
|
|
144
|
+
hour12: false
|
|
145
|
+
}).substring(0, 5);
|
|
146
|
+
} else if (dayDiff <= 7) {
|
|
147
|
+
// 一周内
|
|
148
|
+
return date.toLocaleString('zh-CN', {
|
|
149
|
+
weekday: 'short'
|
|
150
|
+
}).replace('周', '星期');
|
|
151
|
+
} else {
|
|
152
|
+
// 超过一周
|
|
153
|
+
return date.toLocaleDateString('zh-CN');
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const urlToBase64 = (url)=>{
|
|
157
|
+
return new Promise((resolve)=>{
|
|
158
|
+
const image = new Image();
|
|
159
|
+
// 先设置图片跨域属性
|
|
160
|
+
image.crossOrigin = 'Anonymous';
|
|
161
|
+
// 再给image赋值src属性,先后顺序不能颠倒
|
|
162
|
+
image.src = url;
|
|
163
|
+
image.onload = function() {
|
|
164
|
+
const canvas = document.createElement('CANVAS');
|
|
165
|
+
// 设置canvas宽高等于图片实际宽高
|
|
166
|
+
canvas.width = image.width;
|
|
167
|
+
canvas.height = image.height;
|
|
168
|
+
canvas.getContext('2d').drawImage(image, 0, 0);
|
|
169
|
+
// toDataUrl可以接收2个参数,参数一:图片类型,参数二: 图片质量0-1(不传默认为0.92)
|
|
170
|
+
const dataURL = canvas.toDataURL('image/jpeg');
|
|
171
|
+
resolve(dataURL);
|
|
172
|
+
};
|
|
173
|
+
image.onerror = ()=>{
|
|
174
|
+
resolve({
|
|
175
|
+
message: '相片处理失败'
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
|
|
@@ -7,7 +7,7 @@ import "highlight.js/styles/default.css";
|
|
|
7
7
|
import { Input } from "antd";
|
|
8
8
|
import { CustomClose, CustomExpand, CustomAiIcon } from "../icons/index";
|
|
9
9
|
import { SearchOutlined } from "@ant-design/icons";
|
|
10
|
-
import {
|
|
10
|
+
import { formatDate } from "./function"; //录音使用文件
|
|
11
11
|
const HistoryFun = (props)=>{
|
|
12
12
|
let { type , roomId , userData , http , urllocation , onClose , loadSpecifiedData } = props;
|
|
13
13
|
const [keyWordProblem, setKeyWordProblem] = useState(""); //搜索内容
|
|
@@ -55,13 +55,11 @@ const HistoryFun = (props)=>{
|
|
|
55
55
|
maxPageSize: maxPageSize
|
|
56
56
|
}
|
|
57
57
|
}).then((res)=>{
|
|
58
|
-
console.log(res, 7777779999);
|
|
59
58
|
let data = res.data;
|
|
60
59
|
if (data.total > 0) {
|
|
61
60
|
setShowLoadingState(3);
|
|
62
61
|
let list = data.messageHistories;
|
|
63
62
|
setPageCount(Math.ceil(data.total / maxPageSize));
|
|
64
|
-
// setTotalData(totalData.concat(list));
|
|
65
63
|
setTotalData((list1)=>{
|
|
66
64
|
let new_list = list1;
|
|
67
65
|
new_list = new_list.concat(list);
|
|
@@ -350,25 +348,23 @@ const HistoryFun = (props)=>{
|
|
|
350
348
|
let span = "";
|
|
351
349
|
let time = "";
|
|
352
350
|
if (item.count == 1) {
|
|
351
|
+
let message = item.message;
|
|
352
|
+
let position_i = message.indexOf(keyWordProblem);
|
|
353
|
+
if (position_i > 30) {
|
|
354
|
+
message = message.substring(position_i - 15);
|
|
355
|
+
}
|
|
353
356
|
let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
|
|
354
357
|
//搜索内容是否有特殊字符
|
|
355
358
|
if (reg.test(keyWordProblem)) {
|
|
356
|
-
span =
|
|
359
|
+
span = message.replaceAll(keyWordProblem, (e)=>{
|
|
357
360
|
return `<span class=${styles.sign}>${e}</span>`;
|
|
358
361
|
});
|
|
359
362
|
} else {
|
|
360
|
-
span =
|
|
361
|
-
// console.log(i,'skdcnsdjk')
|
|
363
|
+
span = message.replaceAll(new RegExp(keyWordProblem, "ig"), (i)=>{
|
|
362
364
|
return `<span class=${styles.sign}>${i}</span>`;
|
|
363
365
|
});
|
|
364
366
|
}
|
|
365
|
-
|
|
366
|
-
let createdAt = getDataTime(item.createdAt, 1);
|
|
367
|
-
if (currentTime == createdAt) {
|
|
368
|
-
time = getDataTime(item.createdAt, 2);
|
|
369
|
-
} else {
|
|
370
|
-
time = getDataTime(item.createdAt);
|
|
371
|
-
}
|
|
367
|
+
time = formatDate(item.createdAt);
|
|
372
368
|
}
|
|
373
369
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
374
370
|
children: [
|
|
@@ -435,23 +431,21 @@ const HistoryFun = (props)=>{
|
|
|
435
431
|
} else {
|
|
436
432
|
name = userData.real_name;
|
|
437
433
|
}
|
|
438
|
-
let time =
|
|
439
|
-
let currentTime = getDataTime(-1, 1); //当前时间
|
|
440
|
-
let updatedAt = getDataTime(list.updatedAt, 1);
|
|
441
|
-
if (currentTime == updatedAt) {
|
|
442
|
-
time = getDataTime(list.updatedAt, 2);
|
|
443
|
-
} else {
|
|
444
|
-
time = getDataTime(list.updatedAt);
|
|
445
|
-
}
|
|
434
|
+
let time = formatDate(list.updatedAt);
|
|
446
435
|
let reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
|
|
447
436
|
let span = '';
|
|
437
|
+
let message = list.message;
|
|
438
|
+
let position_i = message.indexOf(keyWordProblem);
|
|
439
|
+
if (position_i > 30) {
|
|
440
|
+
message = message.substring(position_i - 15);
|
|
441
|
+
}
|
|
448
442
|
//搜索内容是否有特殊字符
|
|
449
443
|
if (reg.test(keyWordProblem)) {
|
|
450
|
-
span =
|
|
444
|
+
span = message.replaceAll(keyWordProblem, (e)=>{
|
|
451
445
|
return `<span class=${styles.sign}>${e}</span>`;
|
|
452
446
|
});
|
|
453
447
|
} else {
|
|
454
|
-
span =
|
|
448
|
+
span = message.replaceAll(new RegExp(keyWordProblem, "ig"), (i)=>{
|
|
455
449
|
// console.log(i,'skdcnsdjk')
|
|
456
450
|
return `<span class=${styles.sign}>${i}</span>`;
|
|
457
451
|
});
|