bhd-components 0.10.35 → 0.10.37
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/index.esm.es5.development.js +268 -146
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +93 -93
- package/dist/vendor.esm.es5.production.js +12 -12
- package/es2017/customerService/function.js +6 -3
- package/es2017/customerService/index.js +94 -50
- package/es2017/utils/Date.js +5 -1
- package/esm/customerService/function.js +6 -3
- package/esm/customerService/index.js +256 -137
- package/esm/utils/Date.js +4 -0
- package/package.json +1 -1
|
@@ -136,9 +136,12 @@ const getBase64Image = (src)=>{
|
|
|
136
136
|
};
|
|
137
137
|
const formatDate = (dateStr)=>{
|
|
138
138
|
const today = new Date();
|
|
139
|
+
today.setHours(0, 0, 0, 0); // 将时间部分设为0,只比较日期
|
|
139
140
|
const date = new Date(dateStr);
|
|
141
|
+
const cloneDate = new Date(dateStr);
|
|
142
|
+
cloneDate.setHours(0, 0, 0, 0); // 将时间部分设为0,只比较日期
|
|
140
143
|
let isSameDay = today.getFullYear() === date.getFullYear() && today.getMonth() === date.getMonth() && today.getDate() === date.getDate();
|
|
141
|
-
const dayDiff = Math.ceil((today -
|
|
144
|
+
const dayDiff = Math.ceil((today - cloneDate) / (1000 * 60 * 60 * 24)); // 计算天数差
|
|
142
145
|
// 判断当前的日期 是否于传入的日期为同一天 同一天则显示时间 不是同一天则判断是否超过一周
|
|
143
146
|
// console.log(dayDiff,'dayDiffdayDiff',today,'___',date);
|
|
144
147
|
if (isSameDay) {
|
|
@@ -146,7 +149,7 @@ const formatDate = (dateStr)=>{
|
|
|
146
149
|
return date.toLocaleTimeString('zh-CN', {
|
|
147
150
|
hour12: false
|
|
148
151
|
}).substring(0, 5);
|
|
149
|
-
} else if (dayDiff
|
|
152
|
+
} else if (dayDiff < 7) {
|
|
150
153
|
// 一周内
|
|
151
154
|
return date.toLocaleString('zh-CN', {
|
|
152
155
|
weekday: 'short'
|
|
@@ -199,7 +202,7 @@ const removeMermaidBlockComments = (markdownContent)=>{
|
|
|
199
202
|
return markdownContent.replace(mermaidBlockRegex, (match, prefix, content, suffix)=>{
|
|
200
203
|
// 清理块内注释的正则(同之前逻辑,优先保留字符串)
|
|
201
204
|
const commentRegex = /(".*?"|'.*?')|(\/\*[\s\S]*?\*\/)|(\/\/.*?$)/gm;
|
|
202
|
-
const cleanContent = content.replace(commentRegex, (m, stringPart)=>stringPart || '').replace(/<br>/g, '');
|
|
205
|
+
const cleanContent = content.replace(commentRegex, (m, stringPart)=>stringPart || '').replace(/<br>/g, '').replace(/\\n/g, '');
|
|
203
206
|
// 拼接回完整代码块(保留 ```mermaid 和 ``` 标识)
|
|
204
207
|
return `${prefix}${cleanContent}${suffix}`;
|
|
205
208
|
});
|
|
@@ -804,7 +804,7 @@ const CustomerService = (props)=>{
|
|
|
804
804
|
});
|
|
805
805
|
};
|
|
806
806
|
//AI窗口,type:1发送打招呼信息欢迎语 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
|
|
807
|
-
const sendGreetingMessage = (type)=>{
|
|
807
|
+
const sendGreetingMessage = async (type, message = "")=>{
|
|
808
808
|
let obj = {};
|
|
809
809
|
if (type == 1) {
|
|
810
810
|
sendWelcomMessage();
|
|
@@ -842,7 +842,7 @@ const CustomerService = (props)=>{
|
|
|
842
842
|
roomId: roomId,
|
|
843
843
|
sender: mid,
|
|
844
844
|
recevier: "AI",
|
|
845
|
-
message: keyWord,
|
|
845
|
+
message: message ? message : keyWord,
|
|
846
846
|
createdAt: getDataTime(-1),
|
|
847
847
|
quotedMessage: citationContent.content,
|
|
848
848
|
extraInfos: [
|
|
@@ -852,6 +852,22 @@ const CustomerService = (props)=>{
|
|
|
852
852
|
}
|
|
853
853
|
]
|
|
854
854
|
};
|
|
855
|
+
let imageUrl = '';
|
|
856
|
+
if (citationContent.imageUrl) {
|
|
857
|
+
let base64 = await urlToBase64(citationContent.imageUrl);
|
|
858
|
+
imageUrl = base64;
|
|
859
|
+
}
|
|
860
|
+
if (screenshotBese64) {
|
|
861
|
+
imageUrl = screenshotBese64;
|
|
862
|
+
}
|
|
863
|
+
console.log('imageUrl', imageUrl);
|
|
864
|
+
if (imageUrl) {
|
|
865
|
+
obj.image = imageUrl;
|
|
866
|
+
obj.extraInfos.push({
|
|
867
|
+
key: "imageUrl",
|
|
868
|
+
value: imageUrl
|
|
869
|
+
});
|
|
870
|
+
}
|
|
855
871
|
} else if (type == 5) {
|
|
856
872
|
obj = {
|
|
857
873
|
roomId: roomId,
|
|
@@ -874,6 +890,7 @@ const CustomerService = (props)=>{
|
|
|
874
890
|
setKeyWord("");
|
|
875
891
|
setQuestionsList([]);
|
|
876
892
|
setCitationContent({});
|
|
893
|
+
setScreenshotBese64('');
|
|
877
894
|
http.post(`${urllocation}/chat-service/public/v1.0/history-messages`, obj).then((res)=>{
|
|
878
895
|
if (res.data.id) {
|
|
879
896
|
if (pageNumHistory <= 1) {
|
|
@@ -1217,7 +1234,7 @@ const CustomerService = (props)=>{
|
|
|
1217
1234
|
roomId: roomId,
|
|
1218
1235
|
sender: "AI",
|
|
1219
1236
|
recevier: mid,
|
|
1220
|
-
message: "
|
|
1237
|
+
message: "正在思考...",
|
|
1221
1238
|
id: "123456",
|
|
1222
1239
|
createdAt: getDataTime(-1),
|
|
1223
1240
|
extraInfo: null
|
|
@@ -1231,7 +1248,7 @@ const CustomerService = (props)=>{
|
|
|
1231
1248
|
roomId: roomId,
|
|
1232
1249
|
sender: "AI",
|
|
1233
1250
|
recevier: mid,
|
|
1234
|
-
message: "
|
|
1251
|
+
message: "正在思考...",
|
|
1235
1252
|
id: "123456",
|
|
1236
1253
|
createdAt: getDataTime(-1),
|
|
1237
1254
|
extraInfo: null
|
|
@@ -2298,6 +2315,12 @@ const CustomerService = (props)=>{
|
|
|
2298
2315
|
let message = item.message;
|
|
2299
2316
|
let li;
|
|
2300
2317
|
// 是否需要显示日期
|
|
2318
|
+
// 判断是否第一项:
|
|
2319
|
+
// 如果是第一项显示日期+时间;
|
|
2320
|
+
//
|
|
2321
|
+
// 如果不是第一项:
|
|
2322
|
+
// 先判断是否跨天;如果跨天:就显示日期+时间;
|
|
2323
|
+
// 如果不跨天:判断是否超过10分钟,超过10分钟判断是否是当天,如果当天显示时间,不是当天就显示日期+时间;没超过10分钟不显示
|
|
2301
2324
|
let itemIndex = historyMessageList.findIndex((ite)=>ite.id === item.id);
|
|
2302
2325
|
let time = "";
|
|
2303
2326
|
if (historyMessageList.length > 1) {
|
|
@@ -2307,16 +2330,30 @@ const CustomerService = (props)=>{
|
|
|
2307
2330
|
} else {
|
|
2308
2331
|
//非第一项 与上一项进行对比
|
|
2309
2332
|
let beforeTime = historyMessageList[itemIndex - 1].createdAt;
|
|
2310
|
-
//判断与上一条数据 是否跨天
|
|
2311
2333
|
let beforeTimeObj = parseDate(beforeTime);
|
|
2334
|
+
// 上一条的日期
|
|
2312
2335
|
let beforeTimeStr = `${beforeTimeObj.year}-${beforeTimeObj.month}-${beforeTimeObj.day}`;
|
|
2336
|
+
// 当前这条的日期
|
|
2313
2337
|
let curTimeStr = `${timeObj.year}-${timeObj.month}-${timeObj.day}`;
|
|
2338
|
+
let now = new Date();
|
|
2339
|
+
// 当天的日期
|
|
2340
|
+
let nowTimeStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
|
2341
|
+
//判断与上一条数据 是否跨天
|
|
2314
2342
|
if (beforeTimeStr !== curTimeStr) {
|
|
2343
|
+
// 跨天
|
|
2344
|
+
// 显示日期+时间
|
|
2315
2345
|
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
2316
2346
|
} else {
|
|
2317
2347
|
//没有跨天 判断是否相隔超过10分钟
|
|
2318
2348
|
if (new Date(item.createdAt).valueOf() - new Date(beforeTime).valueOf() > 10 * 60 * 1000) {
|
|
2319
|
-
|
|
2349
|
+
//判断是否当天
|
|
2350
|
+
if (curTimeStr === nowTimeStr) {
|
|
2351
|
+
// 当天,显示时间
|
|
2352
|
+
time = `${timeObj.hours}:${timeObj.minutes}`;
|
|
2353
|
+
} else {
|
|
2354
|
+
// 非当天,显示日期+时间
|
|
2355
|
+
time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
|
|
2356
|
+
}
|
|
2320
2357
|
}
|
|
2321
2358
|
}
|
|
2322
2359
|
}
|
|
@@ -2325,7 +2362,9 @@ const CustomerService = (props)=>{
|
|
|
2325
2362
|
// let code = message.split("```");
|
|
2326
2363
|
// code = code[1];
|
|
2327
2364
|
// console.log(code,888888888);
|
|
2328
|
-
|
|
2365
|
+
if (finishedRef.current || i != historyMessageList.length - 1) {
|
|
2366
|
+
message = removeMermaidBlockComments(message);
|
|
2367
|
+
}
|
|
2329
2368
|
message = handleRenderSyntaxBlock(message, finishedRef.current || i != historyMessageList.length - 1);
|
|
2330
2369
|
if (lastId == item.id && keyWordProblem != "") {
|
|
2331
2370
|
//点击历史记录时,找到关键字,防止关键字和标签名重复
|
|
@@ -2452,17 +2491,17 @@ const CustomerService = (props)=>{
|
|
|
2452
2491
|
},
|
|
2453
2492
|
className: styles.content_child
|
|
2454
2493
|
}),
|
|
2455
|
-
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)
|
|
2456
|
-
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 :
|
|
2494
|
+
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl") && /*#__PURE__*/ _jsxs("p", {
|
|
2495
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ''}`,
|
|
2457
2496
|
children: [
|
|
2458
2497
|
/*#__PURE__*/ _jsx("img", {
|
|
2459
|
-
src: JSON.parse(item.extraInfo)
|
|
2498
|
+
src: JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl").value
|
|
2460
2499
|
}),
|
|
2461
2500
|
/*#__PURE__*/ _jsx("div", {
|
|
2462
2501
|
className: styles.mask_zoom,
|
|
2463
2502
|
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2464
2503
|
onClick: ()=>{
|
|
2465
|
-
setViewBase64(JSON.parse(item.extraInfo)
|
|
2504
|
+
setViewBase64(JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl").value);
|
|
2466
2505
|
setVisible(true);
|
|
2467
2506
|
}
|
|
2468
2507
|
})
|
|
@@ -2558,7 +2597,8 @@ const CustomerService = (props)=>{
|
|
|
2558
2597
|
style: {
|
|
2559
2598
|
marginRight: "12px"
|
|
2560
2599
|
},
|
|
2561
|
-
children: isAiChatWindow ? item.extraInfo == null || header == 1
|
|
2600
|
+
children: isAiChatWindow ? // item.extraInfo == null || header == 1
|
|
2601
|
+
userData.modules.some((item)=>item.short == "AIservice") ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
|
|
2562
2602
|
src: knowledge_icon
|
|
2563
2603
|
}) : /*#__PURE__*/ _jsx("img", {
|
|
2564
2604
|
src: headImg
|
|
@@ -2664,17 +2704,17 @@ const CustomerService = (props)=>{
|
|
|
2664
2704
|
})
|
|
2665
2705
|
]
|
|
2666
2706
|
}),
|
|
2667
|
-
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)
|
|
2668
|
-
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 :
|
|
2707
|
+
!item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl") && /*#__PURE__*/ _jsxs("p", {
|
|
2708
|
+
className: `${styles.img_con} ${showType == 2 || showType == 4 ? styles.img_con2 : ''}`,
|
|
2669
2709
|
children: [
|
|
2670
2710
|
/*#__PURE__*/ _jsx("img", {
|
|
2671
|
-
src: JSON.parse(item.extraInfo)
|
|
2711
|
+
src: JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl").value
|
|
2672
2712
|
}),
|
|
2673
2713
|
/*#__PURE__*/ _jsx("div", {
|
|
2674
2714
|
className: styles.mask_zoom,
|
|
2675
2715
|
children: /*#__PURE__*/ _jsx(ZoomInOutlined, {
|
|
2676
2716
|
onClick: ()=>{
|
|
2677
|
-
setViewBase64(JSON.parse(item.extraInfo)
|
|
2717
|
+
setViewBase64(JSON.parse(item.extraInfo).find((x)=>x.key == "imageUrl").value);
|
|
2678
2718
|
setVisible(true);
|
|
2679
2719
|
}
|
|
2680
2720
|
})
|
|
@@ -3282,44 +3322,48 @@ const CustomerService = (props)=>{
|
|
|
3282
3322
|
};
|
|
3283
3323
|
//发送截图信息
|
|
3284
3324
|
const sendScreenshotData = (message)=>{
|
|
3285
|
-
if (
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3325
|
+
if (userData.modules.some((item)=>item.short == "AIservice")) {
|
|
3326
|
+
if (contactsList.length > 0 && contactsList[0].roomId == roomId) {
|
|
3327
|
+
setKeyWord("");
|
|
3328
|
+
setCitationContent({});
|
|
3329
|
+
setBottomRecommendationQuestions([]);
|
|
3330
|
+
setHistoryMessageList((historyMessageList)=>{
|
|
3331
|
+
let newHistoryMessageList = historyMessageList.concat({
|
|
3332
|
+
id: 'p' + new Date().getTime(),
|
|
3333
|
+
roomId: roomId,
|
|
3334
|
+
sender: mid,
|
|
3335
|
+
recevier: 'AI',
|
|
3336
|
+
message: message,
|
|
3337
|
+
createdAt: getDataTime(-1),
|
|
3338
|
+
extraInfo: JSON.stringify([
|
|
3339
|
+
{
|
|
3340
|
+
key: "imageUrl",
|
|
3341
|
+
value: screenshotBese64
|
|
3342
|
+
}
|
|
3343
|
+
])
|
|
3344
|
+
});
|
|
3345
|
+
return newHistoryMessageList;
|
|
3346
|
+
});
|
|
3347
|
+
//ai窗口
|
|
3348
|
+
aiSendQuestions(3, {
|
|
3349
|
+
//相关数据
|
|
3292
3350
|
roomId: roomId,
|
|
3293
|
-
sender: mid,
|
|
3294
|
-
recevier: 'AI',
|
|
3295
3351
|
message: message,
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
}
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
//相关数据
|
|
3309
|
-
roomId: roomId,
|
|
3310
|
-
message: message,
|
|
3311
|
-
image: screenshotBese64,
|
|
3312
|
-
quotedMessage: citationContent.content || "",
|
|
3313
|
-
regenerate: citationContent.content != "" ? false : true,
|
|
3314
|
-
generateUpvoteOrDownvoteMessage: false
|
|
3315
|
-
}, 1);
|
|
3316
|
-
setScreenshotBese64('');
|
|
3352
|
+
image: screenshotBese64,
|
|
3353
|
+
quotedMessage: citationContent.content || "",
|
|
3354
|
+
regenerate: citationContent.content != "" ? false : true,
|
|
3355
|
+
generateUpvoteOrDownvoteMessage: false
|
|
3356
|
+
}, 1);
|
|
3357
|
+
setScreenshotBese64('');
|
|
3358
|
+
} else {
|
|
3359
|
+
//老师窗口
|
|
3360
|
+
sendToTeacher(3, message);
|
|
3361
|
+
}
|
|
3362
|
+
scrollToBottom();
|
|
3363
|
+
resettingBottomHei();
|
|
3317
3364
|
} else {
|
|
3318
|
-
|
|
3319
|
-
sendToTeacher(3, message);
|
|
3365
|
+
sendGreetingMessage(4, message);
|
|
3320
3366
|
}
|
|
3321
|
-
scrollToBottom();
|
|
3322
|
-
resettingBottomHei();
|
|
3323
3367
|
};
|
|
3324
3368
|
//渲染底部按钮
|
|
3325
3369
|
const renderBottomAnt = ()=>{
|
package/es2017/utils/Date.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const parseDate = (dateStr)=>{
|
|
2
|
-
|
|
2
|
+
let date = new Date(dateStr); // 创建一个日期对象,表示当前时间
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
if (date == "Invalid Date") {
|
|
5
|
+
date = new Date();
|
|
6
|
+
}
|
|
3
7
|
const year = date.getFullYear().toString(); // 获取年份
|
|
4
8
|
const month = String(date.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
|
|
5
9
|
const day = String(date.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
|
|
@@ -140,9 +140,12 @@ var getBase64Image = function(src) {
|
|
|
140
140
|
};
|
|
141
141
|
var formatDate = function(dateStr) {
|
|
142
142
|
var today = new Date();
|
|
143
|
+
today.setHours(0, 0, 0, 0); // 将时间部分设为0,只比较日期
|
|
143
144
|
var date = new Date(dateStr);
|
|
145
|
+
var cloneDate = new Date(dateStr);
|
|
146
|
+
cloneDate.setHours(0, 0, 0, 0); // 将时间部分设为0,只比较日期
|
|
144
147
|
var isSameDay = today.getFullYear() === date.getFullYear() && today.getMonth() === date.getMonth() && today.getDate() === date.getDate();
|
|
145
|
-
var dayDiff = Math.ceil((today -
|
|
148
|
+
var dayDiff = Math.ceil((today - cloneDate) / (1000 * 60 * 60 * 24)); // 计算天数差
|
|
146
149
|
// 判断当前的日期 是否于传入的日期为同一天 同一天则显示时间 不是同一天则判断是否超过一周
|
|
147
150
|
// console.log(dayDiff,'dayDiffdayDiff',today,'___',date);
|
|
148
151
|
if (isSameDay) {
|
|
@@ -150,7 +153,7 @@ var formatDate = function(dateStr) {
|
|
|
150
153
|
return date.toLocaleTimeString("zh-CN", {
|
|
151
154
|
hour12: false
|
|
152
155
|
}).substring(0, 5);
|
|
153
|
-
} else if (dayDiff
|
|
156
|
+
} else if (dayDiff < 7) {
|
|
154
157
|
// 一周内
|
|
155
158
|
return date.toLocaleString("zh-CN", {
|
|
156
159
|
weekday: "short"
|
|
@@ -205,7 +208,7 @@ var removeMermaidBlockComments = function(markdownContent) {
|
|
|
205
208
|
var commentRegex = /(".*?"|'.*?')|(\/\*[\s\S]*?\*\/)|(\/\/.*?$)/gm;
|
|
206
209
|
var cleanContent = content.replace(commentRegex, function(m, stringPart) {
|
|
207
210
|
return stringPart || "";
|
|
208
|
-
}).replace(/<br>/g, "");
|
|
211
|
+
}).replace(/<br>/g, "").replace(/\\n/g, "");
|
|
209
212
|
// 拼接回完整代码块(保留 ```mermaid 和 ``` 标识)
|
|
210
213
|
return "".concat(prefix).concat(cleanContent).concat(suffix);
|
|
211
214
|
});
|