bhd-components 0.10.5 → 0.10.6
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 +127 -87
- package/dist/index.esm.es5.development.js +453 -249
- 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 +2 -2
- package/dist/vendor.esm.es5.production.js +2 -2
- package/es2017/AIMessageList/components/copyIcon/index.js +22 -7
- package/es2017/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/es2017/AIMessageList/components/fileList/index.js +11 -2
- package/es2017/AIMessageList/components/footer/index.js +59 -48
- 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 +91 -13
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/es2017/AIMessageList/type.d.ts +42 -10
- package/esm/AIMessageList/components/copyIcon/index.js +22 -7
- package/esm/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/esm/AIMessageList/components/fileList/index.js +7 -2
- package/esm/AIMessageList/components/footer/index.js +63 -50
- 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 +93 -13
- package/esm/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/esm/AIMessageList/type.d.ts +42 -10
- package/package.json +1 -1
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
2
|
import React, { useEffect, useState, useRef } from "react";
|
|
3
3
|
import styles from "./index.module.less";
|
|
4
4
|
import { copyText } from "../../../utils/dom";
|
|
5
5
|
const copyIconSvg = /*#__PURE__*/ _jsx("i", {
|
|
6
|
-
children: /*#__PURE__*/
|
|
7
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
8
7
|
width: "1em",
|
|
9
8
|
height: "1em",
|
|
10
|
-
viewBox: "0 0
|
|
9
|
+
viewBox: "0 0 14 14",
|
|
10
|
+
"shape-rendering": "geometricPrecision",
|
|
11
11
|
fill: "currentColor",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ _jsx("g", {
|
|
15
|
+
"clip-path": "url(#clip0_518_8403)",
|
|
16
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
17
|
+
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"
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ _jsx("defs", {
|
|
21
|
+
children: /*#__PURE__*/ _jsx("clipPath", {
|
|
22
|
+
id: "clip0_518_8403",
|
|
23
|
+
children: /*#__PURE__*/ _jsx("rect", {
|
|
24
|
+
width: "16",
|
|
25
|
+
height: "16"
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
]
|
|
15
30
|
})
|
|
16
31
|
});
|
|
17
32
|
const copySuccessSvg = /*#__PURE__*/ _jsx("i", {
|
|
@@ -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);
|
|
@@ -192,7 +192,16 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
192
192
|
};
|
|
193
193
|
// 删除文件
|
|
194
194
|
const deleteFile = (fileId)=>{
|
|
195
|
-
|
|
195
|
+
let fileObj = null;
|
|
196
|
+
setFileList((fileList)=>{
|
|
197
|
+
return fileList.filter((item)=>{
|
|
198
|
+
if (item.fileId === fileId) {
|
|
199
|
+
fileObj = item;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
});
|
|
204
|
+
});
|
|
196
205
|
// 删除文件时如果删除的是最后一条 则page-1
|
|
197
206
|
const { fileList, page, pageSize } = recordObj.current;
|
|
198
207
|
let list = fileList.slice((page - 1) * pageSize, page * pageSize);
|
|
@@ -200,7 +209,7 @@ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
200
209
|
if (list.length === 0 && page > 1) {
|
|
201
210
|
changePage(page - 1);
|
|
202
211
|
}
|
|
203
|
-
fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId);
|
|
212
|
+
fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId, fileObj);
|
|
204
213
|
};
|
|
205
214
|
// 更新文件状态
|
|
206
215
|
const updateFile = (fileId, status)=>{
|
|
@@ -26,7 +26,7 @@ const defaultFileUploadProps = {
|
|
|
26
26
|
};
|
|
27
27
|
const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
28
28
|
let { footerConfig, prefix, errorCallback, apiRef } = props;
|
|
29
|
-
let { placeholder = defaultProps.placeholder, className = defaultProps.className, maxLength = defaultProps.maxLength, renderAction, fileUpload, sendMsgAjaxParams } = footerConfig;
|
|
29
|
+
let { placeholder = defaultProps.placeholder, className = defaultProps.className, maxLength = defaultProps.maxLength, renderAction, fileUpload, sendMsgAjaxParams, onClickStop = ()=>{} } = footerConfig;
|
|
30
30
|
if (fileUpload) {
|
|
31
31
|
fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
|
|
32
32
|
}
|
|
@@ -114,7 +114,10 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
114
114
|
prefix: prefix,
|
|
115
115
|
canSendMsg: canSendMsg,
|
|
116
116
|
sending: sending,
|
|
117
|
-
stopMessage:
|
|
117
|
+
stopMessage: ()=>{
|
|
118
|
+
onClickStop();
|
|
119
|
+
stopMessage();
|
|
120
|
+
},
|
|
118
121
|
clickFn: ()=>{
|
|
119
122
|
if (textValue.trim().length === 0) return;
|
|
120
123
|
sendMsg(textValue);
|
|
@@ -188,7 +191,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
188
191
|
sendMsgAjax();
|
|
189
192
|
};
|
|
190
193
|
const sendMsgAjax = ()=>{
|
|
191
|
-
const { url, method = "POST", headers = {}, params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {}, beforeSendMsg = ()=>Promise.resolve() } = sendMsgAjaxParams;
|
|
194
|
+
const { url, method = "POST", headers = ()=>({}), params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {}, beforeSendMsg = ()=>Promise.resolve() } = sendMsgAjaxParams;
|
|
192
195
|
ctrl.current = new AbortController();
|
|
193
196
|
// apiRef
|
|
194
197
|
console.log("apiRef", apiRef);
|
|
@@ -213,52 +216,60 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
213
216
|
fileListRef.current ? fileListRef.current.getFileList() : []
|
|
214
217
|
];
|
|
215
218
|
beforeSendMsg(...arg).then((beforeInfo)=>{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
219
|
+
const callback = ()=>{
|
|
220
|
+
fetchEventSource(url, _object_spread({
|
|
221
|
+
method,
|
|
222
|
+
headers: _object_spread({
|
|
223
|
+
"Content-Type": "application/json",
|
|
224
|
+
"Accept": "text/event-stream,application/json"
|
|
225
|
+
}, headers()),
|
|
226
|
+
body: params(...arg, beforeInfo),
|
|
227
|
+
openWhenHidden: true,
|
|
228
|
+
signal: ctrl.current.signal,
|
|
229
|
+
onopen: (res)=>{
|
|
230
|
+
const retryFetch = ()=>{
|
|
231
|
+
callback();
|
|
232
|
+
};
|
|
233
|
+
onOpen(res, {
|
|
234
|
+
retryFetch,
|
|
235
|
+
stopMessage
|
|
236
|
+
});
|
|
237
|
+
return null;
|
|
238
|
+
},
|
|
239
|
+
onmessage: (ev)=>{
|
|
240
|
+
let data = onMessage(ev);
|
|
241
|
+
msgContent += data.content;
|
|
242
|
+
delete data.content;
|
|
243
|
+
recordMsgObj = _object_spread({
|
|
244
|
+
createTime: createTime,
|
|
245
|
+
content: msgContent,
|
|
246
|
+
location: "left",
|
|
247
|
+
reference: null,
|
|
248
|
+
source: null
|
|
249
|
+
}, data);
|
|
250
|
+
updateMsgRef.current = setTimeout(()=>{
|
|
251
|
+
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
252
|
+
msgId = data.id;
|
|
253
|
+
}, 100);
|
|
254
|
+
},
|
|
255
|
+
onclose: ()=>{
|
|
256
|
+
onClose();
|
|
257
|
+
setSending(false);
|
|
258
|
+
if (recordMsgObj.id) {
|
|
259
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
260
|
+
}
|
|
261
|
+
console.log("onclose: ", recordMsgObj);
|
|
262
|
+
},
|
|
263
|
+
onerror: (err)=>{
|
|
264
|
+
onError(err);
|
|
265
|
+
if (recordMsgObj.id) {
|
|
266
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
267
|
+
}
|
|
268
|
+
console.log("onerror: ", err);
|
|
251
269
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
onError(err);
|
|
256
|
-
if (recordMsgObj.id) {
|
|
257
|
-
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
258
|
-
}
|
|
259
|
-
console.log("onerror: ", err);
|
|
260
|
-
}
|
|
261
|
-
}, coverProps));
|
|
270
|
+
}, coverProps));
|
|
271
|
+
};
|
|
272
|
+
callback();
|
|
262
273
|
}).catch(()=>{
|
|
263
274
|
stopMessage();
|
|
264
275
|
});
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import styles from "./index.module.less";
|
|
4
4
|
const referencesIcon = /*#__PURE__*/ _jsx("i", {
|
|
5
|
-
children: /*#__PURE__*/
|
|
6
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
7
6
|
width: "1em",
|
|
8
7
|
height: "1em",
|
|
9
|
-
|
|
8
|
+
"shape-rendering": "geometricPrecision",
|
|
10
9
|
fill: "currentColor",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
]
|
|
14
24
|
})
|
|
15
25
|
});
|
|
16
26
|
const ReferencesIcon = (props)=>{
|
|
@@ -24,7 +34,8 @@ const ReferencesIcon = (props)=>{
|
|
|
24
34
|
console.log("itemitem", item);
|
|
25
35
|
apiRef.footerApi.setReferences({
|
|
26
36
|
type: "text",
|
|
27
|
-
value: item.content
|
|
37
|
+
value: item.content,
|
|
38
|
+
source: item
|
|
28
39
|
});
|
|
29
40
|
}
|
|
30
41
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styles from "./index.module.less";
|
|
4
|
+
const refreshSvg = /*#__PURE__*/ _jsx("svg", {
|
|
5
|
+
viewBox: "0 0 14 14",
|
|
6
|
+
version: "1.1",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
"p-id": "8340",
|
|
9
|
+
width: "1em",
|
|
10
|
+
height: "1em",
|
|
11
|
+
fill: "currentColor",
|
|
12
|
+
"shape-rendering": "geometricPrecision",
|
|
13
|
+
"aria-hidden": "true",
|
|
14
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
15
|
+
d: "M8 3.80001C7.27938 3.80001 6.60141 3.97512 6.00464 4.2846C5.71048 4.43715 5.34834 4.32235 5.19579 4.02818C5.04324 3.73401 5.15804 3.37187 5.4522 3.21932C6.21563 2.82342 7.0826 2.60001 8 2.60001C11.0603 2.60001 13.5412 5.08088 13.5412 8.14118C13.5412 8.40936 13.5221 8.67343 13.4851 8.93202C13.4737 9.01141 13.4607 9.09026 13.446 9.16853L13.7175 9.02364C14.0098 8.86759 14.3733 8.97808 14.5293 9.27041C14.6854 9.56274 14.5749 9.92622 14.2825 10.0823L12.6718 10.9421C12.3819 11.0968 12.0215 10.9896 11.8633 10.7016L11.0035 9.13588C10.844 8.84542 10.9501 8.48065 11.2406 8.32115C11.5311 8.16164 11.8958 8.2678 12.0553 8.55825L12.2672 8.94405C12.2784 8.88383 12.2885 8.82318 12.2972 8.76211C12.3261 8.55962 12.3412 8.35233 12.3412 8.14118C12.3412 5.74362 10.3976 3.80001 8 3.80001ZM3.32824 5.34029C3.61811 5.18556 3.97853 5.29278 4.13669 5.58079L4.99651 7.14649C5.15601 7.43694 5.04986 7.80171 4.7594 7.96122C4.46895 8.12072 4.10418 8.01457 3.94467 7.72411L3.73281 7.33832C3.72156 7.39853 3.71155 7.45919 3.70282 7.52026C3.67386 7.72275 3.65883 7.93003 3.65883 8.14118C3.65883 10.5387 5.60244 12.4824 8 12.4824C8.72063 12.4824 9.39859 12.3072 9.99536 11.9978C10.2895 11.8452 10.6517 11.96 10.8042 12.2542C10.9568 12.5484 10.842 12.9105 10.5478 13.063C9.78437 13.4589 8.9174 13.6824 8 13.6824C4.93969 13.6824 2.45883 11.2015 2.45883 8.14118C2.45883 7.87301 2.47792 7.60894 2.51491 7.35034C2.52627 7.27095 2.5393 7.19211 2.55399 7.11384L2.28254 7.25873C1.99021 7.41477 1.62673 7.30429 1.47069 7.01196C1.31465 6.71963 1.42513 6.35615 1.71746 6.20011L3.32824 5.34029Z"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
const RefreshBtn = (props)=>{
|
|
19
|
+
const { prefix, clickFn } = props;
|
|
20
|
+
const getCls = (clsName)=>{
|
|
21
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/ _jsx("i", {
|
|
24
|
+
className: `${getCls("refreshBtn")}`,
|
|
25
|
+
onClick: ()=>clickFn(),
|
|
26
|
+
children: refreshSvg
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export default RefreshBtn;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styles from "./index.module.less";
|
|
4
|
+
const upvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
|
|
5
|
+
width: "1em",
|
|
6
|
+
height: "1em",
|
|
7
|
+
viewBox: "0 0 16 16",
|
|
8
|
+
"shape-rendering": "geometricPrecision",
|
|
9
|
+
fill: "currentColor",
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
12
|
+
d: "M14.9948 7.82355C14.999 7.88679 14.9948 7.95002 14.978 8.01326L13.7172 13.4046C13.7003 13.4699 13.6709 13.527 13.633 13.58C13.4983 13.8411 13.292 14.0716 13.0205 14.2409C12.7321 14.4184 12.4122 14.5 12.0944 14.5V14.4959L4.00144 14.4918C3.97408 14.4959 3.94461 14.498 3.91514 14.498C3.88568 14.498 3.85621 14.4959 3.82885 14.4918H1.67564C1.64617 14.4959 1.6146 14.5 1.58303 14.5C1.26099 14.5 1 14.2471 1 13.935L1.00631 7.1504C1.00631 6.8383 1.26731 6.58536 1.58934 6.58536C1.6125 6.58536 1.63775 6.5874 1.66091 6.58944L3.59522 6.58536V6.57516C5.37587 6.45073 6.78609 5.03711 6.8366 3.29303C6.83239 3.24408 6.82818 3.19512 6.82818 3.14412C6.82818 2.23639 7.58802 1.5 8.52465 1.5C9.32868 1.5 10.0022 2.04464 10.1769 2.77287L10.1853 2.77083C10.2801 3.18696 10.3327 3.61941 10.3327 4.06206C10.3327 4.74745 10.2127 5.40428 9.99169 6.0142L13.2457 6.01828C13.2752 6.01828 13.3046 6.02032 13.3341 6.02644C13.8898 6.04684 14.4244 6.32426 14.7401 6.8179C14.9422 7.13204 15.0222 7.4829 14.9948 7.82355ZM2.16816 13.3618H3.33422L3.33843 7.71544L2.17448 7.71748L2.16816 13.3618ZM13.7572 7.40946C13.6456 7.23403 13.4478 7.14224 13.2478 7.15244V7.1504H13.2457L9.13294 7.14632C8.8109 7.14632 8.54991 6.89338 8.54991 6.58128C8.54991 6.49153 8.57306 6.40585 8.61095 6.33038L8.60463 6.3263C8.83827 5.90609 9.00665 5.44712 9.10347 4.96367H9.10979C9.10979 4.96367 9.18766 4.6577 9.18556 4.0743C9.18556 3.61125 9.09716 3.18696 9.09716 3.18696H9.09295C9.09295 3.1788 9.09505 3.17064 9.09505 3.16248C9.09505 2.87078 8.85089 2.63416 8.54991 2.63416C8.24892 2.63416 8.00477 2.87078 8.00477 3.16248C8.00477 3.17472 8.00687 3.18696 8.00687 3.1992H7.99845C7.99845 3.1992 8.00687 3.63981 7.91636 4.09878C7.87848 4.29256 7.82375 4.47411 7.77324 4.6169C7.77324 4.6169 7.77113 4.6169 7.77113 4.61486C7.28072 6.06928 6.0473 7.19528 4.50449 7.57673L4.49817 13.3638L12.0965 13.3658C12.1217 13.3658 12.147 13.3679 12.1723 13.372C12.248 13.3618 12.3238 13.3373 12.3912 13.2944C12.488 13.2353 12.5595 13.1496 12.6016 13.0517H12.6037L13.8161 7.86231L13.8119 7.86027C13.8624 7.71544 13.8477 7.55021 13.7572 7.40946Z"
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const downvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
|
|
16
|
+
width: "1em",
|
|
17
|
+
height: "1em",
|
|
18
|
+
"shape-rendering": "geometricPrecision",
|
|
19
|
+
fill: "currentColor",
|
|
20
|
+
viewBox: "0 0 16 16",
|
|
21
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
23
|
+
d: "M1.0052 8.17645C1.00099 8.11321 1.0052 8.04998 1.02204 7.98674L2.28281 2.5954C2.29965 2.53013 2.32912 2.47301 2.36701 2.41998C2.50171 2.15887 2.70798 1.92837 2.9795 1.75906C3.26786 1.58159 3.58779 1.5 3.90561 1.5V1.50408L11.9986 1.50816C12.0259 1.50408 12.0554 1.50204 12.0849 1.50204C12.1143 1.50204 12.1438 1.50408 12.1712 1.50816H14.3244C14.3538 1.50408 14.3854 1.5 14.417 1.5C14.739 1.5 15 1.75294 15 2.06504L14.9937 8.8496C14.9937 9.1617 14.7327 9.41464 14.4107 9.41464C14.3875 9.41464 14.3622 9.4126 14.3391 9.41056L12.4048 9.41464V9.42484C10.6241 9.54927 9.21391 10.9629 9.1634 12.707C9.16761 12.7559 9.17182 12.8049 9.17182 12.8559C9.17182 13.7636 8.41198 14.5 7.47535 14.5C6.67132 14.5 5.99778 13.9554 5.82308 13.2271L5.81466 13.2292C5.71995 12.813 5.66733 12.3806 5.66733 11.9379C5.66733 11.2526 5.7873 10.5957 6.00831 9.9858L2.75429 9.98172C2.72482 9.98172 2.69535 9.97968 2.66589 9.97356C2.11022 9.95316 1.5756 9.67574 1.25988 9.1821C1.05782 8.86796 0.977839 8.5171 1.0052 8.17645ZM13.8318 2.63824H12.6658L12.6616 8.28456L13.8255 8.28252L13.8318 2.63824ZM2.24282 8.59054C2.35438 8.76597 2.55223 8.85776 2.75218 8.84756V8.8496H2.75429L6.86706 8.85368C7.1891 8.85368 7.45009 9.10662 7.45009 9.41872C7.45009 9.50847 7.42694 9.59415 7.38905 9.66962L7.39537 9.6737C7.16173 10.0939 6.99335 10.5529 6.89653 11.0363H6.89021C6.89021 11.0363 6.81234 11.3423 6.81444 11.9257C6.81444 12.3887 6.90284 12.813 6.90284 12.813H6.90705C6.90705 12.8212 6.90495 12.8294 6.90495 12.8375C6.90495 13.1292 7.14911 13.3658 7.45009 13.3658C7.75108 13.3658 7.99523 13.1292 7.99523 12.8375C7.99523 12.8253 7.99313 12.813 7.99313 12.8008H8.00155C8.00155 12.8008 7.99313 12.3602 8.08364 11.9012C8.12152 11.7074 8.17625 11.5259 8.22676 11.3831C8.22676 11.3831 8.22887 11.3831 8.22887 11.3851C8.71928 9.93072 9.9527 8.80472 11.4955 8.42327L11.5018 2.6362L3.90351 2.63416C3.87825 2.63416 3.85299 2.63212 3.82773 2.62804C3.75196 2.63824 3.67619 2.66272 3.60884 2.70555C3.51201 2.76471 3.44045 2.85038 3.39836 2.9483H3.39625L2.18389 8.13769L2.1881 8.13973C2.13758 8.28456 2.15232 8.44979 2.24282 8.59054Z"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
export const UpVoteBtn = (props)=>{
|
|
27
|
+
const { prefix, isActive, clickFn } = props;
|
|
28
|
+
const getCls = (clsName)=>{
|
|
29
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/ _jsx("i", {
|
|
32
|
+
onClick: ()=>{
|
|
33
|
+
clickFn();
|
|
34
|
+
},
|
|
35
|
+
className: `${getCls("upVoteBtn")} ${isActive ? getCls("active") : ""}`,
|
|
36
|
+
children: upvoteBtnSvg
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export const DownVoteBtn = (props)=>{
|
|
40
|
+
const { prefix, isActive, clickFn } = props;
|
|
41
|
+
const getCls = (clsName)=>{
|
|
42
|
+
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/ _jsx("i", {
|
|
45
|
+
onClick: ()=>{
|
|
46
|
+
clickFn();
|
|
47
|
+
},
|
|
48
|
+
className: `${getCls("downVoteBtn")} ${isActive ? getCls("active") : ""}`,
|
|
49
|
+
children: downvoteBtnSvg
|
|
50
|
+
});
|
|
51
|
+
};
|
|
@@ -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,22 @@ 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);
|
|
99
118
|
}
|
|
100
119
|
};
|
|
101
120
|
});
|
|
@@ -173,14 +192,21 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
173
192
|
]);
|
|
174
193
|
const itemContent = (index, item)=>{
|
|
175
194
|
const timeNode = renderTime(item);
|
|
176
|
-
|
|
177
|
-
let contentNode =
|
|
178
|
-
|
|
179
|
-
|
|
195
|
+
let cahceKey = item.id + "-" + item.content;
|
|
196
|
+
let contentNode = null;
|
|
197
|
+
if (htmlRenderCache.has(cahceKey)) {
|
|
198
|
+
contentNode = htmlRenderCache.get(cahceKey);
|
|
199
|
+
} else {
|
|
200
|
+
const html = markToHtml(item.content, item.id);
|
|
201
|
+
contentNode = /*#__PURE__*/ _jsx("div", {
|
|
202
|
+
dangerouslySetInnerHTML: {
|
|
203
|
+
__html: html
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
if (coverRenderText) {
|
|
207
|
+
contentNode = coverRenderText(item, html);
|
|
180
208
|
}
|
|
181
|
-
|
|
182
|
-
if (coverRenderText) {
|
|
183
|
-
contentNode = coverRenderText(item, html);
|
|
209
|
+
htmlRenderCache.set(cahceKey, contentNode);
|
|
184
210
|
}
|
|
185
211
|
// 是否显示时间
|
|
186
212
|
let itemNode = /*#__PURE__*/ _jsx("div", {
|
|
@@ -286,11 +312,51 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
286
312
|
apiRef: apiRef,
|
|
287
313
|
item: item
|
|
288
314
|
});
|
|
315
|
+
let UpVoteNode = /*#__PURE__*/ _jsx(UpVoteBtn, {
|
|
316
|
+
prefix: prefix,
|
|
317
|
+
isActive: item.vote === "up",
|
|
318
|
+
clickFn: ()=>{
|
|
319
|
+
setDataSource((data)=>{
|
|
320
|
+
return data.map((ite)=>{
|
|
321
|
+
if (item.id === ite.id) {
|
|
322
|
+
ite.vote = item.vote === "up" ? "" : "up";
|
|
323
|
+
}
|
|
324
|
+
return ite;
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
onVoteChange(item.vote === "up" ? "" : "up", item);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
let DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
|
|
331
|
+
prefix: prefix,
|
|
332
|
+
isActive: item.vote === "down",
|
|
333
|
+
clickFn: ()=>{
|
|
334
|
+
setDataSource((data)=>{
|
|
335
|
+
return data.map((ite)=>{
|
|
336
|
+
if (item.id === ite.id) {
|
|
337
|
+
ite.vote = ite.vote === "down" ? "" : "down";
|
|
338
|
+
}
|
|
339
|
+
return ite;
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
onVoteChange(item.vote === "down" ? "" : "down", item);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
let RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
|
|
346
|
+
prefix: prefix,
|
|
347
|
+
clickFn: ()=>onRefresh(item)
|
|
348
|
+
});
|
|
349
|
+
if (item.location === "right") {
|
|
350
|
+
UpVoteNode = null;
|
|
351
|
+
DownVoteNode = null;
|
|
352
|
+
}
|
|
289
353
|
let leftNodes = null;
|
|
290
354
|
let rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
291
355
|
children: [
|
|
292
356
|
copyNode,
|
|
293
|
-
referencesNode
|
|
357
|
+
referencesNode,
|
|
358
|
+
UpVoteNode,
|
|
359
|
+
DownVoteNode
|
|
294
360
|
]
|
|
295
361
|
});
|
|
296
362
|
if (msgAction instanceof Array) {
|
|
@@ -302,12 +368,21 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
302
368
|
if (!msgAction.includes("references")) {
|
|
303
369
|
referencesNode = null;
|
|
304
370
|
}
|
|
371
|
+
if (!msgAction.includes("upVite")) {
|
|
372
|
+
UpVoteNode = null;
|
|
373
|
+
}
|
|
374
|
+
if (!msgAction.includes("downVote")) {
|
|
375
|
+
DownVoteNode = null;
|
|
376
|
+
}
|
|
377
|
+
if (!msgAction.includes("refresh")) {
|
|
378
|
+
RefreshNode = null;
|
|
379
|
+
}
|
|
305
380
|
} else if (typeof msgAction === "object") {
|
|
306
381
|
if (msgAction.renderLeft) {
|
|
307
|
-
leftNodes = msgAction.renderLeft(copyNode, referencesNode);
|
|
382
|
+
leftNodes = msgAction.renderLeft(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
308
383
|
}
|
|
309
384
|
if (msgAction.renderRight) {
|
|
310
|
-
rightNodes = msgAction.renderRight(copyNode, referencesNode);
|
|
385
|
+
rightNodes = msgAction.renderRight(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
311
386
|
}
|
|
312
387
|
}
|
|
313
388
|
let index = recordRef.current.dataSource.findIndex((ite)=>ite.id == item.id);
|
|
@@ -321,9 +396,12 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
321
396
|
className: `${getCls("msgItem-action-left")}`,
|
|
322
397
|
children: leftNodes
|
|
323
398
|
}),
|
|
324
|
-
/*#__PURE__*/
|
|
399
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
325
400
|
className: `${getCls("msgItem-action-right")}`,
|
|
326
|
-
children:
|
|
401
|
+
children: [
|
|
402
|
+
RefreshNode,
|
|
403
|
+
rightNodes
|
|
404
|
+
]
|
|
327
405
|
})
|
|
328
406
|
]
|
|
329
407
|
});
|
|
@@ -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 {
|