bhd-components 0.10.12 → 0.10.13
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/index.esm.es5.development.css +768 -0
- package/dist/index.esm.es5.development.js +3130 -159
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +2515 -1100
- package/dist/vendor.esm.es5.production.js +136 -136
- package/es2017/AIMessageList/components/content/index.d.ts +4 -0
- package/es2017/AIMessageList/components/content/index.js +29 -0
- package/es2017/AIMessageList/components/content/index.module.less +8 -0
- package/es2017/AIMessageList/components/copyIcon/index.d.ts +7 -0
- package/es2017/AIMessageList/components/copyIcon/index.js +73 -0
- package/es2017/AIMessageList/components/copyIcon/index.module.less +23 -0
- package/es2017/AIMessageList/components/errorCallback/index.d.ts +3 -0
- package/es2017/AIMessageList/components/errorCallback/index.js +6 -0
- package/es2017/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
- package/es2017/AIMessageList/components/fileList/fileIcon.js +970 -0
- package/es2017/AIMessageList/components/fileList/index.d.ts +4 -0
- package/es2017/AIMessageList/components/fileList/index.js +315 -0
- package/es2017/AIMessageList/components/fileList/index.module.less +95 -0
- package/es2017/AIMessageList/components/footer/index.d.ts +10 -0
- package/es2017/AIMessageList/components/footer/index.js +398 -0
- package/es2017/AIMessageList/components/footer/index.module.less +51 -0
- package/es2017/AIMessageList/components/header/index.d.ts +9 -0
- package/es2017/AIMessageList/components/header/index.js +94 -0
- package/es2017/AIMessageList/components/header/index.module.less +31 -0
- package/es2017/AIMessageList/components/referencesIcon/index.d.ts +9 -0
- package/es2017/AIMessageList/components/referencesIcon/index.js +63 -0
- package/es2017/AIMessageList/components/referencesIcon/index.module.less +14 -0
- package/es2017/AIMessageList/components/refreshBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/refreshBtn/index.js +29 -0
- package/es2017/AIMessageList/components/refreshBtn/index.module.less +12 -0
- package/es2017/AIMessageList/components/remarkBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/remarkBtn/index.js +51 -0
- package/es2017/AIMessageList/components/remarkBtn/index.module.less +13 -0
- package/es2017/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
- package/es2017/AIMessageList/components/renderReferrnce/index.js +68 -0
- package/es2017/AIMessageList/components/renderReferrnce/index.module.less +64 -0
- package/es2017/AIMessageList/components/sendBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/sendBtn/index.js +51 -0
- package/es2017/AIMessageList/components/sendBtn/index.module.less +25 -0
- package/es2017/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/uplodaFileBtn/index.js +33 -0
- package/es2017/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
- package/es2017/AIMessageList/components/virtuosoList/index.d.ts +5 -0
- package/es2017/AIMessageList/components/virtuosoList/index.js +696 -0
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +467 -0
- package/es2017/AIMessageList/index.d.ts +4 -0
- package/es2017/AIMessageList/index.js +58 -0
- package/es2017/AIMessageList/index.module.less +20 -0
- package/es2017/AIMessageList/type.d.ts +307 -0
- package/es2017/customerService/index.js +1 -0
- package/es2017/images/loading2.js +2 -0
- package/es2017/index.d.ts +1 -0
- package/es2017/index.js +1 -0
- package/es2017/utils/Date.d.ts +2 -1
- package/es2017/utils/Date.js +2 -1
- package/es2017/utils/dom.d.ts +4 -1
- package/es2017/utils/dom.js +44 -1
- package/es2017/utils/number.d.ts +1 -0
- package/es2017/utils/number.js +9 -0
- package/esm/AIMessageList/components/content/index.d.ts +4 -0
- package/esm/AIMessageList/components/content/index.js +29 -0
- package/esm/AIMessageList/components/content/index.module.less +8 -0
- package/esm/AIMessageList/components/copyIcon/index.d.ts +7 -0
- package/esm/AIMessageList/components/copyIcon/index.js +76 -0
- package/esm/AIMessageList/components/copyIcon/index.module.less +23 -0
- package/esm/AIMessageList/components/errorCallback/index.d.ts +3 -0
- package/esm/AIMessageList/components/errorCallback/index.js +6 -0
- package/esm/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
- package/esm/AIMessageList/components/fileList/fileIcon.js +970 -0
- package/esm/AIMessageList/components/fileList/index.d.ts +4 -0
- package/esm/AIMessageList/components/fileList/index.js +337 -0
- package/esm/AIMessageList/components/fileList/index.module.less +95 -0
- package/esm/AIMessageList/components/footer/index.d.ts +10 -0
- package/esm/AIMessageList/components/footer/index.js +414 -0
- package/esm/AIMessageList/components/footer/index.module.less +51 -0
- package/esm/AIMessageList/components/header/index.d.ts +9 -0
- package/esm/AIMessageList/components/header/index.js +96 -0
- package/esm/AIMessageList/components/header/index.module.less +31 -0
- package/esm/AIMessageList/components/referencesIcon/index.d.ts +9 -0
- package/esm/AIMessageList/components/referencesIcon/index.js +65 -0
- package/esm/AIMessageList/components/referencesIcon/index.module.less +14 -0
- package/esm/AIMessageList/components/refreshBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/refreshBtn/index.js +31 -0
- package/esm/AIMessageList/components/refreshBtn/index.module.less +12 -0
- package/esm/AIMessageList/components/remarkBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/remarkBtn/index.js +51 -0
- package/esm/AIMessageList/components/remarkBtn/index.module.less +13 -0
- package/esm/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
- package/esm/AIMessageList/components/renderReferrnce/index.js +72 -0
- package/esm/AIMessageList/components/renderReferrnce/index.module.less +64 -0
- package/esm/AIMessageList/components/sendBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/sendBtn/index.js +53 -0
- package/esm/AIMessageList/components/sendBtn/index.module.less +25 -0
- package/esm/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/uplodaFileBtn/index.js +33 -0
- package/esm/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
- package/esm/AIMessageList/components/virtuosoList/index.d.ts +5 -0
- package/esm/AIMessageList/components/virtuosoList/index.js +673 -0
- package/esm/AIMessageList/components/virtuosoList/index.module.less +467 -0
- package/esm/AIMessageList/index.d.ts +4 -0
- package/esm/AIMessageList/index.js +58 -0
- package/esm/AIMessageList/index.module.less +20 -0
- package/esm/AIMessageList/type.d.ts +307 -0
- package/esm/customerService/index.js +1 -0
- package/esm/images/loading2.js +2 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/utils/Date.d.ts +2 -1
- package/esm/utils/Date.js +2 -1
- package/esm/utils/dom.d.ts +4 -1
- package/esm/utils/dom.js +45 -1
- package/esm/utils/number.d.ts +1 -0
- package/esm/utils/number.js +9 -0
- package/package.json +2 -1
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
5
|
+
import React, { useState, useEffect, useImperativeHandle, forwardRef, useRef, useMemo } from "react";
|
|
6
|
+
import styles from "./index.module.less";
|
|
7
|
+
import { fetchEventSource } from "@microsoft/fetch-event-source";
|
|
8
|
+
import BhdEnterInput from "../../../bhdEnterInput";
|
|
9
|
+
import { Divider } from "antd";
|
|
10
|
+
import SendBtn from "../sendBtn";
|
|
11
|
+
import UploadFileBtn from "../uplodaFileBtn";
|
|
12
|
+
import FileList from "../fileList";
|
|
13
|
+
import References from "../renderReferrnce";
|
|
14
|
+
import { guidGenerator } from "../../../utils/number";
|
|
15
|
+
var TextArea = BhdEnterInput.TextArea;
|
|
16
|
+
var defaultProps = {
|
|
17
|
+
placeholder: "请输入内容\n按Enter发送,Shift+Enter换行",
|
|
18
|
+
className: "",
|
|
19
|
+
maxLength: 500,
|
|
20
|
+
fileUpload: false
|
|
21
|
+
};
|
|
22
|
+
var defaultFileUploadProps = {
|
|
23
|
+
accept: ".pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.txt,.text,.png,.jpg,.jpeg,.gif,.webp",
|
|
24
|
+
maxCount: 10,
|
|
25
|
+
maxSize: 50 * 1024 * 1024,
|
|
26
|
+
mapUploadCount: 1,
|
|
27
|
+
multiple: true
|
|
28
|
+
};
|
|
29
|
+
var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
30
|
+
var footerConfig = props.footerConfig, prefix = props.prefix, errorCallback = props.errorCallback, apiRef = props.apiRef;
|
|
31
|
+
var _footerConfig_placeholder = footerConfig.placeholder, placeholder = _footerConfig_placeholder === void 0 ? defaultProps.placeholder : _footerConfig_placeholder, _footerConfig_className = footerConfig.className, className = _footerConfig_className === void 0 ? defaultProps.className : _footerConfig_className, _footerConfig_maxLength = footerConfig.maxLength, maxLength = _footerConfig_maxLength === void 0 ? defaultProps.maxLength : _footerConfig_maxLength, renderAction = footerConfig.renderAction, fileUpload = footerConfig.fileUpload, sendMsgAjaxParams = footerConfig.sendMsgAjaxParams, _footerConfig_onClickStop = footerConfig.onClickStop, onClickStop = _footerConfig_onClickStop === void 0 ? function() {} : _footerConfig_onClickStop, _footerConfig_conversionContent = footerConfig.conversionContent, conversionContent = _footerConfig_conversionContent === void 0 ? function(str) {
|
|
32
|
+
return str;
|
|
33
|
+
} : _footerConfig_conversionContent;
|
|
34
|
+
if (fileUpload) {
|
|
35
|
+
fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
|
|
36
|
+
}
|
|
37
|
+
var footerDomRef = useRef(null);
|
|
38
|
+
var resizeObserverRef = useRef(null);
|
|
39
|
+
var fileListRef = useRef(null);
|
|
40
|
+
var ctrl = useRef(); //停止生成ai回答时使用
|
|
41
|
+
var _useState = _sliced_to_array(useState(""), 2), textValue = _useState[0], setTextValue = _useState[1];
|
|
42
|
+
var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
|
|
43
|
+
var _useState2 = _sliced_to_array(useState(true), 2), fileCanSending = _useState2[0], setFileCanSending = _useState2[1]; // 是否允许发送 关联文件
|
|
44
|
+
var updateMsgRef = useRef(null);
|
|
45
|
+
// const [referencesSource, setReferencesSource] = useState<referenceType>({
|
|
46
|
+
// type: "file",
|
|
47
|
+
// value: {
|
|
48
|
+
// name: "文件名字.doc",
|
|
49
|
+
// suffix: "doc",
|
|
50
|
+
// fileId: "",
|
|
51
|
+
// url: "",
|
|
52
|
+
// status: undefined,
|
|
53
|
+
// source: undefined,
|
|
54
|
+
// },
|
|
55
|
+
// });
|
|
56
|
+
var _useState3 = _sliced_to_array(useState(null), 2), referencesSource = _useState3[0], setReferencesSource = _useState3[1];
|
|
57
|
+
var recordRef = useRef({
|
|
58
|
+
value: textValue,
|
|
59
|
+
referencesSource: referencesSource,
|
|
60
|
+
sending: sending
|
|
61
|
+
});
|
|
62
|
+
useImperativeHandle(ref, function() {
|
|
63
|
+
return _object_spread({
|
|
64
|
+
setTextValue: setTextValue,
|
|
65
|
+
sendMsg: sendMsg,
|
|
66
|
+
refreshSendMsg: refreshSendMsg,
|
|
67
|
+
clearText: function() {
|
|
68
|
+
setTextValue("");
|
|
69
|
+
},
|
|
70
|
+
getCanSendMsg: function() {
|
|
71
|
+
return canSendMsg;
|
|
72
|
+
},
|
|
73
|
+
stopMessage: function() {
|
|
74
|
+
stopMessage();
|
|
75
|
+
},
|
|
76
|
+
setReferences: function(reference) {
|
|
77
|
+
setReferencesSource(reference);
|
|
78
|
+
}
|
|
79
|
+
}, fileListRef.current);
|
|
80
|
+
});
|
|
81
|
+
useEffect(function() {
|
|
82
|
+
listenerFooterHeight();
|
|
83
|
+
return function() {
|
|
84
|
+
resizeObserverRef.current && resizeObserverRef.current.disconnect();
|
|
85
|
+
clearTimeout(updateMsgRef.current);
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
88
|
+
useEffect(function() {
|
|
89
|
+
recordRef.current.value = textValue;
|
|
90
|
+
recordRef.current.referencesSource = referencesSource;
|
|
91
|
+
recordRef.current.sending = sending;
|
|
92
|
+
}, [
|
|
93
|
+
textValue,
|
|
94
|
+
referencesSource,
|
|
95
|
+
sending
|
|
96
|
+
]);
|
|
97
|
+
// 监听footer变化
|
|
98
|
+
var listenerFooterHeight = function() {
|
|
99
|
+
if (!footerDomRef.current) return;
|
|
100
|
+
// 创建ResizeObserver实例
|
|
101
|
+
resizeObserverRef.current = new ResizeObserver(function(entries) {
|
|
102
|
+
apiRef.contentApi && apiRef.contentApi.scrollToBottom();
|
|
103
|
+
});
|
|
104
|
+
// 开始观察footer元素
|
|
105
|
+
resizeObserverRef.current.observe(footerDomRef.current);
|
|
106
|
+
};
|
|
107
|
+
// 是否允许发送消息
|
|
108
|
+
var canSendMsg = useMemo(function() {
|
|
109
|
+
if (textValue.trim().length === 0) return false;
|
|
110
|
+
if (typeof maxLength === "function") {
|
|
111
|
+
if (maxLength(textValue)) return false;
|
|
112
|
+
}
|
|
113
|
+
if (textValue.trim().length > maxLength) return false;
|
|
114
|
+
if (sending) return false;
|
|
115
|
+
if (!fileCanSending) return false;
|
|
116
|
+
return true;
|
|
117
|
+
}, [
|
|
118
|
+
textValue,
|
|
119
|
+
maxLength,
|
|
120
|
+
sending,
|
|
121
|
+
fileCanSending
|
|
122
|
+
]);
|
|
123
|
+
var stopMessage = function() {
|
|
124
|
+
ctrl.current && ctrl.current.abort();
|
|
125
|
+
apiRef.contentApi.clearInputing();
|
|
126
|
+
setSending(false);
|
|
127
|
+
};
|
|
128
|
+
var getCls = function(clsName) {
|
|
129
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
130
|
+
};
|
|
131
|
+
var renderBtn = function() {
|
|
132
|
+
var sendNode = /*#__PURE__*/ _jsx(SendBtn, {
|
|
133
|
+
prefix: prefix,
|
|
134
|
+
canSendMsg: canSendMsg,
|
|
135
|
+
sending: sending,
|
|
136
|
+
stopMessage: function() {
|
|
137
|
+
onClickStop();
|
|
138
|
+
stopMessage();
|
|
139
|
+
},
|
|
140
|
+
clickFn: function() {
|
|
141
|
+
if (textValue.trim().length === 0) return;
|
|
142
|
+
sendMsg(textValue);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (fileUpload) {
|
|
146
|
+
var fileNode = /*#__PURE__*/ _jsx(UploadFileBtn, {
|
|
147
|
+
prefix: prefix,
|
|
148
|
+
fileUpload: fileUpload,
|
|
149
|
+
customRequest: function(options) {
|
|
150
|
+
var _fileListRef_current;
|
|
151
|
+
console.log("customRequestcustomRequest", options);
|
|
152
|
+
(_fileListRef_current = fileListRef.current) === null || _fileListRef_current === void 0 ? void 0 : _fileListRef_current.addFile(options.file);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
if (renderAction) {
|
|
156
|
+
return renderAction(sendNode, fileNode);
|
|
157
|
+
} else {
|
|
158
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
159
|
+
className: "".concat(getCls("footerActionBtn")),
|
|
160
|
+
children: [
|
|
161
|
+
fileNode,
|
|
162
|
+
/*#__PURE__*/ _jsx(Divider, {
|
|
163
|
+
type: "vertical"
|
|
164
|
+
}),
|
|
165
|
+
sendNode
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
var fileNode1 = null;
|
|
171
|
+
if (renderAction) {
|
|
172
|
+
return renderAction(sendNode, fileNode1);
|
|
173
|
+
} else {
|
|
174
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
175
|
+
className: "".concat(getCls("footerActionBtn")),
|
|
176
|
+
children: sendNode
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var onPressEnter = function(e) {
|
|
182
|
+
// 判断是否按下了 Shift 键
|
|
183
|
+
if (e.shiftKey) {
|
|
184
|
+
// 如果按下了 Shift + Enter,则允许换行(默认行为)
|
|
185
|
+
return;
|
|
186
|
+
} else {
|
|
187
|
+
if (textValue.length === 0) {
|
|
188
|
+
// 内容为空时 执行换行操作
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// 如果只按了 Enter,则阻止默认行为并发送消息
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
// 在这里添加发送消息的逻辑
|
|
194
|
+
sendMsg(textValue);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
// 发现消息
|
|
198
|
+
var sendMsg = function(value) {
|
|
199
|
+
if (value.trim().length === 0) return;
|
|
200
|
+
if (!canSendMsg) return;
|
|
201
|
+
console.log("发送消息:", value);
|
|
202
|
+
apiRef.contentApi.addMsg({
|
|
203
|
+
id: guidGenerator(),
|
|
204
|
+
createTime: new Date().getTime(),
|
|
205
|
+
content: value,
|
|
206
|
+
location: "right",
|
|
207
|
+
reference: recordRef.current.referencesSource,
|
|
208
|
+
source: null,
|
|
209
|
+
fileList: fileListRef.current.getFileList()
|
|
210
|
+
});
|
|
211
|
+
sendMsgAjax();
|
|
212
|
+
};
|
|
213
|
+
// 重新发送消息
|
|
214
|
+
var refreshSendMsg = function refreshSendMsg(msgId, value, reference, fileList) {
|
|
215
|
+
sendMsgAjax({
|
|
216
|
+
id: msgId,
|
|
217
|
+
value: value,
|
|
218
|
+
reference: reference || null,
|
|
219
|
+
fileList: fileList || []
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
var sendMsgAjax = function(recordObj) {
|
|
223
|
+
var url = sendMsgAjaxParams.url, _sendMsgAjaxParams_method = sendMsgAjaxParams.method, method = _sendMsgAjaxParams_method === void 0 ? "POST" : _sendMsgAjaxParams_method, _sendMsgAjaxParams_headers = sendMsgAjaxParams.headers, headers = _sendMsgAjaxParams_headers === void 0 ? function() {
|
|
224
|
+
return {};
|
|
225
|
+
} : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
|
|
226
|
+
return "";
|
|
227
|
+
} : _sendMsgAjaxParams_params, _sendMsgAjaxParams_onOpen = sendMsgAjaxParams.onOpen, onOpen = _sendMsgAjaxParams_onOpen === void 0 ? function() {} : _sendMsgAjaxParams_onOpen, _sendMsgAjaxParams_onMessage = sendMsgAjaxParams.onMessage, onMessage = _sendMsgAjaxParams_onMessage === void 0 ? function(ev) {
|
|
228
|
+
return ev;
|
|
229
|
+
} : _sendMsgAjaxParams_onMessage, _sendMsgAjaxParams_onClose = sendMsgAjaxParams.onClose, onClose = _sendMsgAjaxParams_onClose === void 0 ? function() {} : _sendMsgAjaxParams_onClose, _sendMsgAjaxParams_onError = sendMsgAjaxParams.onError, onError = _sendMsgAjaxParams_onError === void 0 ? function() {} : _sendMsgAjaxParams_onError, _sendMsgAjaxParams_coverProps = sendMsgAjaxParams.coverProps, coverProps = _sendMsgAjaxParams_coverProps === void 0 ? {} : _sendMsgAjaxParams_coverProps, _sendMsgAjaxParams_beforeSendMsg = sendMsgAjaxParams.beforeSendMsg, beforeSendMsg = _sendMsgAjaxParams_beforeSendMsg === void 0 ? function() {
|
|
230
|
+
return Promise.resolve();
|
|
231
|
+
} : _sendMsgAjaxParams_beforeSendMsg;
|
|
232
|
+
ctrl.current = new AbortController();
|
|
233
|
+
// apiRef
|
|
234
|
+
console.log("apiRef", apiRef);
|
|
235
|
+
var msgId = "inputing";
|
|
236
|
+
var createTime = new Date().getTime();
|
|
237
|
+
if (recordObj) {
|
|
238
|
+
apiRef.contentApi.addMsg({
|
|
239
|
+
id: msgId,
|
|
240
|
+
createTime: createTime,
|
|
241
|
+
content: "正在输入...",
|
|
242
|
+
location: "left",
|
|
243
|
+
reference: recordObj.reference || null,
|
|
244
|
+
source: null,
|
|
245
|
+
fileList: recordObj.fileList || []
|
|
246
|
+
});
|
|
247
|
+
} else {
|
|
248
|
+
apiRef.contentApi.addMsg({
|
|
249
|
+
id: msgId,
|
|
250
|
+
createTime: createTime,
|
|
251
|
+
content: "正在输入...",
|
|
252
|
+
location: "left",
|
|
253
|
+
reference: null,
|
|
254
|
+
source: null,
|
|
255
|
+
fileList: fileListRef.current.getFileList()
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
var msgContent = "";
|
|
259
|
+
setSending(true);
|
|
260
|
+
setTextValue("");
|
|
261
|
+
fileListRef.current.clearFileList();
|
|
262
|
+
setReferencesSource(null);
|
|
263
|
+
var recordMsgObj = {};
|
|
264
|
+
var arg = [
|
|
265
|
+
recordRef.current.value,
|
|
266
|
+
recordRef.current.referencesSource,
|
|
267
|
+
fileListRef.current ? fileListRef.current.getFileList() : []
|
|
268
|
+
];
|
|
269
|
+
if (recordObj) {
|
|
270
|
+
arg = [
|
|
271
|
+
recordObj.value,
|
|
272
|
+
recordObj.reference || null,
|
|
273
|
+
recordObj.fileList || []
|
|
274
|
+
];
|
|
275
|
+
} else {
|
|
276
|
+
arg = [
|
|
277
|
+
recordRef.current.value,
|
|
278
|
+
recordRef.current.referencesSource,
|
|
279
|
+
fileListRef.current ? fileListRef.current.getFileList() : []
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
|
|
283
|
+
var callback = function() {
|
|
284
|
+
var isClose = false;
|
|
285
|
+
var closeCallback = function() {
|
|
286
|
+
if (isClose) return;
|
|
287
|
+
isClose = true;
|
|
288
|
+
onClose();
|
|
289
|
+
setSending(false);
|
|
290
|
+
if (recordMsgObj.id) {
|
|
291
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
292
|
+
}
|
|
293
|
+
apiRef.contentApi.setSendingId("");
|
|
294
|
+
console.log("onclose: ", recordMsgObj);
|
|
295
|
+
};
|
|
296
|
+
fetchEventSource(url, _object_spread({
|
|
297
|
+
method: method,
|
|
298
|
+
headers: _object_spread({
|
|
299
|
+
"Content-Type": "application/json",
|
|
300
|
+
Accept: "text/event-stream,application/json"
|
|
301
|
+
}, headers()),
|
|
302
|
+
body: params.apply(void 0, _to_consumable_array(arg).concat([
|
|
303
|
+
beforeInfo
|
|
304
|
+
])),
|
|
305
|
+
openWhenHidden: true,
|
|
306
|
+
signal: ctrl.current.signal,
|
|
307
|
+
onopen: function(res) {
|
|
308
|
+
var retryFetch = function() {
|
|
309
|
+
callback();
|
|
310
|
+
};
|
|
311
|
+
onOpen(res, {
|
|
312
|
+
retryFetch: retryFetch,
|
|
313
|
+
stopMessage: stopMessage
|
|
314
|
+
});
|
|
315
|
+
return null;
|
|
316
|
+
},
|
|
317
|
+
onmessage: function(ev) {
|
|
318
|
+
var data = onMessage(ev, closeCallback);
|
|
319
|
+
if (recordObj) {
|
|
320
|
+
data.id = recordObj.id;
|
|
321
|
+
}
|
|
322
|
+
msgContent += data.content;
|
|
323
|
+
var str = msgContent.replace(/\\n/g, "\n");
|
|
324
|
+
str = conversionContent(str);
|
|
325
|
+
delete data.content;
|
|
326
|
+
recordMsgObj = _object_spread({
|
|
327
|
+
createTime: createTime,
|
|
328
|
+
content: str || "正在输入...",
|
|
329
|
+
location: "left",
|
|
330
|
+
reference: null,
|
|
331
|
+
source: null
|
|
332
|
+
}, data);
|
|
333
|
+
apiRef.contentApi.setSendingId(data.id);
|
|
334
|
+
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
335
|
+
msgId = data.id;
|
|
336
|
+
// updateMsgRef.current = setTimeout(function () {
|
|
337
|
+
apiRef.contentApi.scrollToBottom();
|
|
338
|
+
// }, 100);
|
|
339
|
+
},
|
|
340
|
+
onclose: function() {
|
|
341
|
+
closeCallback();
|
|
342
|
+
},
|
|
343
|
+
onerror: function(err) {
|
|
344
|
+
onError(err);
|
|
345
|
+
if (recordMsgObj.id) {
|
|
346
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
347
|
+
}
|
|
348
|
+
console.log("onerror: ", err);
|
|
349
|
+
}
|
|
350
|
+
}, coverProps));
|
|
351
|
+
};
|
|
352
|
+
callback();
|
|
353
|
+
}).catch(function() {
|
|
354
|
+
stopMessage();
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
// 判断是否超出最大字数
|
|
358
|
+
var judegTextLengthWarn = function() {
|
|
359
|
+
if (typeof maxLength === "function") {
|
|
360
|
+
return maxLength(textValue);
|
|
361
|
+
} else {
|
|
362
|
+
return textValue.length > maxLength;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
366
|
+
className: "".concat(getCls("footer"), " ").concat(className),
|
|
367
|
+
ref: footerDomRef,
|
|
368
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
369
|
+
className: "".concat(getCls("footerBody"), " ").concat(judegTextLengthWarn() ? getCls("footerBodyWarn") : ""),
|
|
370
|
+
children: [
|
|
371
|
+
fileUpload && /*#__PURE__*/ _jsx("div", {
|
|
372
|
+
className: getCls("footerFile"),
|
|
373
|
+
children: /*#__PURE__*/ _jsx(FileList, {
|
|
374
|
+
prefix: prefix,
|
|
375
|
+
fileUpload: fileUpload,
|
|
376
|
+
ref: fileListRef,
|
|
377
|
+
errorCallback: errorCallback,
|
|
378
|
+
changeFileCanSending: setFileCanSending
|
|
379
|
+
})
|
|
380
|
+
}),
|
|
381
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
382
|
+
className: getCls("footerInput"),
|
|
383
|
+
children: [
|
|
384
|
+
/*#__PURE__*/ _jsx(TextArea, {
|
|
385
|
+
value: textValue,
|
|
386
|
+
onChange: function(e) {
|
|
387
|
+
setTextValue(e.target.value);
|
|
388
|
+
},
|
|
389
|
+
placeholder: placeholder,
|
|
390
|
+
autoSize: {
|
|
391
|
+
minRows: 2,
|
|
392
|
+
maxRows: 6
|
|
393
|
+
},
|
|
394
|
+
onPressEnter: onPressEnter
|
|
395
|
+
}),
|
|
396
|
+
/*#__PURE__*/ _jsx(References, {
|
|
397
|
+
prefix: prefix,
|
|
398
|
+
referencesSource: referencesSource,
|
|
399
|
+
fileUpload: fileUpload,
|
|
400
|
+
deleteReferences: function() {
|
|
401
|
+
return setReferencesSource(null);
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
]
|
|
405
|
+
}),
|
|
406
|
+
/*#__PURE__*/ _jsx("div", {
|
|
407
|
+
className: getCls("footerAction"),
|
|
408
|
+
children: renderBtn()
|
|
409
|
+
})
|
|
410
|
+
]
|
|
411
|
+
})
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
export default Footer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.footer {
|
|
2
|
+
width: 100%;
|
|
3
|
+
padding: 16px;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
.footerBody {
|
|
6
|
+
width: 100%;
|
|
7
|
+
border-radius: 8px;
|
|
8
|
+
background: #ffffff;
|
|
9
|
+
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
10
|
+
padding-bottom: 12px;
|
|
11
|
+
&.footerBodyWarn {
|
|
12
|
+
border-color: #f4523b;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.footerFile {
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
.footerInput {
|
|
19
|
+
:global {
|
|
20
|
+
.bhd-input {
|
|
21
|
+
border: none;
|
|
22
|
+
box-shadow: none;
|
|
23
|
+
background: transparent;
|
|
24
|
+
padding: 12px 16px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.footerAction {
|
|
29
|
+
width: 100%;
|
|
30
|
+
padding: 0 16px;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
.footerActionBtn {
|
|
33
|
+
width: 100%;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
:global {
|
|
38
|
+
.bhd-divider {
|
|
39
|
+
border-color: rgba(0, 0, 0, 0.06);
|
|
40
|
+
height: 16px;
|
|
41
|
+
top: 0;
|
|
42
|
+
margin: 0 16px;
|
|
43
|
+
}
|
|
44
|
+
.bhd-upload-wrapper {
|
|
45
|
+
display: flex;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { headerConfigProps, errorMessageProps } from "../../type";
|
|
3
|
+
interface IProps {
|
|
4
|
+
headerConfig: headerConfigProps;
|
|
5
|
+
prefix: string;
|
|
6
|
+
errorCallback: (error: errorMessageProps) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const Header: (props: IProps) => React.JSX.Element;
|
|
9
|
+
export default Header;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styles from "./index.module.less";
|
|
4
|
+
var defaultProps = {
|
|
5
|
+
icon: /*#__PURE__*/ _jsx("i", {
|
|
6
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
width: "1em",
|
|
9
|
+
height: "1em",
|
|
10
|
+
viewBox: "0 0 16 16",
|
|
11
|
+
fill: "none",
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ _jsx("path", {
|
|
14
|
+
d: "M12.6063 14C12.2547 13.9994 11.9095 13.9066 11.6051 13.7309C11.3006 13.5551 11.0476 13.3025 10.8714 12.9983L7.15187 6.55597L4.21122 11.6493H7.67426C7.98599 11.6493 8.28495 11.7731 8.50538 11.9935C8.7258 12.2139 8.84963 12.5129 8.84963 12.8246C8.84963 13.1364 8.7258 13.4353 8.50538 13.6557C8.28495 13.8762 7.98599 14 7.67426 14H2.17613C1.96974 14.0001 1.76696 13.9459 1.58818 13.8428C1.40939 13.7397 1.26091 13.5913 1.15766 13.4126C1.05441 13.2339 1.00003 13.0312 1 12.8248C0.999967 12.6184 1.05428 12.4157 1.15747 12.2369L6.13322 3.61754C6.23638 3.43887 6.38476 3.29051 6.56343 3.18736C6.7421 3.08421 6.94478 3.0299 7.15109 3.0299C7.3574 3.0299 7.56008 3.08421 7.73875 3.18736C7.91742 3.29051 8.0658 3.43887 8.16896 3.61754L12.2582 10.6998V4.20522C12.2582 3.8935 12.3821 3.59454 12.6025 3.37411C12.8229 3.15368 13.1219 3.02985 13.4336 3.02985C13.7453 3.02985 14.0443 3.15368 14.2647 3.37411C14.4851 3.59454 14.609 3.8935 14.609 4.20522V11.9966C14.609 12.5279 14.398 13.0373 14.0224 13.413C13.6469 13.7887 13.1375 13.9998 12.6063 14Z",
|
|
15
|
+
fill: "url(#paint0_linear_34_244)"
|
|
16
|
+
}),
|
|
17
|
+
/*#__PURE__*/ _jsx("path", {
|
|
18
|
+
d: "M13.4336 2.35075C14.0827 2.35075 14.609 1.82451 14.609 1.17537C14.609 0.526232 14.0827 0 13.4336 0C12.7845 0 12.2582 0.526232 12.2582 1.17537C12.2582 1.82451 12.7845 2.35075 13.4336 2.35075Z",
|
|
19
|
+
fill: "url(#paint1_linear_34_244)"
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ _jsxs("defs", {
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsxs("linearGradient", {
|
|
24
|
+
id: "paint0_linear_34_244",
|
|
25
|
+
x1: "14.609",
|
|
26
|
+
y1: "0",
|
|
27
|
+
x2: "-0.275842",
|
|
28
|
+
y2: "13.609",
|
|
29
|
+
gradientUnits: "userSpaceOnUse",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ _jsx("stop", {
|
|
32
|
+
stopColor: "#F87AFD"
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _jsx("stop", {
|
|
35
|
+
offset: "1",
|
|
36
|
+
stopColor: "#41DAF8"
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsxs("linearGradient", {
|
|
41
|
+
id: "paint1_linear_34_244",
|
|
42
|
+
x1: "14.609",
|
|
43
|
+
y1: "0",
|
|
44
|
+
x2: "-0.275842",
|
|
45
|
+
y2: "13.609",
|
|
46
|
+
gradientUnits: "userSpaceOnUse",
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ _jsx("stop", {
|
|
49
|
+
stopColor: "#F87AFD"
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ _jsx("stop", {
|
|
52
|
+
offset: "1",
|
|
53
|
+
stopColor: "#41DAF8"
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
className: "",
|
|
63
|
+
renderRightHead: function() {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var Header = function(props) {
|
|
68
|
+
var headerConfig = props.headerConfig, prefix = props.prefix;
|
|
69
|
+
var _headerConfig_icon = headerConfig.icon, icon = _headerConfig_icon === void 0 ? defaultProps.icon : _headerConfig_icon, title = headerConfig.title, _headerConfig_className = headerConfig.className, className = _headerConfig_className === void 0 ? defaultProps.className : _headerConfig_className, _headerConfig_renderRightHead = headerConfig.renderRightHead, renderRightHead = _headerConfig_renderRightHead === void 0 ? defaultProps.renderRightHead : _headerConfig_renderRightHead;
|
|
70
|
+
var getCls = function(clsName) {
|
|
71
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
72
|
+
};
|
|
73
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
74
|
+
className: "".concat(getCls("header"), " ").concat(className),
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
77
|
+
className: getCls("headerLeft"),
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ _jsx("div", {
|
|
80
|
+
className: getCls("headerIcon"),
|
|
81
|
+
children: icon
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ _jsx("div", {
|
|
84
|
+
className: getCls("headerTitle"),
|
|
85
|
+
children: title
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ _jsx("div", {
|
|
90
|
+
className: getCls("headerRight"),
|
|
91
|
+
children: renderRightHead()
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export default Header;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.header {
|
|
2
|
+
width: 100%;
|
|
3
|
+
padding: 8px 16px;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 8px;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
border-bottom: 1px solid #ebebeb;
|
|
10
|
+
.headerLeft {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: 8px;
|
|
14
|
+
.headerIcon {
|
|
15
|
+
&>i{
|
|
16
|
+
line-height: 1;
|
|
17
|
+
font-size: 16px;
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.headerTitle {
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
color: rgba(0, 0, 0, 0.65);
|
|
24
|
+
font-size: 16px;
|
|
25
|
+
line-height: 1.5;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.headerRight {
|
|
29
|
+
font-size: 16px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { dataItemType, AIMessageListRefProps } from "../../type";
|
|
3
|
+
interface ReferencesIconProps {
|
|
4
|
+
prefix: string;
|
|
5
|
+
item: dataItemType;
|
|
6
|
+
apiRef: AIMessageListRefProps;
|
|
7
|
+
}
|
|
8
|
+
declare const ReferencesIcon: (props: ReferencesIconProps) => React.JSX.Element;
|
|
9
|
+
export default ReferencesIcon;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styles from "./index.module.less";
|
|
4
|
+
var referencesIcon = /*#__PURE__*/ _jsx("i", {
|
|
5
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
shapeRendering: "geometricPrecision",
|
|
9
|
+
fill: "currentColor",
|
|
10
|
+
viewBox: "0 0 14 14",
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ _jsx("path", {
|
|
14
|
+
"fill-rule": "evenodd",
|
|
15
|
+
"clip-rule": "evenodd",
|
|
16
|
+
d: "M6.28443 3.03861C3.77423 4.65069 2.37971 6.52702 2.10085 8.66759C1.66674 12 4.6468 13.6311 6.15677 12.1655C7.66673 10.7 6.7616 8.83982 5.66823 8.33136C4.57487 7.82286 3.90623 7.99996 4.02287 7.32046C4.1395 6.64099 5.69503 4.75706 7.06163 3.87969C7.1523 3.80259 7.1868 3.65299 7.0995 3.53949C7.04207 3.46486 6.92943 3.31847 6.7616 3.10033C6.61483 2.90957 6.47423 2.91671 6.28443 3.03861Z"
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ _jsx("path", {
|
|
19
|
+
"fill-rule": "evenodd",
|
|
20
|
+
"clip-rule": "evenodd",
|
|
21
|
+
d: "M12.893 3.03861C10.3828 4.65069 8.98827 6.52702 8.7094 8.66759C8.2753 12 11.2554 13.6311 12.7653 12.1655C14.2753 10.7 13.3702 8.83982 12.2768 8.33136C11.1834 7.82286 10.5148 7.99996 10.6314 7.32046C10.7481 6.64099 12.3036 4.75706 13.6702 3.87969C13.7609 3.80259 13.7954 3.65299 13.708 3.53949C13.6506 3.46486 13.538 3.31847 13.3702 3.10033C13.2234 2.90957 13.0828 2.91671 12.893 3.03861Z"
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
var ReferencesIcon = function(props) {
|
|
27
|
+
var prefix = props.prefix, apiRef = props.apiRef, item = props.item;
|
|
28
|
+
var getCls = function(clsName) {
|
|
29
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
30
|
+
};
|
|
31
|
+
var clickFn = function() {
|
|
32
|
+
console.log("apiRef", apiRef);
|
|
33
|
+
if (apiRef && apiRef.footerApi) {
|
|
34
|
+
console.log("itemitem", item);
|
|
35
|
+
if (item.type === "file") {
|
|
36
|
+
apiRef.footerApi.setReferences({
|
|
37
|
+
type: "file",
|
|
38
|
+
value: {
|
|
39
|
+
name: item.fileTitle,
|
|
40
|
+
suffix: item.suffix,
|
|
41
|
+
fileId: item.id,
|
|
42
|
+
url: "",
|
|
43
|
+
status: "success",
|
|
44
|
+
source: null
|
|
45
|
+
},
|
|
46
|
+
source: item
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
apiRef.footerApi.setReferences({
|
|
50
|
+
type: "text",
|
|
51
|
+
value: item.content,
|
|
52
|
+
source: item
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
58
|
+
className: "".concat(getCls("msgItem-action-reference")),
|
|
59
|
+
onClick: function() {
|
|
60
|
+
return clickFn();
|
|
61
|
+
},
|
|
62
|
+
children: referencesIcon
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export default ReferencesIcon;
|