bhd-components 0.10.5 → 0.10.7
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.css +1244 -1202
- package/dist/index.esm.es5.development.js +490 -256
- package/dist/index.esm.es5.production.css +2 -2
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +2 -2
- package/dist/vendor.esm.es5.production.js +2 -2
- package/es2017/AIMessageList/components/copyIcon/index.js +23 -8
- package/es2017/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/es2017/AIMessageList/components/fileList/index.js +16 -3
- package/es2017/AIMessageList/components/footer/index.js +61 -42
- package/es2017/AIMessageList/components/header/index.js +4 -4
- package/es2017/AIMessageList/components/referencesIcon/index.js +19 -8
- package/es2017/AIMessageList/components/referencesIcon/index.module.less +1 -1
- 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/virtuosoList/index.js +109 -19
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/es2017/AIMessageList/type.d.ts +45 -11
- package/es2017/customerService/historyFun.js +7 -1
- package/es2017/customerService/index.module.less +1 -0
- package/es2017/customerService/index2.module.less +1 -0
- package/esm/AIMessageList/components/copyIcon/index.js +23 -8
- package/esm/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/esm/AIMessageList/components/fileList/index.js +12 -3
- package/esm/AIMessageList/components/footer/index.js +65 -44
- package/esm/AIMessageList/components/header/index.js +4 -4
- package/esm/AIMessageList/components/referencesIcon/index.js +19 -8
- package/esm/AIMessageList/components/referencesIcon/index.module.less +1 -1
- 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/virtuosoList/index.js +111 -19
- package/esm/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/esm/AIMessageList/type.d.ts +45 -11
- package/esm/customerService/historyFun.js +7 -1
- package/esm/customerService/index.module.less +1 -0
- package/esm/customerService/index2.module.less +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ import hljs from "highlight.js";
|
|
|
11
11
|
import "highlight.js/styles/github.css";
|
|
12
12
|
import CopyIcon from "../copyIcon";
|
|
13
13
|
import ReferencesIcon from "../referencesIcon";
|
|
14
|
+
import { UpVoteBtn, DownVoteBtn } from "../remarkBtn";
|
|
15
|
+
import RefreshBtn from "../refreshBtn";
|
|
14
16
|
const Header = ({ context })=>{
|
|
15
17
|
const { prefix, loading } = context;
|
|
16
18
|
if (!loading) return null;
|
|
@@ -43,7 +45,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
43
45
|
const { getList, coverRenderText, msgAction = [
|
|
44
46
|
"copy",
|
|
45
47
|
"references"
|
|
46
|
-
], coverRenderReferences, onRecordMessage = ()=>{} } = contentConfig;
|
|
48
|
+
], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{} } = contentConfig;
|
|
47
49
|
const loadMoreProps = contentConfig.loadMore || true;
|
|
48
50
|
const virtuosoRef = useRef(null);
|
|
49
51
|
const [loading, setLoading] = useState(false); // 是否加载中
|
|
@@ -65,6 +67,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
65
67
|
maxPage: Math.ceil(total / pageSize)
|
|
66
68
|
});
|
|
67
69
|
const timeRenderCache = useRef(new Map()).current;
|
|
70
|
+
const htmlRenderCache = useRef(new Map()).current;
|
|
68
71
|
useImperativeHandle(ref, ()=>{
|
|
69
72
|
return {
|
|
70
73
|
addMsg: (msg)=>{
|
|
@@ -96,6 +99,29 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
96
99
|
},
|
|
97
100
|
recordMsg: (msg)=>{
|
|
98
101
|
onRecordMessage(msg);
|
|
102
|
+
},
|
|
103
|
+
getDataSource: ()=>{
|
|
104
|
+
return recordRef.current.dataSource;
|
|
105
|
+
},
|
|
106
|
+
upateDataSource: (id, obj)=>{
|
|
107
|
+
setDataSource((list)=>{
|
|
108
|
+
return list.map((item)=>{
|
|
109
|
+
if (item.id === id) {
|
|
110
|
+
return _object_spread({}, item, obj);
|
|
111
|
+
}
|
|
112
|
+
return item;
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
changeDataSource: (data)=>{
|
|
117
|
+
setDataSource(data);
|
|
118
|
+
},
|
|
119
|
+
scrollToBottom: function() {
|
|
120
|
+
if (!virtuosoRef.current) return;
|
|
121
|
+
virtuosoRef.current.scrollToIndex({
|
|
122
|
+
index: "LAST",
|
|
123
|
+
behavior: "auto"
|
|
124
|
+
});
|
|
99
125
|
}
|
|
100
126
|
};
|
|
101
127
|
});
|
|
@@ -112,18 +138,18 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
112
138
|
}, []);
|
|
113
139
|
useEffect(()=>{
|
|
114
140
|
if (!virtuosoRef.current) return;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
// virtuosoRef.current.scrollToIndex({
|
|
142
|
+
// index: "LAST", // 或者使用 dataSource.length - 1
|
|
143
|
+
// behavior: "auto", // 可以是 "smooth" 实现平滑滚动
|
|
144
|
+
// });
|
|
145
|
+
// clearTimeout(timerRef.current.scrollTimer);
|
|
146
|
+
// timerRef.current.scrollTimer = setTimeout(() => {
|
|
147
|
+
// virtuosoRef.current.scrollToIndex({
|
|
148
|
+
// index: "LAST", // 或者使用 dataSource.length - 1
|
|
149
|
+
// behavior: "auto", // 可以是 "smooth" 实现平滑滚动
|
|
150
|
+
// align: "end",
|
|
151
|
+
// });
|
|
152
|
+
// }, 500);
|
|
127
153
|
}, [
|
|
128
154
|
dataSource
|
|
129
155
|
]);
|
|
@@ -173,8 +199,20 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
173
199
|
]);
|
|
174
200
|
const itemContent = (index, item)=>{
|
|
175
201
|
const timeNode = renderTime(item);
|
|
202
|
+
let cahceKey = item.id + "-" + item.content;
|
|
203
|
+
let contentNode = null;
|
|
204
|
+
// if (htmlRenderCache.has(cahceKey)) {
|
|
205
|
+
// contentNode = htmlRenderCache.get(cahceKey);
|
|
206
|
+
// } else {
|
|
207
|
+
// const html = markToHtml(item.content, item.id);
|
|
208
|
+
// contentNode = <div dangerouslySetInnerHTML={{ __html: html }}></div>;
|
|
209
|
+
// if (coverRenderText) {
|
|
210
|
+
// contentNode = coverRenderText(item, html);
|
|
211
|
+
// }
|
|
212
|
+
// htmlRenderCache.set(cahceKey, contentNode);
|
|
213
|
+
// }
|
|
176
214
|
const html = markToHtml(item.content, item.id);
|
|
177
|
-
|
|
215
|
+
contentNode = /*#__PURE__*/ _jsx("div", {
|
|
178
216
|
dangerouslySetInnerHTML: {
|
|
179
217
|
__html: html
|
|
180
218
|
}
|
|
@@ -286,11 +324,51 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
286
324
|
apiRef: apiRef,
|
|
287
325
|
item: item
|
|
288
326
|
});
|
|
327
|
+
let UpVoteNode = /*#__PURE__*/ _jsx(UpVoteBtn, {
|
|
328
|
+
prefix: prefix,
|
|
329
|
+
isActive: item.vote === "up",
|
|
330
|
+
clickFn: ()=>{
|
|
331
|
+
setDataSource((data)=>{
|
|
332
|
+
return data.map((ite)=>{
|
|
333
|
+
if (item.id === ite.id) {
|
|
334
|
+
ite.vote = item.vote === "up" ? "" : "up";
|
|
335
|
+
}
|
|
336
|
+
return ite;
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
onVoteChange(item.vote === "up" ? "" : "up", item);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
let DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
|
|
343
|
+
prefix: prefix,
|
|
344
|
+
isActive: item.vote === "down",
|
|
345
|
+
clickFn: ()=>{
|
|
346
|
+
setDataSource((data)=>{
|
|
347
|
+
return data.map((ite)=>{
|
|
348
|
+
if (item.id === ite.id) {
|
|
349
|
+
ite.vote = ite.vote === "down" ? "" : "down";
|
|
350
|
+
}
|
|
351
|
+
return ite;
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
onVoteChange(item.vote === "down" ? "" : "down", item);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
let RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
|
|
358
|
+
prefix: prefix,
|
|
359
|
+
clickFn: ()=>onRefresh(item)
|
|
360
|
+
});
|
|
361
|
+
if (item.location === "right") {
|
|
362
|
+
UpVoteNode = null;
|
|
363
|
+
DownVoteNode = null;
|
|
364
|
+
}
|
|
289
365
|
let leftNodes = null;
|
|
290
366
|
let rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
291
367
|
children: [
|
|
292
368
|
copyNode,
|
|
293
|
-
referencesNode
|
|
369
|
+
referencesNode,
|
|
370
|
+
UpVoteNode,
|
|
371
|
+
DownVoteNode
|
|
294
372
|
]
|
|
295
373
|
});
|
|
296
374
|
if (msgAction instanceof Array) {
|
|
@@ -302,12 +380,21 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
302
380
|
if (!msgAction.includes("references")) {
|
|
303
381
|
referencesNode = null;
|
|
304
382
|
}
|
|
383
|
+
if (!msgAction.includes("upVite")) {
|
|
384
|
+
UpVoteNode = null;
|
|
385
|
+
}
|
|
386
|
+
if (!msgAction.includes("downVote")) {
|
|
387
|
+
DownVoteNode = null;
|
|
388
|
+
}
|
|
389
|
+
if (!msgAction.includes("refresh")) {
|
|
390
|
+
RefreshNode = null;
|
|
391
|
+
}
|
|
305
392
|
} else if (typeof msgAction === "object") {
|
|
306
393
|
if (msgAction.renderLeft) {
|
|
307
|
-
leftNodes = msgAction.renderLeft(copyNode, referencesNode);
|
|
394
|
+
leftNodes = msgAction.renderLeft(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
308
395
|
}
|
|
309
396
|
if (msgAction.renderRight) {
|
|
310
|
-
rightNodes = msgAction.renderRight(copyNode, referencesNode);
|
|
397
|
+
rightNodes = msgAction.renderRight(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
311
398
|
}
|
|
312
399
|
}
|
|
313
400
|
let index = recordRef.current.dataSource.findIndex((ite)=>ite.id == item.id);
|
|
@@ -321,9 +408,12 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
321
408
|
className: `${getCls("msgItem-action-left")}`,
|
|
322
409
|
children: leftNodes
|
|
323
410
|
}),
|
|
324
|
-
/*#__PURE__*/
|
|
411
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
325
412
|
className: `${getCls("msgItem-action-right")}`,
|
|
326
|
-
children:
|
|
413
|
+
children: [
|
|
414
|
+
RefreshNode,
|
|
415
|
+
rightNodes
|
|
416
|
+
]
|
|
327
417
|
})
|
|
328
418
|
]
|
|
329
419
|
});
|
|
@@ -274,7 +274,10 @@
|
|
|
274
274
|
display: flex;
|
|
275
275
|
align-items: center;
|
|
276
276
|
justify-content: space-between;
|
|
277
|
-
.msgItem-action-
|
|
277
|
+
.msgItem-action-left {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
gap: 8px;
|
|
278
281
|
}
|
|
279
282
|
.msgItem-action-right {
|
|
280
283
|
display: flex;
|
|
@@ -294,8 +297,14 @@
|
|
|
294
297
|
line-height: 1;
|
|
295
298
|
z-index: 9;
|
|
296
299
|
padding: 4px 8px;
|
|
300
|
+
.msgItem-action-left {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: 8px;
|
|
304
|
+
}
|
|
297
305
|
.msgItem-action-right {
|
|
298
306
|
display: flex;
|
|
307
|
+
align-items: center;
|
|
299
308
|
gap: 8px;
|
|
300
309
|
}
|
|
301
310
|
&.msgItem-action-popover-floatTop {
|
|
@@ -26,11 +26,17 @@ export interface headerConfigProps {
|
|
|
26
26
|
export interface msgActionProps {
|
|
27
27
|
renderLeft?: (
|
|
28
28
|
copyNode: React.ReactNode,
|
|
29
|
-
referencesNode: React.ReactNode
|
|
29
|
+
referencesNode: React.ReactNode,
|
|
30
|
+
upVoteNode: React.ReactNode,
|
|
31
|
+
downVoteNode: React.ReactNode,
|
|
32
|
+
refreshNode:React.ReactNode,
|
|
30
33
|
) => React.ReactNode;
|
|
31
34
|
renderRight?: (
|
|
32
35
|
copyNode: React.ReactNode,
|
|
33
|
-
referencesNode: React.ReactNode
|
|
36
|
+
referencesNode: React.ReactNode,
|
|
37
|
+
upVoteNode: React.ReactNode,
|
|
38
|
+
downVoteNode: React.ReactNode,
|
|
39
|
+
refreshNode:React.ReactNode,
|
|
34
40
|
) => React.ReactNode;
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -54,6 +60,8 @@ export interface contentConfigProps {
|
|
|
54
60
|
referenceNode: React.ReactNode
|
|
55
61
|
) => React.ReactNode; //覆盖引用内容
|
|
56
62
|
onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
|
|
63
|
+
onVoteChange?: (type:string,item: dataItemType) => void; // 点赞 或踩
|
|
64
|
+
onRefresh?: (item:dataItemType) => void;// 刷新
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
// content props
|
|
@@ -76,20 +84,26 @@ export interface footerConfigProps {
|
|
|
76
84
|
) => React.ReactNode; // 自定义渲染操作栏
|
|
77
85
|
fileUpload?: boolean | fileUploadProps; // 默认为false
|
|
78
86
|
sendMsgAjaxParams: sendMsgAjaxParams;
|
|
87
|
+
onClickStop?: () => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface onOpenProps {
|
|
91
|
+
retryFetch: () => void; // 重试
|
|
92
|
+
stopMessage: () => void;
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
export interface sendMsgAjaxParams {
|
|
82
96
|
url: string;
|
|
83
97
|
method?: string;
|
|
84
|
-
headers?: object;
|
|
98
|
+
headers?: () => object;
|
|
85
99
|
params: (
|
|
86
100
|
value: string,
|
|
87
101
|
refereces: referenceType,
|
|
88
102
|
fileList: fileCustomProps[],
|
|
89
|
-
beforeInfo:any
|
|
103
|
+
beforeInfo: any
|
|
90
104
|
) => string;
|
|
91
|
-
onOpen?: (res: Response) => void;
|
|
92
|
-
onMessage?: (ev: EventSourceMessage) => { id: string; content: string };
|
|
105
|
+
onOpen?: (res: Response, onOpenProps: onOpenProps) => void;
|
|
106
|
+
onMessage?: (ev: EventSourceMessage,closeCallback:()=>void) => { id: string; content: string };
|
|
93
107
|
onClose?: () => void;
|
|
94
108
|
onError?: (err: any) => void;
|
|
95
109
|
coverProps?: object;
|
|
@@ -107,16 +121,17 @@ export interface fileUploadProps {
|
|
|
107
121
|
maxCount?: number; // 上传文件数量限制 -1为不限制 默认为10
|
|
108
122
|
maxSize?: number; // 默认为50Mb 目前不考虑切片上传 业务上不要设置太大
|
|
109
123
|
multiple?: boolean; // 是否允许多选
|
|
110
|
-
customRequest: (
|
|
111
|
-
file: File
|
|
112
|
-
) => Promise<{
|
|
124
|
+
customRequest: (file: File) => Promise<{
|
|
113
125
|
url: string;
|
|
114
126
|
fileId: string;
|
|
115
127
|
source: File;
|
|
116
128
|
status: fileStatus;
|
|
117
129
|
}>; // 自定义上传方法
|
|
118
130
|
mapUploadCount?: number; // 并发上传的数量 默认为1
|
|
119
|
-
deleteFileAjax?: (
|
|
131
|
+
deleteFileAjax?: (
|
|
132
|
+
fileId: string,
|
|
133
|
+
file: fileCustomProps
|
|
134
|
+
) => Promise<{ fileId: string }>; // 删除文件的ajax 返回删除文件的fileId
|
|
120
135
|
statusText?: (status: fileStatus) => React.ReactNode; // 自定义状态显示
|
|
121
136
|
parseFileAjax?: (fileId: string) => { status: fileStatus; fileId; string }; //文件解析的 ajax 请求 如不存在解析过程,可在此函数内直接返回上传成功的状态
|
|
122
137
|
iconFileRender?: (suffix: string) => React.ReactNode; // 文件上传的 icon。参数 文件对象file 返回值为图标
|
|
@@ -161,6 +176,17 @@ export interface uploadFileBtnProps {
|
|
|
161
176
|
customRequest: (options: any) => void;
|
|
162
177
|
}
|
|
163
178
|
|
|
179
|
+
export interface VoteBtnProps {
|
|
180
|
+
prefix: string;
|
|
181
|
+
clickFn: () => void;
|
|
182
|
+
isActive: boolean;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface refreshBtnProps{
|
|
186
|
+
prefix:string;
|
|
187
|
+
clickFn:()=>void;
|
|
188
|
+
}
|
|
189
|
+
|
|
164
190
|
// fileList Props
|
|
165
191
|
|
|
166
192
|
export interface fileListProps {
|
|
@@ -190,7 +216,8 @@ export interface FileListRefProps {
|
|
|
190
216
|
updateFile: (fileId: string, status: fileStatus) => void;
|
|
191
217
|
getFileList: () => fileCustomProps[];
|
|
192
218
|
vaildFile: (file: File, fileId?: string) => boolean; // 校验文件是否合规
|
|
193
|
-
fileToCustomFile: (file: File) => fileCustomProps;
|
|
219
|
+
fileToCustomFile: (file: File, params: any) => fileCustomProps;
|
|
220
|
+
clearFileList: () => void;
|
|
194
221
|
}
|
|
195
222
|
|
|
196
223
|
// error Message
|
|
@@ -220,11 +247,13 @@ export type referenceType = referenceTypeText | referenceTypeFile;
|
|
|
220
247
|
export type referenceTypeText = {
|
|
221
248
|
type: "text";
|
|
222
249
|
value: string;
|
|
250
|
+
source:any;
|
|
223
251
|
};
|
|
224
252
|
|
|
225
253
|
export type referenceTypeFile = {
|
|
226
254
|
type: "file";
|
|
227
255
|
value: fileCustomProps;
|
|
256
|
+
source:any;
|
|
228
257
|
};
|
|
229
258
|
|
|
230
259
|
export interface VirtuosoListProps {
|
|
@@ -238,6 +267,10 @@ export interface VirtuosoListRefProps {
|
|
|
238
267
|
updateMsg: (id: string, obj: any) => void;
|
|
239
268
|
clearInputing: () => void; //清楚正在输入的inputing
|
|
240
269
|
recordMsg: (item: dataItemType) => void;
|
|
270
|
+
getDataSource: () => dataItemType[];
|
|
271
|
+
upateDataSource:(id:string,obj:dataItemType)=>void;
|
|
272
|
+
changeDataSource:(list:dataItemType[])=>void;
|
|
273
|
+
scrollToBottom: () => void;
|
|
241
274
|
}
|
|
242
275
|
|
|
243
276
|
export interface contentRefProps extends VirtuosoListRefProps {}
|
|
@@ -256,4 +289,5 @@ export interface dataItemType {
|
|
|
256
289
|
location: "left" | "right"; // 消息显示在左边还是右边
|
|
257
290
|
reference: referenceType | null; // 引用数据
|
|
258
291
|
source: any; //原消息对象
|
|
292
|
+
vote?:string;// "up":点赞。"down":踩
|
|
259
293
|
}
|
|
@@ -462,7 +462,13 @@ const HistoryFun = (props)=>{
|
|
|
462
462
|
return /*#__PURE__*/ _jsxs("div", {
|
|
463
463
|
className: styles.list,
|
|
464
464
|
onClick: ()=>{
|
|
465
|
-
calculationData(item.roomId, list.id, list.receiver);
|
|
465
|
+
calculationData(item.roomId, list.id, props.userData.mid == list.sender ? list.receiver : list.sender);
|
|
466
|
+
console.log('答应一下111111', {
|
|
467
|
+
roomId: item.roomId,
|
|
468
|
+
id: list.id,
|
|
469
|
+
sender: list.sender
|
|
470
|
+
});
|
|
471
|
+
// calculationData(item.roomId, list.id, list.sender);
|
|
466
472
|
},
|
|
467
473
|
children: [
|
|
468
474
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
|
-
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
3
3
|
import React, { useEffect, useState, useRef } from "react";
|
|
4
4
|
import styles from "./index.module.less";
|
|
5
5
|
import { copyText } from "../../../utils/dom";
|
|
6
6
|
var copyIconSvg = /*#__PURE__*/ _jsx("i", {
|
|
7
|
-
children: /*#__PURE__*/
|
|
8
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
9
8
|
width: "1em",
|
|
10
9
|
height: "1em",
|
|
11
|
-
viewBox: "0 0
|
|
10
|
+
viewBox: "0 0 14 14",
|
|
11
|
+
shapeRendering: "geometricPrecision",
|
|
12
12
|
fill: "currentColor",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ _jsx("g", {
|
|
16
|
+
clipPath: "url(#clip0_518_8403)",
|
|
17
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
18
|
+
d: "M6.16666 1.66666H13.1667C13.4761 1.66666 13.7728 1.78957 13.9916 2.00837C14.2104 2.22716 14.3333 2.5239 14.3333 2.83332V9.83332C14.3333 10.1427 14.2104 10.4395 13.9916 10.6583C13.7728 10.8771 13.4761 11 13.1667 11H6.16666C5.85724 11 5.5605 10.8771 5.34171 10.6583C5.12291 10.4395 5 10.1427 5 9.83332V2.83332C5 2.5239 5.12291 2.22716 5.34171 2.00837C5.5605 1.78957 5.85724 1.66666 6.16666 1.66666ZM6.16666 2.66666C6.12246 2.66666 6.08007 2.68422 6.04881 2.71547C6.01756 2.74673 6 2.78912 6 2.83332V9.83332C6 9.85521 6.00431 9.87688 6.01268 9.8971C6.02106 9.91732 6.03334 9.9357 6.04881 9.95117C6.06429 9.96665 6.08266 9.97893 6.10288 9.9873C6.1231 9.99568 6.14478 9.99999 6.16666 9.99999H13.1667C13.2109 9.99999 13.2533 9.98243 13.2845 9.95117C13.3158 9.91992 13.3333 9.87753 13.3333 9.83332V2.83332C13.3333 2.78912 13.3158 2.74673 13.2845 2.71547C13.2533 2.68422 13.2109 2.66666 13.1667 2.66666H6.16666ZM10 12C10 11.8674 10.0527 11.7402 10.1464 11.6464C10.2402 11.5527 10.3674 11.5 10.5 11.5C10.6326 11.5 10.7598 11.5527 10.8536 11.6464C10.9473 11.7402 11 11.8674 11 12V13.1667C11 13.4761 10.8771 13.7728 10.6583 13.9916C10.4395 14.2104 10.1427 14.3333 9.83333 14.3333H2.83333C2.52391 14.3333 2.22717 14.2104 2.00837 13.9916C1.78958 13.7728 1.66666 13.4761 1.66666 13.1667V6.16666C1.66666 5.85724 1.78958 5.56049 2.00837 5.3417C2.22717 5.12291 2.52391 4.99999 2.83333 4.99999H4C4.13261 4.99999 4.25978 5.05267 4.35355 5.14644C4.44732 5.2402 4.5 5.36738 4.5 5.49999C4.5 5.6326 4.44732 5.75978 4.35355 5.85354C4.25978 5.94731 4.13261 5.99999 4 5.99999H2.83333C2.78913 5.99999 2.74674 6.01755 2.71548 6.04881C2.68422 6.08006 2.66666 6.12245 2.66666 6.16666V13.1667C2.66666 13.2109 2.68422 13.2533 2.71548 13.2845C2.74674 13.3158 2.78913 13.3333 2.83333 13.3333H9.83333C9.87753 13.3333 9.91993 13.3158 9.95118 13.2845C9.98244 13.2533 10 13.2109 10 13.1667V12Z"
|
|
19
|
+
})
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ _jsx("defs", {
|
|
22
|
+
children: /*#__PURE__*/ _jsx("clipPath", {
|
|
23
|
+
id: "clip0_518_8403",
|
|
24
|
+
children: /*#__PURE__*/ _jsx("rect", {
|
|
25
|
+
width: "16",
|
|
26
|
+
height: "16"
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
]
|
|
16
31
|
})
|
|
17
32
|
});
|
|
18
33
|
var copySuccessSvg = /*#__PURE__*/ _jsx("i", {
|
|
19
34
|
children: /*#__PURE__*/ _jsx("svg", {
|
|
20
35
|
width: "1em",
|
|
21
36
|
height: "1em",
|
|
22
|
-
|
|
37
|
+
shapeRendering: "geometricPrecision",
|
|
23
38
|
fill: "currentColor",
|
|
24
39
|
viewBox: "0 0 12 7",
|
|
25
40
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
background-color: transparent;
|
|
9
9
|
&>i{
|
|
10
10
|
color: #f4523b;
|
|
11
|
-
font-size:
|
|
11
|
+
font-size: 16px;
|
|
12
12
|
transform:scale(0.8);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
& > i {
|
|
16
16
|
color: rgba(140, 140, 140, 1);
|
|
17
|
-
font-size:
|
|
17
|
+
font-size: 16px;
|
|
18
18
|
}
|
|
19
19
|
&:hover {
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.04);
|
|
@@ -58,12 +58,16 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
58
58
|
return recordObj.current.fileList;
|
|
59
59
|
},
|
|
60
60
|
vaildFile: vaildFile,
|
|
61
|
-
fileToCustomFile: fileToCustomFile
|
|
61
|
+
fileToCustomFile: fileToCustomFile,
|
|
62
|
+
clearFileList: clearFileList
|
|
62
63
|
};
|
|
63
64
|
});
|
|
64
65
|
var getCls = function(clsName) {
|
|
65
66
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
66
67
|
};
|
|
68
|
+
var clearFileList = function() {
|
|
69
|
+
setFileList([]);
|
|
70
|
+
};
|
|
67
71
|
var vaildFile = function(file, fileId) {
|
|
68
72
|
if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
|
|
69
73
|
errorCallback({
|
|
@@ -202,9 +206,14 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
202
206
|
};
|
|
203
207
|
// 删除文件
|
|
204
208
|
var deleteFile = function(fileId) {
|
|
209
|
+
var fileObj = null;
|
|
205
210
|
setFileList(function(fileList) {
|
|
206
211
|
return fileList.filter(function(item) {
|
|
207
|
-
|
|
212
|
+
if (item.fileId === fileId) {
|
|
213
|
+
fileObj = item;
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
208
217
|
});
|
|
209
218
|
});
|
|
210
219
|
// 删除文件时如果删除的是最后一条 则page-1
|
|
@@ -216,7 +225,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
216
225
|
if (list.length === 0 && page > 1) {
|
|
217
226
|
changePage(page - 1);
|
|
218
227
|
}
|
|
219
|
-
fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId);
|
|
228
|
+
fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId, fileObj);
|
|
220
229
|
};
|
|
221
230
|
// 更新文件状态
|
|
222
231
|
var updateFile = function(fileId, status) {
|
|
@@ -28,7 +28,7 @@ var defaultFileUploadProps = {
|
|
|
28
28
|
};
|
|
29
29
|
var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
30
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;
|
|
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;
|
|
32
32
|
if (fileUpload) {
|
|
33
33
|
fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
|
|
34
34
|
}
|
|
@@ -116,7 +116,10 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
116
116
|
prefix: prefix,
|
|
117
117
|
canSendMsg: canSendMsg,
|
|
118
118
|
sending: sending,
|
|
119
|
-
stopMessage:
|
|
119
|
+
stopMessage: function() {
|
|
120
|
+
onClickStop();
|
|
121
|
+
stopMessage();
|
|
122
|
+
},
|
|
120
123
|
clickFn: function() {
|
|
121
124
|
if (textValue.trim().length === 0) return;
|
|
122
125
|
sendMsg(textValue);
|
|
@@ -190,7 +193,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
190
193
|
sendMsgAjax();
|
|
191
194
|
};
|
|
192
195
|
var sendMsgAjax = function() {
|
|
193
|
-
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 ?
|
|
196
|
+
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() {
|
|
197
|
+
return {};
|
|
198
|
+
} : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
|
|
194
199
|
return "";
|
|
195
200
|
} : _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) {
|
|
196
201
|
return ev;
|
|
@@ -213,6 +218,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
213
218
|
var msgContent = "";
|
|
214
219
|
setSending(true);
|
|
215
220
|
setTextValue("");
|
|
221
|
+
fileListRef.current.clearFileList();
|
|
216
222
|
setReferencesSource(null);
|
|
217
223
|
var recordMsgObj = {};
|
|
218
224
|
var arg = [
|
|
@@ -221,54 +227,69 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
221
227
|
fileListRef.current ? fileListRef.current.getFileList() : []
|
|
222
228
|
];
|
|
223
229
|
beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}, headers),
|
|
230
|
-
body: params.apply(void 0, _to_consumable_array(arg).concat([
|
|
231
|
-
beforeInfo
|
|
232
|
-
])),
|
|
233
|
-
openWhenHidden: true,
|
|
234
|
-
signal: ctrl.current.signal,
|
|
235
|
-
onopen: function(res) {
|
|
236
|
-
onOpen(res);
|
|
237
|
-
if (res.status === 200) {}
|
|
238
|
-
return null;
|
|
239
|
-
},
|
|
240
|
-
onmessage: function(ev) {
|
|
241
|
-
var data = onMessage(ev);
|
|
242
|
-
msgContent += data.content;
|
|
243
|
-
delete data.content;
|
|
244
|
-
recordMsgObj = _object_spread({
|
|
245
|
-
createTime: createTime,
|
|
246
|
-
content: msgContent,
|
|
247
|
-
location: "left",
|
|
248
|
-
reference: null,
|
|
249
|
-
source: null
|
|
250
|
-
}, data);
|
|
251
|
-
updateMsgRef.current = setTimeout(function() {
|
|
252
|
-
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
253
|
-
msgId = data.id;
|
|
254
|
-
}, 100);
|
|
255
|
-
},
|
|
256
|
-
onclose: function() {
|
|
230
|
+
var callback = function() {
|
|
231
|
+
var isClose = false;
|
|
232
|
+
var closeCallback = function() {
|
|
233
|
+
if (isClose) return;
|
|
234
|
+
isClose = true;
|
|
257
235
|
onClose();
|
|
258
236
|
setSending(false);
|
|
259
237
|
if (recordMsgObj.id) {
|
|
260
238
|
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
261
239
|
}
|
|
262
240
|
console.log("onclose: ", recordMsgObj);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
241
|
+
};
|
|
242
|
+
fetchEventSource(url, _object_spread({
|
|
243
|
+
method: method,
|
|
244
|
+
headers: _object_spread({
|
|
245
|
+
"Content-Type": "application/json",
|
|
246
|
+
Accept: "text/event-stream,application/json"
|
|
247
|
+
}, headers()),
|
|
248
|
+
body: params.apply(void 0, _to_consumable_array(arg).concat([
|
|
249
|
+
beforeInfo
|
|
250
|
+
])),
|
|
251
|
+
openWhenHidden: true,
|
|
252
|
+
signal: ctrl.current.signal,
|
|
253
|
+
onopen: function(res) {
|
|
254
|
+
var retryFetch = function() {
|
|
255
|
+
callback();
|
|
256
|
+
};
|
|
257
|
+
onOpen(res, {
|
|
258
|
+
retryFetch: retryFetch,
|
|
259
|
+
stopMessage: stopMessage
|
|
260
|
+
});
|
|
261
|
+
return null;
|
|
262
|
+
},
|
|
263
|
+
onmessage: function(ev) {
|
|
264
|
+
var data = onMessage(ev, closeCallback);
|
|
265
|
+
msgContent += data.content;
|
|
266
|
+
delete data.content;
|
|
267
|
+
recordMsgObj = _object_spread({
|
|
268
|
+
createTime: createTime,
|
|
269
|
+
content: msgContent,
|
|
270
|
+
location: "left",
|
|
271
|
+
reference: null,
|
|
272
|
+
source: null
|
|
273
|
+
}, data);
|
|
274
|
+
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
275
|
+
msgId = data.id;
|
|
276
|
+
updateMsgRef.current = setTimeout(function() {
|
|
277
|
+
apiRef.contentApi.scrollToBottom();
|
|
278
|
+
}, 100);
|
|
279
|
+
},
|
|
280
|
+
onclose: function() {
|
|
281
|
+
closeCallback();
|
|
282
|
+
},
|
|
283
|
+
onerror: function(err) {
|
|
284
|
+
onError(err);
|
|
285
|
+
if (recordMsgObj.id) {
|
|
286
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
287
|
+
}
|
|
288
|
+
console.log("onerror: ", err);
|
|
268
289
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
290
|
+
}, coverProps));
|
|
291
|
+
};
|
|
292
|
+
callback();
|
|
272
293
|
}).catch(function() {
|
|
273
294
|
stopMessage();
|
|
274
295
|
});
|