bhd-components 0.9.29 → 0.10.1

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.
Files changed (103) hide show
  1. package/dist/index.esm.es5.development.css +662 -0
  2. package/dist/index.esm.es5.development.js +2694 -159
  3. package/dist/index.esm.es5.production.css +1 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +3940 -638
  6. package/dist/vendor.esm.es5.production.js +136 -136
  7. package/es2017/AIMessageList/components/content/index.d.ts +4 -0
  8. package/es2017/AIMessageList/components/content/index.js +29 -0
  9. package/es2017/AIMessageList/components/content/index.module.less +8 -0
  10. package/es2017/AIMessageList/components/copyIcon/index.d.ts +7 -0
  11. package/es2017/AIMessageList/components/copyIcon/index.js +58 -0
  12. package/es2017/AIMessageList/components/copyIcon/index.module.less +22 -0
  13. package/es2017/AIMessageList/components/errorCallback/index.d.ts +3 -0
  14. package/es2017/AIMessageList/components/errorCallback/index.js +6 -0
  15. package/es2017/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  16. package/es2017/AIMessageList/components/fileList/fileIcon.js +970 -0
  17. package/es2017/AIMessageList/components/fileList/index.d.ts +4 -0
  18. package/es2017/AIMessageList/components/fileList/index.js +299 -0
  19. package/es2017/AIMessageList/components/fileList/index.module.less +95 -0
  20. package/es2017/AIMessageList/components/footer/index.d.ts +10 -0
  21. package/es2017/AIMessageList/components/footer/index.js +296 -0
  22. package/es2017/AIMessageList/components/footer/index.module.less +51 -0
  23. package/es2017/AIMessageList/components/header/index.d.ts +9 -0
  24. package/es2017/AIMessageList/components/header/index.js +94 -0
  25. package/es2017/AIMessageList/components/header/index.module.less +31 -0
  26. package/es2017/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  27. package/es2017/AIMessageList/components/referencesIcon/index.js +37 -0
  28. package/es2017/AIMessageList/components/referencesIcon/index.module.less +13 -0
  29. package/es2017/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  30. package/es2017/AIMessageList/components/renderReferrnce/index.js +68 -0
  31. package/es2017/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  32. package/es2017/AIMessageList/components/sendBtn/index.d.ts +4 -0
  33. package/es2017/AIMessageList/components/sendBtn/index.js +46 -0
  34. package/es2017/AIMessageList/components/sendBtn/index.module.less +25 -0
  35. package/es2017/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  36. package/es2017/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  37. package/es2017/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  38. package/es2017/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  39. package/es2017/AIMessageList/components/virtuosoList/index.js +507 -0
  40. package/es2017/AIMessageList/components/virtuosoList/index.module.less +381 -0
  41. package/es2017/AIMessageList/index.d.ts +4 -0
  42. package/es2017/AIMessageList/index.js +58 -0
  43. package/es2017/AIMessageList/index.module.less +20 -0
  44. package/es2017/AIMessageList/type.d.ts +242 -0
  45. package/es2017/customerService/index.js +1 -0
  46. package/es2017/images/loading2.js +2 -0
  47. package/es2017/index.d.ts +1 -0
  48. package/es2017/index.js +1 -0
  49. package/es2017/utils/Date.d.ts +2 -1
  50. package/es2017/utils/Date.js +2 -1
  51. package/es2017/utils/dom.d.ts +4 -1
  52. package/es2017/utils/dom.js +44 -1
  53. package/es2017/utils/number.d.ts +1 -0
  54. package/es2017/utils/number.js +9 -0
  55. package/esm/AIMessageList/components/content/index.d.ts +4 -0
  56. package/esm/AIMessageList/components/content/index.js +29 -0
  57. package/esm/AIMessageList/components/content/index.module.less +8 -0
  58. package/esm/AIMessageList/components/copyIcon/index.d.ts +7 -0
  59. package/esm/AIMessageList/components/copyIcon/index.js +61 -0
  60. package/esm/AIMessageList/components/copyIcon/index.module.less +22 -0
  61. package/esm/AIMessageList/components/errorCallback/index.d.ts +3 -0
  62. package/esm/AIMessageList/components/errorCallback/index.js +6 -0
  63. package/esm/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  64. package/esm/AIMessageList/components/fileList/fileIcon.js +970 -0
  65. package/esm/AIMessageList/components/fileList/index.d.ts +4 -0
  66. package/esm/AIMessageList/components/fileList/index.js +325 -0
  67. package/esm/AIMessageList/components/fileList/index.module.less +95 -0
  68. package/esm/AIMessageList/components/footer/index.d.ts +10 -0
  69. package/esm/AIMessageList/components/footer/index.js +304 -0
  70. package/esm/AIMessageList/components/footer/index.module.less +51 -0
  71. package/esm/AIMessageList/components/header/index.d.ts +9 -0
  72. package/esm/AIMessageList/components/header/index.js +96 -0
  73. package/esm/AIMessageList/components/header/index.module.less +31 -0
  74. package/esm/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  75. package/esm/AIMessageList/components/referencesIcon/index.js +39 -0
  76. package/esm/AIMessageList/components/referencesIcon/index.module.less +13 -0
  77. package/esm/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  78. package/esm/AIMessageList/components/renderReferrnce/index.js +72 -0
  79. package/esm/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  80. package/esm/AIMessageList/components/sendBtn/index.d.ts +4 -0
  81. package/esm/AIMessageList/components/sendBtn/index.js +48 -0
  82. package/esm/AIMessageList/components/sendBtn/index.module.less +25 -0
  83. package/esm/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  84. package/esm/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  85. package/esm/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  86. package/esm/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  87. package/esm/AIMessageList/components/virtuosoList/index.js +484 -0
  88. package/esm/AIMessageList/components/virtuosoList/index.module.less +381 -0
  89. package/esm/AIMessageList/index.d.ts +4 -0
  90. package/esm/AIMessageList/index.js +58 -0
  91. package/esm/AIMessageList/index.module.less +20 -0
  92. package/esm/AIMessageList/type.d.ts +242 -0
  93. package/esm/customerService/index.js +1 -0
  94. package/esm/images/loading2.js +2 -0
  95. package/esm/index.d.ts +1 -0
  96. package/esm/index.js +1 -0
  97. package/esm/utils/Date.d.ts +2 -1
  98. package/esm/utils/Date.js +2 -1
  99. package/esm/utils/dom.d.ts +4 -1
  100. package/esm/utils/dom.js +45 -1
  101. package/esm/utils/number.d.ts +1 -0
  102. package/esm/utils/number.js +9 -0
  103. package/package.json +2 -1
