@zero-library/chat-agent 2.1.19 → 2.2.0
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.cjs.js +259 -189
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +1035 -204
- package/dist/index.d.ts +1035 -204
- package/dist/index.esm.js +260 -185
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var common = require('@zero-library/common');
|
|
4
4
|
var antd = require('antd');
|
|
5
|
-
var dayjs = require('dayjs');
|
|
6
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
var react = require('react');
|
|
8
7
|
var valtio = require('valtio');
|
|
9
8
|
var icons = require('@ant-design/icons');
|
|
10
9
|
var x = require('@ant-design/x');
|
|
11
|
-
var
|
|
10
|
+
var classNames9 = require('classnames');
|
|
11
|
+
var dayjs = require('dayjs');
|
|
12
12
|
var InfiniteScroll = require('react-infinite-scroll-component');
|
|
13
13
|
|
|
14
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
|
|
16
|
+
var classNames9__default = /*#__PURE__*/_interopDefault(classNames9);
|
|
16
17
|
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
17
|
-
var classNames8__default = /*#__PURE__*/_interopDefault(classNames8);
|
|
18
18
|
var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
|
|
19
19
|
|
|
20
20
|
var __defProp = Object.defineProperty;
|
|
@@ -26,36 +26,6 @@ var __export = (target, all) => {
|
|
|
26
26
|
for (var name in all)
|
|
27
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
28
|
};
|
|
29
|
-
var classifyTime, replaceThinkTags, copy;
|
|
30
|
-
var init_utils = __esm({
|
|
31
|
-
"src/core/utils.ts"() {
|
|
32
|
-
classifyTime = (timestamp) => {
|
|
33
|
-
const now = dayjs__default.default();
|
|
34
|
-
const target = dayjs__default.default(timestamp);
|
|
35
|
-
if (target.isSame(now, "day")) {
|
|
36
|
-
return "\u4ECA\u5929";
|
|
37
|
-
}
|
|
38
|
-
const diffInDays = now.diff(target, "day");
|
|
39
|
-
if (diffInDays < 7) {
|
|
40
|
-
return "\u6700\u8FD1 7 \u5929";
|
|
41
|
-
} else if (diffInDays < 30) {
|
|
42
|
-
return "\u6700\u8FD1 30 \u5929";
|
|
43
|
-
} else if (diffInDays < 180) {
|
|
44
|
-
return "\u6700\u8FD1\u534A\u5E74";
|
|
45
|
-
} else {
|
|
46
|
-
return "\u66F4\u65E9";
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
replaceThinkTags = (str) => {
|
|
50
|
-
return str.replace(/<think>/g, ":::alert type=think data={content:'").replace(/<\/think>/g, "'} ::: ");
|
|
51
|
-
};
|
|
52
|
-
copy = (value) => {
|
|
53
|
-
common.copyText(value).then(() => {
|
|
54
|
-
antd.message.success("\u590D\u5236\u6210\u529F");
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
29
|
var ChatProvider, useChatStore;
|
|
60
30
|
var init_Context = __esm({
|
|
61
31
|
"src/stores/Context.ts"() {
|
|
@@ -214,7 +184,6 @@ __export(FileEdit_exports, {
|
|
|
214
184
|
var FileEdit_default;
|
|
215
185
|
var init_FileEdit = __esm({
|
|
216
186
|
"src/ui/common/markdownAlert/FileEdit.tsx"() {
|
|
217
|
-
init_utils();
|
|
218
187
|
init_Context();
|
|
219
188
|
init_styles_module();
|
|
220
189
|
FileEdit_default = ({ data, loading }) => {
|
|
@@ -230,7 +199,7 @@ var init_FileEdit = __esm({
|
|
|
230
199
|
] }),
|
|
231
200
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
232
201
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlayCircleOutlined, {}), onClick: onPreview, children: "\u9884\u89C8\u7F16\u8F91" }),
|
|
233
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}), onClick: () =>
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}), onClick: () => common.copyText(data.content), children: "\u590D\u5236" })
|
|
234
203
|
] }) })
|
|
235
204
|
] }),
|
|
236
205
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: styles_module_default.fileEditContent, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: data.content }) })
|
|
@@ -313,9 +282,41 @@ var init_Think = __esm({
|
|
|
313
282
|
};
|
|
314
283
|
}
|
|
315
284
|
});
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
285
|
+
var userInfoManager = common.createSecureManager({
|
|
286
|
+
key: "NS-USER",
|
|
287
|
+
aesKey: "((#II))"
|
|
288
|
+
});
|
|
289
|
+
var TOKEN_KEY = "NS-TOKEN";
|
|
290
|
+
var tokenManager = common.createTokenManager({
|
|
291
|
+
key: TOKEN_KEY
|
|
292
|
+
});
|
|
293
|
+
var redirectUrl = () => {
|
|
294
|
+
const path = localStorage.getItem("SIGNPATH");
|
|
295
|
+
common.emit("jumpLink", { url: `/uc${path || "/sign-in"}` });
|
|
296
|
+
};
|
|
297
|
+
var classifyTime = (timestamp) => {
|
|
298
|
+
const now = dayjs__default.default();
|
|
299
|
+
const target = dayjs__default.default(timestamp);
|
|
300
|
+
if (target.isSame(now, "day")) {
|
|
301
|
+
return "\u4ECA\u5929";
|
|
302
|
+
}
|
|
303
|
+
const diffInDays = now.diff(target, "day");
|
|
304
|
+
if (diffInDays < 7) {
|
|
305
|
+
return "\u6700\u8FD1 7 \u5929";
|
|
306
|
+
} else if (diffInDays < 30) {
|
|
307
|
+
return "\u6700\u8FD1 30 \u5929";
|
|
308
|
+
} else if (diffInDays < 180) {
|
|
309
|
+
return "\u6700\u8FD1\u534A\u5E74";
|
|
310
|
+
} else {
|
|
311
|
+
return "\u66F4\u65E9";
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var replaceThinkTags = (str) => {
|
|
315
|
+
return str.replace(/<think>/g, ":::alert type=think data={content:'").replace(/<\/think>/g, "'} :::");
|
|
316
|
+
};
|
|
317
|
+
var getChatSocketUrl = (baseURL, params) => {
|
|
318
|
+
return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/lolr/conversation/ws/subscribe`), "comma");
|
|
319
|
+
};
|
|
319
320
|
|
|
320
321
|
// src/services/index.ts
|
|
321
322
|
var createChatService = (request) => {
|
|
@@ -435,8 +436,6 @@ var defaultExpertLayout = {
|
|
|
435
436
|
globalHeader: false,
|
|
436
437
|
chatHeader: {
|
|
437
438
|
props: {
|
|
438
|
-
title: true,
|
|
439
|
-
closeBtn: false,
|
|
440
439
|
newConversationBtn: false,
|
|
441
440
|
agentCharacter: false,
|
|
442
441
|
conversationListBtn: false
|
|
@@ -447,10 +446,14 @@ var defaultExpertLayout = {
|
|
|
447
446
|
function createChatStore() {
|
|
448
447
|
const config = valtio.proxy({
|
|
449
448
|
services: {
|
|
450
|
-
|
|
449
|
+
/** WebSocket地址 */
|
|
450
|
+
websocketUrls: ["", ""],
|
|
451
|
+
/** HTTP请求实例 */
|
|
452
|
+
request: {}
|
|
451
453
|
},
|
|
452
454
|
hooks: {},
|
|
453
455
|
layout: {},
|
|
456
|
+
/** 文件预览状态 */
|
|
454
457
|
preview: {
|
|
455
458
|
file: {},
|
|
456
459
|
isEdit: false
|
|
@@ -458,16 +461,42 @@ function createChatStore() {
|
|
|
458
461
|
// isShow: 0, // 0 不显示 1 显示 2 用户关闭
|
|
459
462
|
// isIntact: false // true 完整 false 不完整
|
|
460
463
|
},
|
|
464
|
+
/** 当前用户信息 */
|
|
461
465
|
userInfo: {},
|
|
466
|
+
/** 聊天参数配置 */
|
|
462
467
|
params: {}
|
|
463
468
|
});
|
|
464
|
-
const setServices = ({
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
469
|
+
const setServices = ({ http, websocket } = {}) => {
|
|
470
|
+
const httpConfig = { baseURL: "/api", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
|
|
471
|
+
const request = common.createRequest(httpConfig);
|
|
472
|
+
if (config.hooks?.onRequestInterceptor) {
|
|
473
|
+
request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
|
|
474
|
+
}
|
|
475
|
+
request.instance.interceptors.response.use(void 0, (err) => {
|
|
476
|
+
if (err?.response?.status === common.HttpStatus.UNAUTHORIZED) {
|
|
477
|
+
if (config.hooks.onRedirectLogin) {
|
|
478
|
+
config.hooks.onRedirectLogin();
|
|
479
|
+
} else {
|
|
480
|
+
redirectUrl();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return Promise.reject(err);
|
|
484
|
+
});
|
|
485
|
+
if (config.hooks?.onResponseInterceptor) {
|
|
486
|
+
request.instance.interceptors.response.use(...config.hooks.onResponseInterceptor);
|
|
487
|
+
}
|
|
488
|
+
config.services.request = { ...createChatService(request), ...createFileService(request), ...http?.request };
|
|
489
|
+
config.services.websocketUrls = ["", ""];
|
|
490
|
+
if (common.isArray(websocket?.baseURLs)) {
|
|
491
|
+
websocket.baseURLs.forEach((baseURL, index) => {
|
|
492
|
+
if (common.isString(baseURL)) {
|
|
493
|
+
config.services.websocketUrls[index] = getChatSocketUrl(baseURL, websocket?.params || httpConfig.headers);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
} else {
|
|
497
|
+
const url = getChatSocketUrl(httpConfig.baseURL, websocket?.params || httpConfig.headers);
|
|
498
|
+
config.services.websocketUrls = [url, ""];
|
|
468
499
|
}
|
|
469
|
-
const request = common.createRequest(baseUrl);
|
|
470
|
-
config.services.request = { ...createChatService(request), ...createFileService(request) };
|
|
471
500
|
};
|
|
472
501
|
const setPreview = (file = {}, isEdit = false) => {
|
|
473
502
|
if (common.shouldRender(config.layout.preview)) {
|
|
@@ -494,20 +523,16 @@ function createChatStore() {
|
|
|
494
523
|
config.hooks = hooks;
|
|
495
524
|
};
|
|
496
525
|
const setUserInfo = (userInfo) => {
|
|
497
|
-
config.userInfo =
|
|
498
|
-
|
|
499
|
-
return String(userInfo2["id"]);
|
|
500
|
-
},
|
|
501
|
-
name: "name",
|
|
502
|
-
iconUrl: "avatar",
|
|
503
|
-
description: "name"
|
|
504
|
-
});
|
|
526
|
+
config.userInfo = userInfo || userInfoManager.get() || {};
|
|
527
|
+
config.userInfo.id = String(config.userInfo.id || "");
|
|
505
528
|
};
|
|
506
529
|
const receiver = valtio.proxy({
|
|
530
|
+
/** 当前激活的接收者信息(智能体或专家) */
|
|
507
531
|
active: {},
|
|
532
|
+
/** 接收者加载状态 */
|
|
508
533
|
loading: false,
|
|
534
|
+
/** 接收者透传参数,后期可能扩展不透传参数 */
|
|
509
535
|
params: {}
|
|
510
|
-
// 透传参数,后期可能扩展不透传参数
|
|
511
536
|
});
|
|
512
537
|
const setReceiverParams = (params) => {
|
|
513
538
|
if (common.isObject(params)) {
|
|
@@ -566,10 +591,15 @@ function createChatStore() {
|
|
|
566
591
|
setReceiverParams();
|
|
567
592
|
};
|
|
568
593
|
const character = valtio.proxy({
|
|
594
|
+
/** 性格列表 */
|
|
569
595
|
list: [],
|
|
596
|
+
/** 当前激活的性格 */
|
|
570
597
|
active: {},
|
|
598
|
+
/** 性格选择面板是否打开 */
|
|
571
599
|
open: false,
|
|
600
|
+
/** 加载性格列表的状态 */
|
|
572
601
|
loading: false,
|
|
602
|
+
/** 切换性格时的加载状态 */
|
|
573
603
|
switchLoading: false
|
|
574
604
|
});
|
|
575
605
|
const getCharacters = async (agentId) => {
|
|
@@ -604,16 +634,20 @@ function createChatStore() {
|
|
|
604
634
|
}
|
|
605
635
|
};
|
|
606
636
|
const conversations = valtio.proxy({
|
|
637
|
+
/** 会话列表数据 */
|
|
607
638
|
list: {
|
|
608
639
|
items: [],
|
|
640
|
+
/** 分页查询参数 */
|
|
609
641
|
params: {
|
|
610
642
|
pageNum: 1,
|
|
611
643
|
pageSize: 1e3
|
|
612
644
|
}
|
|
613
645
|
},
|
|
646
|
+
/** 当前会话索引,创建会话时更新,促使页面更新会话列表 */
|
|
614
647
|
updateIndex: 0,
|
|
615
|
-
|
|
648
|
+
/** 获取会话列表的加载状态 */
|
|
616
649
|
loading: false,
|
|
650
|
+
/** 删除会话的加载状态 */
|
|
617
651
|
delLoading: false
|
|
618
652
|
});
|
|
619
653
|
const getConversations = async (targetId, targetType) => {
|
|
@@ -659,14 +693,18 @@ function createChatStore() {
|
|
|
659
693
|
}
|
|
660
694
|
};
|
|
661
695
|
const conversation = valtio.proxy({
|
|
662
|
-
|
|
696
|
+
/** 当前激活的会话信息 */
|
|
663
697
|
active: {
|
|
664
698
|
id: "",
|
|
699
|
+
/** 会话成员对象,包含用户、智能体、专家等 */
|
|
665
700
|
member: {}
|
|
666
701
|
},
|
|
702
|
+
/** 每个会话的消息存储,以会话ID为键 */
|
|
667
703
|
messages: {},
|
|
704
|
+
/** 消息反馈状态 */
|
|
668
705
|
feedback: {
|
|
669
706
|
// open: false,
|
|
707
|
+
/** 反馈操作加载状态 */
|
|
670
708
|
loading: false
|
|
671
709
|
// recordId: '',
|
|
672
710
|
// target: undefined as number | undefined
|
|
@@ -714,14 +752,18 @@ function createChatStore() {
|
|
|
714
752
|
};
|
|
715
753
|
const setInitMessage = async (conversationId) => {
|
|
716
754
|
conversation.messages[conversationId] = {
|
|
755
|
+
/** 输入框内容 */
|
|
717
756
|
content: "",
|
|
757
|
+
/** 上传文件列表 */
|
|
718
758
|
files: [],
|
|
719
|
-
|
|
759
|
+
/** 头部展开状态 */
|
|
720
760
|
headerOpen: false,
|
|
761
|
+
/** 消息发送/接收加载状态 */
|
|
721
762
|
loading: false,
|
|
763
|
+
/** 消息列表 */
|
|
722
764
|
message: [],
|
|
765
|
+
/** 推荐问题列表 */
|
|
723
766
|
questionList: []
|
|
724
|
-
// 推荐问题
|
|
725
767
|
};
|
|
726
768
|
};
|
|
727
769
|
const resolveConversationId = async (receiverId, strategy = 2) => {
|
|
@@ -826,13 +868,13 @@ function createChatStore() {
|
|
|
826
868
|
if (other) return other;
|
|
827
869
|
return void 0;
|
|
828
870
|
};
|
|
829
|
-
const sendMessage = async (
|
|
871
|
+
const sendMessage = async (message2, files = [], params) => {
|
|
830
872
|
const conversationId = conversation.active.id;
|
|
831
873
|
if (conversation.messages[conversationId].loading) return;
|
|
832
874
|
let msgContent = "", msgFiles;
|
|
833
875
|
const references = conversation.messages[conversationId].references;
|
|
834
|
-
if (
|
|
835
|
-
msgContent =
|
|
876
|
+
if (message2) {
|
|
877
|
+
msgContent = message2;
|
|
836
878
|
msgFiles = files;
|
|
837
879
|
} else {
|
|
838
880
|
if (references?.type === 1 && references?.content?.markdown) {
|
|
@@ -860,9 +902,9 @@ function createChatStore() {
|
|
|
860
902
|
stream: true
|
|
861
903
|
};
|
|
862
904
|
const extraParams = common.deepCopy(config.params.params || {});
|
|
863
|
-
Object.assign(extraParams, receiver.params,
|
|
905
|
+
Object.assign(extraParams, receiver.params, message2 ? {} : references?.params, params);
|
|
864
906
|
sendParams.params = JSON.stringify(extraParams);
|
|
865
|
-
if (!
|
|
907
|
+
if (!message2) {
|
|
866
908
|
setContent("");
|
|
867
909
|
setFileList([]);
|
|
868
910
|
setReferences();
|
|
@@ -908,15 +950,15 @@ function createChatStore() {
|
|
|
908
950
|
const messages = conversation.messages[msg.conversationId].message;
|
|
909
951
|
const idx = findMsgIndex(msg.conversationId, msg.id);
|
|
910
952
|
if (idx === -1) return;
|
|
911
|
-
const
|
|
953
|
+
const message2 = messages[idx];
|
|
912
954
|
conversation.messages[msg.conversationId].loading = true;
|
|
913
|
-
if (
|
|
955
|
+
if (message2?.type === "STEP_STARTED" || message2?.type === "TEXT_MESSAGE_START") {
|
|
914
956
|
messages[idx] = msg;
|
|
915
957
|
return;
|
|
916
958
|
}
|
|
917
959
|
messages[idx] = {
|
|
918
|
-
...
|
|
919
|
-
msgContent:
|
|
960
|
+
...message2,
|
|
961
|
+
msgContent: message2.msgContent + (msg.msgContent || "")
|
|
920
962
|
};
|
|
921
963
|
};
|
|
922
964
|
const endCallback = (msg) => {
|
|
@@ -934,9 +976,13 @@ function createChatStore() {
|
|
|
934
976
|
messages[idx] = { ...msg, type: void 0 };
|
|
935
977
|
conversation.messages[msg.conversationId].loading = false;
|
|
936
978
|
};
|
|
937
|
-
const acceptMessage = (newMessage) => {
|
|
979
|
+
const acceptMessage = async (newMessage) => {
|
|
938
980
|
const conversationId = newMessage.data.conversationId;
|
|
939
981
|
if (!conversation.messages[conversationId]?.message) return;
|
|
982
|
+
const canProceed = await config.hooks?.onBeforeAcceptMessage?.(newMessage.data);
|
|
983
|
+
if (canProceed === false) {
|
|
984
|
+
throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
|
|
985
|
+
}
|
|
940
986
|
switch (newMessage.data.type) {
|
|
941
987
|
case "TEXT_MESSAGE_START":
|
|
942
988
|
startCallback(newMessage.data);
|
|
@@ -954,37 +1000,68 @@ function createChatStore() {
|
|
|
954
1000
|
errCallback(newMessage.data);
|
|
955
1001
|
break;
|
|
956
1002
|
}
|
|
1003
|
+
config.hooks?.onAfterAcceptMessage?.(newMessage.data);
|
|
957
1004
|
};
|
|
958
1005
|
return {
|
|
1006
|
+
/** 全局配置对象 */
|
|
959
1007
|
config,
|
|
1008
|
+
/** 设置服务配置 */
|
|
960
1009
|
setServices,
|
|
1010
|
+
/** 设置文件预览 */
|
|
961
1011
|
setPreview,
|
|
1012
|
+
/** 设置布局配置 */
|
|
962
1013
|
setLayout,
|
|
1014
|
+
/** 设置生命周期钩子 */
|
|
963
1015
|
setHooks,
|
|
1016
|
+
/** 设置聊天参数 */
|
|
964
1017
|
setParams,
|
|
1018
|
+
/** 设置用户信息 */
|
|
965
1019
|
setUserInfo,
|
|
1020
|
+
/** 智能体性格状态 */
|
|
966
1021
|
character,
|
|
1022
|
+
/** 获取性格列表 */
|
|
967
1023
|
getCharacters,
|
|
1024
|
+
/** 打开性格选择面板 */
|
|
968
1025
|
openCharacterList,
|
|
1026
|
+
/** 关闭性格选择面板 */
|
|
969
1027
|
closeCharacterList,
|
|
1028
|
+
/** 切换性格 */
|
|
970
1029
|
switchCharacter,
|
|
1030
|
+
/** 接收者状态 */
|
|
971
1031
|
receiver,
|
|
1032
|
+
/** 设置接收者参数 */
|
|
972
1033
|
setReceiverParams,
|
|
1034
|
+
/** 历史会话状态 */
|
|
973
1035
|
conversations,
|
|
1036
|
+
/** 获取会话列表 */
|
|
974
1037
|
getConversations,
|
|
1038
|
+
/** 删除会话 */
|
|
975
1039
|
delConversation,
|
|
1040
|
+
/** 当前会话状态 */
|
|
976
1041
|
conversation,
|
|
1042
|
+
/** 设置说话人类型 */
|
|
977
1043
|
setSpeakHuman,
|
|
1044
|
+
/** 设置引用消息 */
|
|
978
1045
|
setReferences,
|
|
1046
|
+
/** 设置消息内容 */
|
|
979
1047
|
setContent,
|
|
1048
|
+
/** 设置文件列表 */
|
|
980
1049
|
setFileList,
|
|
1050
|
+
/** 设置头部展开状态 */
|
|
981
1051
|
setHeaderOpen,
|
|
1052
|
+
/** 消息反馈操作 */
|
|
982
1053
|
feedback,
|
|
1054
|
+
/** 切换智能体会话 */
|
|
983
1055
|
switchAgentConversation,
|
|
1056
|
+
/** 创建新会话 */
|
|
984
1057
|
createConversation,
|
|
1058
|
+
/** 切换会话 */
|
|
985
1059
|
switchConversation,
|
|
1060
|
+
/** 发送消息 */
|
|
986
1061
|
sendMessage,
|
|
1062
|
+
/** 取消接收 */
|
|
987
1063
|
cancelReceive,
|
|
1064
|
+
/** 接收消息 */
|
|
988
1065
|
acceptMessage
|
|
989
1066
|
};
|
|
990
1067
|
}
|
|
@@ -992,9 +1069,6 @@ function createChatStore() {
|
|
|
992
1069
|
// src/ui/layouts/index.tsx
|
|
993
1070
|
init_Context();
|
|
994
1071
|
|
|
995
|
-
// src/components/MessageRender.tsx
|
|
996
|
-
init_utils();
|
|
997
|
-
|
|
998
1072
|
// src/ui/common/markdownAlert/index.ts
|
|
999
1073
|
var customComponents = {
|
|
1000
1074
|
appCard: () => Promise.resolve().then(() => (init_AppCard(), AppCard_exports)),
|
|
@@ -1013,17 +1087,17 @@ var styles_module_default2 = {
|
|
|
1013
1087
|
chatSender: "styles_module_chatSender",
|
|
1014
1088
|
chatQuoteMsg: "styles_module_chatQuoteMsg"
|
|
1015
1089
|
};
|
|
1016
|
-
var MessageRender_default = ({ message:
|
|
1017
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(
|
|
1018
|
-
|
|
1090
|
+
var MessageRender_default = ({ message: message2, placement }) => {
|
|
1091
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(message2.msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1092
|
+
message2.msgContent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1019
1093
|
x.Bubble,
|
|
1020
1094
|
{
|
|
1021
1095
|
placement,
|
|
1022
|
-
className:
|
|
1023
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: replaceThinkTags(
|
|
1096
|
+
className: classNames9__default.default({ [styles_module_default2.loadingMessage]: message2.type }),
|
|
1097
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: replaceThinkTags(message2.msgContent), customComponents })
|
|
1024
1098
|
}
|
|
1025
1099
|
),
|
|
1026
|
-
|
|
1100
|
+
message2.msgFiles?.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1027
1101
|
x.Bubble,
|
|
1028
1102
|
{
|
|
1029
1103
|
className: "m-t-8",
|
|
@@ -1043,19 +1117,19 @@ var MessageRender_default = ({ message: message3, placement }) => {
|
|
|
1043
1117
|
},
|
|
1044
1118
|
file.content
|
|
1045
1119
|
)),
|
|
1046
|
-
|
|
1120
|
+
message2.quoteMsg?.id && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1047
1121
|
x.Bubble,
|
|
1048
1122
|
{
|
|
1049
|
-
className:
|
|
1123
|
+
className: classNames9__default.default(styles_module_default2.chatQuoteMsg),
|
|
1050
1124
|
placement,
|
|
1051
1125
|
content: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
|
|
1052
|
-
|
|
1126
|
+
message2.quoteMsg.msgContent && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1053
1127
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
|
|
1054
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children:
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children: message2.quoteMsg.msgContent })
|
|
1055
1129
|
] }),
|
|
1056
|
-
|
|
1130
|
+
message2.quoteMsg?.msgFiles && message2.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1057
1131
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
|
|
1058
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, wrap: true, flex: 1, children:
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, wrap: true, flex: 1, children: message2.quoteMsg.msgFiles.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1059
1133
|
x.Attachments.FileCard,
|
|
1060
1134
|
{
|
|
1061
1135
|
item: {
|
|
@@ -1081,7 +1155,6 @@ var MEMBER_TYPE = {
|
|
|
1081
1155
|
};
|
|
1082
1156
|
|
|
1083
1157
|
// src/ui/common/BubbleListItems.tsx
|
|
1084
|
-
init_utils();
|
|
1085
1158
|
init_Context();
|
|
1086
1159
|
|
|
1087
1160
|
// src/ui/common/styles.module.less
|
|
@@ -1109,7 +1182,55 @@ var styles_module_default3 = {
|
|
|
1109
1182
|
nsAvatarListItemIconActive: "styles_module_nsAvatarListItemIconActive",
|
|
1110
1183
|
nsAvatarListItemName: "styles_module_nsAvatarListItemName"
|
|
1111
1184
|
};
|
|
1112
|
-
|
|
1185
|
+
|
|
1186
|
+
// src/ui/common/WelcomeItem.tsx
|
|
1187
|
+
init_Context();
|
|
1188
|
+
var WelcomeItem_default = ({ icon = true, title = true, description = true, prompts = true }) => {
|
|
1189
|
+
const chatStore = useChatStore();
|
|
1190
|
+
const receiverState = valtio.useSnapshot(chatStore.receiver);
|
|
1191
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { direction: "vertical", size: 16, className: styles_module_default3.chatWelcomeWrap, children: [
|
|
1192
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1193
|
+
x.Welcome,
|
|
1194
|
+
{
|
|
1195
|
+
className: classNames9__default.default(styles_module_default3.chatWelcome, "p-t-32"),
|
|
1196
|
+
variant: "borderless",
|
|
1197
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: icon, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { shape: "square", size: 58, src: receiverState.active.logo }) }),
|
|
1198
|
+
title: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: title, DefaultComponent: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}` }),
|
|
1199
|
+
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1200
|
+
common.RenderWrapper,
|
|
1201
|
+
{
|
|
1202
|
+
control: description,
|
|
1203
|
+
DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: receiverState.active.description || "" } })
|
|
1204
|
+
}
|
|
1205
|
+
)
|
|
1206
|
+
}
|
|
1207
|
+
),
|
|
1208
|
+
receiverState.active.config?.recommendQuestions?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1209
|
+
common.RenderWrapper,
|
|
1210
|
+
{
|
|
1211
|
+
control: prompts,
|
|
1212
|
+
DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1213
|
+
x.Prompts,
|
|
1214
|
+
{
|
|
1215
|
+
className: "m-t-16",
|
|
1216
|
+
wrap: true,
|
|
1217
|
+
items: [
|
|
1218
|
+
{
|
|
1219
|
+
key: "1",
|
|
1220
|
+
label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
|
|
1221
|
+
children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
|
|
1222
|
+
key: question,
|
|
1223
|
+
description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames9__default.default(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
|
|
1224
|
+
}))
|
|
1225
|
+
}
|
|
1226
|
+
]
|
|
1227
|
+
}
|
|
1228
|
+
)
|
|
1229
|
+
}
|
|
1230
|
+
)
|
|
1231
|
+
] });
|
|
1232
|
+
};
|
|
1233
|
+
var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, avatar = { user: false, agent: true, other: true } }) => {
|
|
1113
1234
|
const chatStore = useChatStore();
|
|
1114
1235
|
const receiverState = valtio.useSnapshot(chatStore.receiver);
|
|
1115
1236
|
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
@@ -1149,44 +1270,16 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1149
1270
|
() => conversationState.messages[conversationState.active.id] || {},
|
|
1150
1271
|
[conversationState.messages[conversationState.active.id]]
|
|
1151
1272
|
);
|
|
1152
|
-
const
|
|
1153
|
-
()
|
|
1273
|
+
const welcomeMessageRecord = react.useMemo(() => {
|
|
1274
|
+
const isExist = common.shouldRender(welcomeMessage);
|
|
1275
|
+
return isExist ? [
|
|
1154
1276
|
{
|
|
1155
1277
|
key: "placeholder",
|
|
1156
|
-
content: /* @__PURE__ */ jsxRuntime.
|
|
1157
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1158
|
-
x.Welcome,
|
|
1159
|
-
{
|
|
1160
|
-
className: classNames8__default.default(styles_module_default3.chatWelcome, "p-t-32"),
|
|
1161
|
-
variant: "borderless",
|
|
1162
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { shape: "square", size: 58, src: receiverState.active.logo }),
|
|
1163
|
-
title: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}`,
|
|
1164
|
-
description: /* @__PURE__ */ jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: receiverState.active.description || "" } })
|
|
1165
|
-
}
|
|
1166
|
-
),
|
|
1167
|
-
receiverState.active.config?.recommendQuestions?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1168
|
-
x.Prompts,
|
|
1169
|
-
{
|
|
1170
|
-
className: "m-t-16",
|
|
1171
|
-
wrap: true,
|
|
1172
|
-
items: [
|
|
1173
|
-
{
|
|
1174
|
-
key: "1",
|
|
1175
|
-
label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
|
|
1176
|
-
children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
|
|
1177
|
-
key: question,
|
|
1178
|
-
description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames8__default.default(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
|
|
1179
|
-
}))
|
|
1180
|
-
}
|
|
1181
|
-
]
|
|
1182
|
-
}
|
|
1183
|
-
)
|
|
1184
|
-
] }),
|
|
1278
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: welcomeMessage, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(WelcomeItem_default, {}) }),
|
|
1185
1279
|
variant: "borderless"
|
|
1186
1280
|
}
|
|
1187
|
-
]
|
|
1188
|
-
|
|
1189
|
-
);
|
|
1281
|
+
] : [];
|
|
1282
|
+
}, [receiverState.active, welcomeMessage]);
|
|
1190
1283
|
const questionList = react.useMemo(
|
|
1191
1284
|
() => chatMessage?.questionList?.length ? [
|
|
1192
1285
|
{
|
|
@@ -1214,36 +1307,36 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1214
1307
|
[chatMessage?.questionList]
|
|
1215
1308
|
);
|
|
1216
1309
|
const chatRecords = react.useMemo(() => {
|
|
1217
|
-
return (chatMessage?.message || []).map((
|
|
1218
|
-
const role = conversationRoles[MEMBER_TYPE[
|
|
1310
|
+
return (chatMessage?.message || []).map((message2, index) => {
|
|
1311
|
+
const role = conversationRoles[MEMBER_TYPE[message2.sender.type]] || {};
|
|
1219
1312
|
return {
|
|
1220
|
-
key:
|
|
1313
|
+
key: message2.id,
|
|
1221
1314
|
placement: role.placement,
|
|
1222
1315
|
variant: "borderless",
|
|
1223
1316
|
avatar: role.avatar,
|
|
1224
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(MessageRender_default, { message:
|
|
1317
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(MessageRender_default, { message: message2, placement: role.placement }),
|
|
1225
1318
|
footer: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
1226
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () =>
|
|
1319
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () => common.copyText(message2.msgContent), color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}) }),
|
|
1227
1320
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1228
1321
|
antd.Button,
|
|
1229
1322
|
{
|
|
1230
|
-
color:
|
|
1231
|
-
disabled: !!
|
|
1323
|
+
color: message2.msgFeedback === 1 ? "primary" : "default",
|
|
1324
|
+
disabled: !!message2.type,
|
|
1232
1325
|
size: "small",
|
|
1233
1326
|
variant: "text",
|
|
1234
1327
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
|
|
1235
|
-
onClick: () => chatStore.feedback(conversationState.active.id,
|
|
1328
|
+
onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 1, index)
|
|
1236
1329
|
}
|
|
1237
1330
|
),
|
|
1238
1331
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1239
1332
|
antd.Button,
|
|
1240
1333
|
{
|
|
1241
|
-
color:
|
|
1242
|
-
disabled: !!
|
|
1334
|
+
color: message2.msgFeedback === 2 ? "primary" : "default",
|
|
1335
|
+
disabled: !!message2.type,
|
|
1243
1336
|
size: "small",
|
|
1244
1337
|
variant: "text",
|
|
1245
1338
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
|
|
1246
|
-
onClick: () => chatStore.feedback(conversationState.active.id,
|
|
1339
|
+
onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 2, index)
|
|
1247
1340
|
}
|
|
1248
1341
|
)
|
|
1249
1342
|
] })
|
|
@@ -1266,23 +1359,19 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1266
1359
|
}, [firstMessage]);
|
|
1267
1360
|
const bubbleListItems = react.useMemo(() => {
|
|
1268
1361
|
const list = [];
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
if (chatRecords.length > 0) {
|
|
1273
|
-
list.push(...chatRecords, ...questionList);
|
|
1274
|
-
}
|
|
1362
|
+
list.push(...firstMessageRecord);
|
|
1363
|
+
list.push(...chatRecords, ...questionList);
|
|
1275
1364
|
if (list.length) {
|
|
1276
1365
|
return list;
|
|
1277
1366
|
}
|
|
1278
|
-
return [...
|
|
1279
|
-
}, [chatRecords, questionList,
|
|
1367
|
+
return [...welcomeMessageRecord];
|
|
1368
|
+
}, [chatRecords, questionList, welcomeMessageRecord, firstMessageRecord]);
|
|
1280
1369
|
const listRef = react.useRef(null);
|
|
1281
1370
|
const autoScrollRef = react.useRef(true);
|
|
1282
1371
|
const handleScroll = (el) => {
|
|
1283
1372
|
const target = el.target;
|
|
1284
1373
|
const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
|
|
1285
|
-
autoScrollRef.current = distanceToBottom <
|
|
1374
|
+
autoScrollRef.current = distanceToBottom < 150;
|
|
1286
1375
|
};
|
|
1287
1376
|
react.useEffect(() => {
|
|
1288
1377
|
autoScrollRef.current = true;
|
|
@@ -1307,7 +1396,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1307
1396
|
autoScroll: false,
|
|
1308
1397
|
ref: listRef,
|
|
1309
1398
|
items: bubbleListItems,
|
|
1310
|
-
className:
|
|
1399
|
+
className: classNames9__default.default(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
|
|
1311
1400
|
onScroll: handleScroll
|
|
1312
1401
|
},
|
|
1313
1402
|
conversationState.active.id
|
|
@@ -1342,7 +1431,7 @@ var CharacterList_default = () => {
|
|
|
1342
1431
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1343
1432
|
antd.Avatar,
|
|
1344
1433
|
{
|
|
1345
|
-
className:
|
|
1434
|
+
className: classNames9__default.default(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
|
|
1346
1435
|
[styles_module_default3.nsAvatarListItemIconActive]: activeCharacter.id === item.id
|
|
1347
1436
|
}),
|
|
1348
1437
|
size: 50,
|
|
@@ -1429,6 +1518,7 @@ var ConversationList_default = () => {
|
|
|
1429
1518
|
};
|
|
1430
1519
|
var ChatHeader_default = ({
|
|
1431
1520
|
title = true,
|
|
1521
|
+
avatar = true,
|
|
1432
1522
|
closeBtn = false,
|
|
1433
1523
|
newConversationBtn = true,
|
|
1434
1524
|
agentCharacter = true,
|
|
@@ -1437,18 +1527,10 @@ var ChatHeader_default = ({
|
|
|
1437
1527
|
const chatStore = useChatStore();
|
|
1438
1528
|
const receiverState = valtio.useSnapshot(chatStore.receiver);
|
|
1439
1529
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
1440
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className:
|
|
1530
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: classNames9__default.default(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
|
|
1441
1531
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
|
|
1442
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1443
|
-
|
|
1444
|
-
{
|
|
1445
|
-
control: title,
|
|
1446
|
-
DefaultComponent: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1447
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size: 22, src: receiverState.active.logo, alt: receiverState.active.name }),
|
|
1448
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default3.nsChatTitle, children: receiverState.active.name })
|
|
1449
|
-
] })
|
|
1450
|
-
}
|
|
1451
|
-
),
|
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: avatar, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size: 22, src: receiverState.active.logo, alt: receiverState.active.name }) }),
|
|
1533
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default3.nsChatTitle, children: receiverState.active.name }) }),
|
|
1452
1534
|
" "
|
|
1453
1535
|
] }),
|
|
1454
1536
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 2, children: [
|
|
@@ -1488,7 +1570,7 @@ var ChatHeader_default = ({
|
|
|
1488
1570
|
] }) });
|
|
1489
1571
|
};
|
|
1490
1572
|
var Attachments_default = react.forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
|
|
1491
|
-
const { message:
|
|
1573
|
+
const { message: message2 } = antd.App.useApp();
|
|
1492
1574
|
const fileListRef = react.useRef([]);
|
|
1493
1575
|
const [attachedFiles, setAttachedFiles, getAttachedFiles] = common.useRefState([]);
|
|
1494
1576
|
react.useEffect(() => {
|
|
@@ -1516,7 +1598,7 @@ var Attachments_default = react.forwardRef(({ fileUpload, fileUploadConfig = [],
|
|
|
1516
1598
|
onChange(files);
|
|
1517
1599
|
}, [attachedFiles]);
|
|
1518
1600
|
const onErrorTip = common.useDebounce((errorMsg) => {
|
|
1519
|
-
|
|
1601
|
+
message2.error(errorMsg);
|
|
1520
1602
|
}, 300);
|
|
1521
1603
|
const findConfigByFile = (file) => {
|
|
1522
1604
|
return fileUploadConfig.find((cfg) => cfg.allowedFileTypes?.includes(common.getFileSuffixName(file.name).toLocaleUpperCase()));
|
|
@@ -1747,7 +1829,7 @@ var SenderPromptsItems_default = () => {
|
|
|
1747
1829
|
title: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1748
1830
|
"div",
|
|
1749
1831
|
{
|
|
1750
|
-
className:
|
|
1832
|
+
className: classNames9__default.default(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
|
|
1751
1833
|
children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
|
|
1752
1834
|
}
|
|
1753
1835
|
),
|
|
@@ -1876,7 +1958,7 @@ var ConversationListHeader_default = () => {
|
|
|
1876
1958
|
type: "primary",
|
|
1877
1959
|
shape: "round",
|
|
1878
1960
|
onClick: () => chatStore.createConversation(),
|
|
1879
|
-
className:
|
|
1961
|
+
className: classNames9__default.default("m-t-16"),
|
|
1880
1962
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
|
|
1881
1963
|
children: "\u65B0\u5EFA\u4F1A\u8BDD"
|
|
1882
1964
|
}
|
|
@@ -1884,7 +1966,7 @@ var ConversationListHeader_default = () => {
|
|
|
1884
1966
|
] });
|
|
1885
1967
|
};
|
|
1886
1968
|
var ConversationListPanel_default = ({ header }) => {
|
|
1887
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className:
|
|
1969
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
|
|
1888
1970
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
|
|
1889
1971
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}) })
|
|
1890
1972
|
] });
|
|
@@ -1903,6 +1985,18 @@ var styles_module_default4 = {
|
|
|
1903
1985
|
var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout, config, services }, ref) => {
|
|
1904
1986
|
const chatStore = react.useMemo(() => createChatStore(), []);
|
|
1905
1987
|
const senderRef = react.useRef();
|
|
1988
|
+
react.useEffect(() => {
|
|
1989
|
+
chatStore.setHooks(hooks);
|
|
1990
|
+
}, [hooks]);
|
|
1991
|
+
react.useEffect(() => {
|
|
1992
|
+
chatStore.setUserInfo(userInfo);
|
|
1993
|
+
}, [userInfo]);
|
|
1994
|
+
react.useEffect(() => {
|
|
1995
|
+
chatStore.setLayout(layout, config?.receiverType);
|
|
1996
|
+
}, [layout, config?.receiverType]);
|
|
1997
|
+
react.useEffect(() => {
|
|
1998
|
+
chatStore.setParams(params);
|
|
1999
|
+
}, [params]);
|
|
1906
2000
|
common.useDeepEffect(() => {
|
|
1907
2001
|
chatStore.setServices(services);
|
|
1908
2002
|
}, [services]);
|
|
@@ -1915,18 +2009,6 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
|
|
|
1915
2009
|
chatStore.switchAgentConversation(config.receiverId, config.conversationStrategy);
|
|
1916
2010
|
}
|
|
1917
2011
|
}, [config]);
|
|
1918
|
-
react.useEffect(() => {
|
|
1919
|
-
chatStore.setUserInfo(userInfo);
|
|
1920
|
-
}, [userInfo]);
|
|
1921
|
-
react.useEffect(() => {
|
|
1922
|
-
chatStore.setLayout(layout, config?.receiverType);
|
|
1923
|
-
}, [layout, config?.receiverType]);
|
|
1924
|
-
react.useEffect(() => {
|
|
1925
|
-
chatStore.setParams(params);
|
|
1926
|
-
}, [params]);
|
|
1927
|
-
react.useEffect(() => {
|
|
1928
|
-
chatStore.setHooks(hooks);
|
|
1929
|
-
}, [hooks]);
|
|
1930
2012
|
const receiverState = valtio.useSnapshot(chatStore.receiver);
|
|
1931
2013
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
1932
2014
|
react.useImperativeHandle(
|
|
@@ -1962,19 +2044,13 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
|
|
|
1962
2044
|
}
|
|
1963
2045
|
}, [hasPreView]);
|
|
1964
2046
|
common.useWebSocket({
|
|
1965
|
-
url: configState.services.
|
|
1966
|
-
`${configState.services.websocketBaseUrls?.[0]}/lolr/conversation/ws/subscribe?NS-TOKEN=${common.getToken()}`,
|
|
1967
|
-
common.isLocalhost() ? "192.168.3.102" : ""
|
|
1968
|
-
),
|
|
2047
|
+
url: configState.services.websocketUrls?.[0],
|
|
1969
2048
|
onMessage: chatStore.acceptMessage,
|
|
1970
2049
|
clientHeartbeat: false,
|
|
1971
2050
|
reconnectInterval: 1e4
|
|
1972
2051
|
});
|
|
1973
2052
|
common.useWebSocket({
|
|
1974
|
-
url: configState.services.
|
|
1975
|
-
`${configState.services.websocketBaseUrls?.[1]}/lolr/conversation/ws/subscribe?NS-TOKEN=${common.getToken()}`,
|
|
1976
|
-
common.isLocalhost() ? "192.168.3.102" : ""
|
|
1977
|
-
),
|
|
2053
|
+
url: configState.services.websocketUrls?.[1],
|
|
1978
2054
|
onMessage: chatStore.acceptMessage,
|
|
1979
2055
|
clientHeartbeat: false,
|
|
1980
2056
|
reconnectInterval: 1e4
|
|
@@ -1982,7 +2058,7 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
|
|
|
1982
2058
|
react.useEffect(() => {
|
|
1983
2059
|
configState.hooks?.onBeforeInit?.();
|
|
1984
2060
|
}, []);
|
|
1985
|
-
return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className:
|
|
2061
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
|
|
1986
2062
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
1987
2063
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: "full-scroll", children: [
|
|
1988
2064
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
|
|
@@ -2036,15 +2112,15 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
|
|
|
2036
2112
|
}
|
|
2037
2113
|
)
|
|
2038
2114
|
] }) }),
|
|
2039
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className:
|
|
2115
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default("height-full"), children: [
|
|
2040
2116
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
2041
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className:
|
|
2117
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames9__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2042
2118
|
antd.Flex,
|
|
2043
2119
|
{
|
|
2044
2120
|
justify: "center",
|
|
2045
2121
|
vertical: true,
|
|
2046
2122
|
gap: 24,
|
|
2047
|
-
className:
|
|
2123
|
+
className: classNames9__default.default("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
|
|
2048
2124
|
children: [
|
|
2049
2125
|
common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
|
|
2050
2126
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
|
|
@@ -2081,11 +2157,5 @@ exports.Attachments = Attachments_default;
|
|
|
2081
2157
|
exports.ChatCopilot = layouts_default;
|
|
2082
2158
|
exports.ChatSender = ChatSender_default;
|
|
2083
2159
|
exports.MessageRender = MessageRender_default;
|
|
2084
|
-
Object.keys(x).forEach(function (k) {
|
|
2085
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2086
|
-
enumerable: true,
|
|
2087
|
-
get: function () { return x[k]; }
|
|
2088
|
-
});
|
|
2089
|
-
});
|
|
2090
2160
|
//# sourceMappingURL=index.cjs.js.map
|
|
2091
2161
|
//# sourceMappingURL=index.cjs.js.map
|