@@ -0,0 +1,484 @@
1
+ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
6
+ import React, { useRef, useState, useCallback, useEffect, forwardRef, useImperativeHandle } from "react";
7
+ import styles from "./index.module.less";
8
+ import { copyText, findParent, delegate } from "../../../utils/dom";
9
+ import { Virtuoso } from "react-virtuoso";
10
+ import loading2Gif from "../../../images/loading2";
11
+ import { parseDate } from "../../../utils/Date";
12
+ import { Remarkable } from "remarkable";
13
+ import hljs from "highlight.js";
14
+ import "highlight.js/styles/github.css";
15
+ import CopyIcon from "../copyIcon";
16
+ import ReferencesIcon from "../referencesIcon";
17
+ var Header = function(param) {
18
+ var context = param.context;
19
+ var prefix = context.prefix, loading = context.loading;
20
+ if (!loading) return null;
21
+ var getCls = function(clsName) {
22
+ return styles[clsName] + " " + prefix + "-" + clsName;
23
+ };
24
+ return /*#__PURE__*/ _jsx("div", {
25
+ className: "".concat(getCls("loadingIcon")),
26
+ children: /*#__PURE__*/ _jsx("img", {
27
+ src: loading2Gif,
28
+ alt: ""
29
+ })
30
+ });
31
+ };
32
+ var remarkable = new Remarkable({
33
+ highlight: function highlight(str, lang) {
34
+ if (lang && hljs.getLanguage(lang)) {
35
+ try {
36
+ return hljs.highlight(lang, str).value;
37
+ } catch (err) {}
38
+ }
39
+ try {
40
+ return hljs.highlightAuto(str).value;
41
+ } catch (err) {}
42
+ return ""; // use external default escaping
43
+ }
44
+ });
45
+ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
46
+ var prefix = props.prefix, contentConfig = props.contentConfig, apiRef = props.apiRef;
47
+ var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
48
+ "copy",
49
+ "references"
50
+ ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences;
51
+ var loadMoreProps = contentConfig.loadMore || true;
52
+ var virtuosoRef = useRef(null);
53
+ var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
54
+ var _useState1 = _sliced_to_array(useState([]), 2), dataSource = _useState1[0], setDataSource = _useState1[1];
55
+ var _useState2 = _sliced_to_array(useState(0), 2), firstItemIndex = _useState2[0], setFirstItemIndex = _useState2[1];
56
+ var _useState3 = _sliced_to_array(useState(1), 2), page = _useState3[0], setPage = _useState3[1];
57
+ var _useState4 = _sliced_to_array(useState(30), 2), pageSize = _useState4[0], setPageSize = _useState4[1];
58
+ var _useState5 = _sliced_to_array(useState(0), 2), total = _useState5[0], setTotal = _useState5[1];
59
+ var timerRef = useRef({
60
+ loadMore: null,
61
+ scrollTimer: null
62
+ });
63
+ var wrapperRef = useRef(null);
64
+ var recordRef = useRef({
65
+ page: page,
66
+ pageSize: pageSize,
67
+ total: total,
68
+ dataSource: dataSource,
69
+ maxPage: Math.ceil(total / pageSize)
70
+ });
71
+ var timeRenderCache = useRef(new Map()).current;
72
+ useImperativeHandle(ref, function() {
73
+ return {
74
+ addMsg: function(msg) {
75
+ setDataSource(function(data) {
76
+ return _to_consumable_array(data).concat([
77
+ msg
78
+ ]);
79
+ });
80
+ },
81
+ updateMsg: function(id, obj) {
82
+ setDataSource(function(data) {
83
+ return data.map(function(item) {
84
+ if (item.id === id) {
85
+ return _object_spread({}, item, obj);
86
+ }
87
+ return item;
88
+ });
89
+ });
90
+ },
91
+ clearInputing: function clearInputing() {
92
+ setDataSource(function(data) {
93
+ return data.filter(function(item) {
94
+ return item.id !== "inputing";
95
+ });
96
+ });
97
+ }
98
+ };
99
+ });
100
+ useEffect(function() {
101
+ getData(page, pageSize);
102
+ var removeFn = delegate(wrapperRef.current, "click", ".".concat(styles.copyCode), function(event, target) {
103
+ findCopyContent(event);
104
+ });
105
+ return function() {
106
+ removeFn();
107
+ clearTimeout(timerRef.current.loadMore);
108
+ clearTimeout(timerRef.current.scrollTimer);
109
+ };
110
+ }, []);
111
+ useEffect(function() {
112
+ if (!virtuosoRef.current) return;
113
+ virtuosoRef.current.scrollToIndex({
114
+ index: "LAST",
115
+ behavior: "auto"
116
+ });
117
+ clearTimeout(timerRef.current.scrollTimer);
118
+ timerRef.current.scrollTimer = setTimeout(function() {
119
+ virtuosoRef.current.scrollToIndex({
120
+ index: "LAST",
121
+ behavior: "auto",
122
+ align: "end"
123
+ });
124
+ }, 500);
125
+ }, [
126
+ dataSource
127
+ ]);
128
+ useEffect(function() {
129
+ recordRef.current.page = page;
130
+ recordRef.current.pageSize = pageSize;
131
+ recordRef.current.total = total;
132
+ recordRef.current.dataSource = dataSource;
133
+ recordRef.current.maxPage = Math.ceil(total / pageSize);
134
+ }, [
135
+ page,
136
+ pageSize,
137
+ total,
138
+ dataSource
139
+ ]);
140
+ var getData = function(page, pageSize) {
141
+ setLoading(true);
142
+ clearTimeout(timerRef.current.loadMore);
143
+ timerRef.current.loadMore = setTimeout(function() {
144
+ setLoading(false);
145
+ getList(page, pageSize).then(function(listObj) {
146
+ setLoading(false);
147
+ console.log("listObjlistObj", listObj);
148
+ setDataSource(function(data) {
149
+ return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
150
+ });
151
+ setTotal(listObj.total);
152
+ setPage(page);
153
+ setPageSize(pageSize);
154
+ setFirstItemIndex(listObj.total - pageSize * (page - 1));
155
+ });
156
+ }, 500);
157
+ };
158
+ var getCls = function(clsName) {
159
+ return styles[clsName] + " " + prefix + "-" + clsName;
160
+ };
161
+ var loadMore = useCallback(function() {
162
+ if (!loadMoreProps) return;
163
+ if (recordRef.current.page >= recordRef.current.maxPage) return;
164
+ getData(page + 1, pageSize);
165
+ }, [
166
+ page,
167
+ pageSize
168
+ ]);
169
+ var itemContent = function(index, item) {
170
+ var timeNode = renderTime(item);
171
+ var html = markToHtml(item.content, item.id);
172
+ var contentNode = /*#__PURE__*/ _jsx("div", {
173
+ dangerouslySetInnerHTML: {
174
+ __html: html
175
+ }
176
+ });
177
+ if (coverRenderText) {
178
+ contentNode = coverRenderText(item, html);
179
+ }
180
+ // 是否显示时间
181
+ var itemNode = /*#__PURE__*/ _jsx("div", {
182
+ className: "".concat(getCls("msgItem"), " ").concat(item.location === "left" ? getCls("msgItem-left") : getCls("msgItem-right")),
183
+ children: /*#__PURE__*/ _jsxs("div", {
184
+ className: "".concat(getCls("msgItem-box")),
185
+ "data-id": item.id,
186
+ onMouseEnter: function() {
187
+ return onMouseEnter(item);
188
+ },
189
+ onMouseLeave: function() {
190
+ return onMouseLeave(item);
191
+ },
192
+ children: [
193
+ renderAction("floatTop", item),
194
+ /*#__PURE__*/ _jsxs("div", {
195
+ className: "".concat(getCls("msgItem-content")),
196
+ children: [
197
+ /*#__PURE__*/ _jsx("div", {
198
+ className: "".concat(getCls("msgItem-text")),
199
+ children: contentNode
200
+ }),
201
+ renderAction("bottom", item)
202
+ ]
203
+ }),
204
+ item.location === "left" && renderAction("floatBottom", item),
205
+ renderReference(item)
206
+ ]
207
+ })
208
+ });
209
+ return /*#__PURE__*/ _jsxs(_Fragment, {
210
+ children: [
211
+ timeNode,
212
+ itemNode
213
+ ]
214
+ });
215
+ };
216
+ var renderReference = function(item) {
217
+ var reference = item.reference;
218
+ if (!item.reference) return null;
219
+ var referenceNode = null;
220
+ if (reference.type === "text") {
221
+ referenceNode = /*#__PURE__*/ _jsx("div", {
222
+ className: "".concat(getCls("msgItem-references-text")),
223
+ children: /*#__PURE__*/ _jsx("div", {
224
+ children: reference.value
225
+ })
226
+ });
227
+ }
228
+ if (coverRenderReferences) {
229
+ return coverRenderReferences(item, referenceNode);
230
+ } else {
231
+ return referenceNode;
232
+ }
233
+ };
234
+ var onMouseEnter = function(item) {
235
+ var dom = document.querySelector('[data-id="'.concat(item.id, '"]'));
236
+ var container = wrapperRef.current;
237
+ if (!dom) return;
238
+ var topDom = dom.querySelector("." + styles["msgItem-action-popover-floatTop"]);
239
+ var bottomDom = dom.querySelector("." + styles["msgItem-action-popover-floatBottom"]);
240
+ if (!topDom || !bottomDom) return;
241
+ console.log("itemitem", dom, container);
242
+ var con_obj = container.getBoundingClientRect(); // 外层盒子
243
+ var dom_obj = dom.getBoundingClientRect(); // 鼠标滑过元素
244
+ var y = dom_obj.y - con_obj.y;
245
+ if (y > 0) {
246
+ // 元素tou在可视区域内
247
+ // 判断底部是否在可视区域内
248
+ if (y + dom_obj.height < con_obj.height) {
249
+ // 底部在可视区域内
250
+ // 显示在下边
251
+ bottomDom.style.cssText = "display:flex";
252
+ } else {
253
+ // 显示在上
254
+ topDom.style.cssText = "display:flex";
255
+ }
256
+ } else {
257
+ console.log("yyyy", y, dom_obj, con_obj, y + dom_obj.height < con_obj.height);
258
+ // 元素top不在可视区域内
259
+ if (y + dom_obj.height < con_obj.height) {
260
+ // 底部在可视区域内
261
+ // 显示在下边
262
+ bottomDom.style.cssText = "display:flex";
263
+ } else {
264
+ // 头部和底部都不在可视区域内 移动 topDom到可视区域
265
+ topDom.style.cssText = "display:flex;top:".concat(-1 * y + 24, "px;bottom:auto;");
266
+ }
267
+ }
268
+ };
269
+ var onMouseLeave = function(item) {
270
+ var dom = document.querySelector('[data-id="'.concat(item.id, '"]'));
271
+ if (!dom) return;
272
+ var topDom = dom.querySelector("." + styles["msgItem-action-popover-floatTop"]);
273
+ var bottomDom = dom.querySelector("." + styles["msgItem-action-popover-floatBottom"]);
274
+ if (!topDom || !bottomDom) return;
275
+ bottomDom.style.cssText = "";
276
+ topDom.style.cssText = "";
277
+ };
278
+ var renderAction = function(location, item) {
279
+ var copyNode = /*#__PURE__*/ _jsx(CopyIcon, {
280
+ prefix: prefix,
281
+ content: item.content
282
+ });
283
+ var referencesNode = /*#__PURE__*/ _jsx(ReferencesIcon, {
284
+ prefix: prefix,
285
+ apiRef: apiRef,
286
+ item: item
287
+ });
288
+ var leftNodes = null;
289
+ var rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
290
+ children: [
291
+ copyNode,
292
+ referencesNode
293
+ ]
294
+ });
295
+ if (_instanceof(msgAction, Array)) {
296
+ if (msgAction.length == 0) return null;
297
+ // 数组
298
+ if (!msgAction.includes("copy")) {
299
+ copyNode = null;
300
+ }
301
+ if (!msgAction.includes("references")) {
302
+ referencesNode = null;
303
+ }
304
+ } else if (typeof msgAction === "object") {
305
+ if (msgAction.renderLeft) {
306
+ leftNodes = msgAction.renderLeft(copyNode, referencesNode);
307
+ }
308
+ if (msgAction.renderRight) {
309
+ rightNodes = msgAction.renderRight(copyNode, referencesNode);
310
+ }
311
+ }
312
+ var index = recordRef.current.dataSource.findIndex(function(ite) {
313
+ return ite.id == item.id;
314
+ });
315
+ if (location === "bottom") {
316
+ if (item.location === "left" && item.id !== "helloMsg" && item.id !== "inputing") {
317
+ if (index === recordRef.current.dataSource.length - 1) {
318
+ return /*#__PURE__*/ _jsxs("div", {
319
+ className: "".concat(getCls("msgItem-action")),
320
+ children: [
321
+ /*#__PURE__*/ _jsx("div", {
322
+ className: "".concat(getCls("msgItem-action-left")),
323
+ children: leftNodes
324
+ }),
325
+ /*#__PURE__*/ _jsx("div", {
326
+ className: "".concat(getCls("msgItem-action-right")),
327
+ children: rightNodes
328
+ })
329
+ ]
330
+ });
331
+ }
332
+ }
333
+ // 只有最后一条才显示底部操作啦 且是左侧消息 且不是招呼语
334
+ }
335
+ if (location === "floatTop" || location === "floatBottom") {
336
+ if (item.location === "left" && item.id !== "helloMsg" && item.id !== "inputing" && index === recordRef.current.dataSource.length - 1) return null;
337
+ // 浮框
338
+ return /*#__PURE__*/ _jsx("div", {
339
+ className: "".concat(getCls("msgItem-action-operate")),
340
+ children: /*#__PURE__*/ _jsxs("div", {
341
+ className: "".concat(getCls("msgItem-action"), " ").concat(getCls("msgItem-action-popover"), " ").concat(getCls("msgItem-action-popover-" + location)),
342
+ children: [
343
+ /*#__PURE__*/ _jsx("div", {
344
+ className: "".concat(getCls("msgItem-action-left")),
345
+ children: leftNodes
346
+ }),
347
+ /*#__PURE__*/ _jsx("div", {
348
+ className: "".concat(getCls("msgItem-action-right")),
349
+ children: rightNodes
350
+ })
351
+ ]
352
+ })
353
+ });
354
+ }
355
+ return null;
356
+ };
357
+ var markToHtml = function(markStr, id) {
358
+ var html = remarkable.render(markStr);
359
+ var position = 0;
360
+ html = html.replace(new RegExp("<pre", "ig"), function() {
361
+ position++;
362
+ return "<p class='".concat(getCls("copyCode"), " ").concat(styles.copyCodeFun, "' data-id=").concat(id, " data-position=").concat(position, ">\n <span class='").concat(getCls("icon"), " ").concat(getCls("copy"), '\'>\n <svg\n width="1em"\n height="1em"\n viewBox="0 0 14 14"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n xmlns="http://www.w3.org/2000/svg"\n >\n <g clip-path="url(#clip0_518_8403)">\n <path\n 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"\n />\n </g>\n <defs>\n <clipPath id="clip0_518_8403">\n <rect width="16" height="16" />\n </clipPath>\n </defs>\n </svg>\n </span>\n <span class=\'').concat(getCls("icon"), " ").concat(getCls("copy_success_flag"), '\'>\n <svg\n width="1em"\n height="1em"\n shape-rendering="geometricPrecision"\n fill="currentColor"\n viewBox="0 0 12 7"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path d="M11.2242 0.375687C11.4586 0.610002 11.4586 0.989901 11.2242 1.22422L4.82424 7.62422C4.58992 7.85853 4.21003 7.85853 3.97571 7.62422L0.775712 4.42422C0.541397 4.1899 0.541397 3.81 0.775712 3.57569C1.01003 3.34137 1.38993 3.34137 1.62424 3.57569L4.39998 6.35142L10.3757 0.375687C10.61 0.141373 10.9899 0.141373 11.2242 0.375687Z" />\n </svg>\n </span><span class="').concat(getCls("copyCodeText"), '">复制代码</span></p><pre');
363
+ });
364
+ return html;
365
+ };
366
+ var renderTime = function(item) {
367
+ // 生成缓存键
368
+ var cacheKey = "".concat(item.id);
369
+ // 检查缓存中是否已有结果
370
+ if (timeRenderCache.has(cacheKey)) {
371
+ return timeRenderCache.get(cacheKey);
372
+ }
373
+ var index = recordRef.current.dataSource.findIndex(function(i) {
374
+ return i.id === item.id;
375
+ });
376
+ var timeObj = parseDate(item.createTime);
377
+ var time = null;
378
+ if (index === 0) {
379
+ // 第一项 显示年月日 时分
380
+ time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
381
+ } else {
382
+ // 非第一项 与上一项进行对比
383
+ var prevItem = recordRef.current.dataSource[index - 1];
384
+ if (prevItem) {
385
+ var beforeTime = prevItem.createTime;
386
+ var beforeTimeObj = parseDate(beforeTime);
387
+ // 判断与上一条数据 是否跨天
388
+ if (timeObj.year !== beforeTimeObj.year || timeObj.month !== beforeTimeObj.month || timeObj.day !== beforeTimeObj.day) {
389
+ // 显示 年月日 时分
390
+ time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
391
+ } else {
392
+ // 没有跨天 判断是否相隔超过10分钟
393
+ if (timeObj.timestamp - beforeTimeObj.timestamp > 10 * 60 * 1000) {
394
+ // 超过10分钟 显示 时分
395
+ time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
396
+ }
397
+ }
398
+ }
399
+ }
400
+ var result = time ? /*#__PURE__*/ _jsx("div", {
401
+ className: "".concat(getCls("msg-date")),
402
+ children: time
403
+ }) : null;
404
+ // 将结果存入缓存
405
+ timeRenderCache.set(cacheKey, result);
406
+ return result;
407
+ };
408
+ var findCopyContent = function(e) {
409
+ var source = findParent(e.target, styles.copyCode);
410
+ if (!source) return;
411
+ var id = source.getAttribute("data-id");
412
+ var position = source.getAttribute("data-position");
413
+ if (!id && !position) return;
414
+ var message = "";
415
+ recordRef.current.dataSource.forEach(function(item) {
416
+ if (item.id === id) {
417
+ message = item.content;
418
+ }
419
+ });
420
+ if (!message) return;
421
+ var codeConment = "";
422
+ var i = 0;
423
+ message.replaceAll(new RegExp(/```(?:.|\n)*?```/, "ig"), function(con) {
424
+ i++;
425
+ if (i == position) {
426
+ // 异常标记
427
+ con = con.replace(/^```[\s\S]*?\n/, "").replace(/\n```$/, "");
428
+ codeConment = con;
429
+ return con;
430
+ } else {
431
+ return null;
432
+ }
433
+ });
434
+ resetStyles();
435
+ source.classList.add(styles.copy_success);
436
+ source.children[2].innerText = "复制成功";
437
+ copyText(codeConment);
438
+ setTimeout(function() {
439
+ try {
440
+ resetStyles();
441
+ } catch (error) {}
442
+ }, 3000);
443
+ };
444
+ //初始化样式
445
+ var resetStyles = function() {
446
+ var dom_list = document.getElementsByClassName(styles.copy_success);
447
+ for(var i = 0; i < dom_list.length; i++){
448
+ dom_list[i].classList.remove(styles.copy_success);
449
+ }
450
+ var dom_list2 = document.getElementsByClassName(styles.copyCodeFun);
451
+ for(var i = 0; i < dom_list2.length; i++){
452
+ var p = dom_list2[i].getElementsByClassName(styles.copyCodeText);
453
+ p[0].innerText = "复制代码";
454
+ }
455
+ };
456
+ return /*#__PURE__*/ _jsx("div", {
457
+ className: "".concat(getCls("virtuosoList-wrapper")),
458
+ ref: wrapperRef,
459
+ children: /*#__PURE__*/ _jsx(Virtuoso, {
460
+ ref: virtuosoRef,
461
+ style: {
462
+ height: "100%"
463
+ },
464
+ data: dataSource,
465
+ initialTopMostItemIndex: {
466
+ index: "LAST",
467
+ align: "end"
468
+ },
469
+ startReached: loadMore,
470
+ firstItemIndex: firstItemIndex,
471
+ context: {
472
+ loading: loading,
473
+ prefix: prefix
474
+ },
475
+ itemContent: itemContent,
476
+ components: {
477
+ Header: Header
478
+ },
479
+ increaseViewportBy: 200,
480
+ overscan: 10
481
+ })
482
+ });
483
+ });
484
+ export default VirtuosoList;