bhd-components 0.10.2 → 0.10.4

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.
@@ -35,6 +35,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
35
35
  const [textValue, setTextValue] = useState("");
36
36
  const [sending, setSending] = useState(false);
37
37
  const [fileCanSending, setFileCanSending] = useState(true); // 是否允许发送 关联文件
38
+ const updateMsgRef = useRef(null);
38
39
  // const [referencesSource, setReferencesSource] = useState<referenceType>({
39
40
  // type: "file",
40
41
  // value: {
@@ -70,6 +71,11 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
70
71
  }
71
72
  }, fileListRef.current);
72
73
  });
74
+ useEffect(()=>{
75
+ return ()=>{
76
+ clearTimeout(updateMsgRef.current);
77
+ };
78
+ }, []);
73
79
  useEffect(()=>{
74
80
  recordRef.current.value = textValue;
75
81
  recordRef.current.referencesSource = referencesSource;
@@ -177,8 +183,8 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
177
183
  });
178
184
  sendMsgAjax();
179
185
  };
180
- const sendMsgAjax = ()=>{
181
- const { url, method = "POST", headers = {}, params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {} } = sendMsgAjaxParams;
186
+ const sendMsgAjax = async ()=>{
187
+ const { url, method = "POST", headers = {}, params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {}, beforeSendMsg = ()=>Promise.resolve() } = sendMsgAjaxParams;
182
188
  ctrl.current = new AbortController();
183
189
  // apiRef
184
190
  console.log("apiRef", apiRef);
@@ -196,18 +202,20 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
196
202
  setSending(true);
197
203
  setTextValue("");
198
204
  setReferencesSource(null);
205
+ let recordMsgObj = {};
199
206
  let arg = [
200
207
  recordRef.current.value,
201
208
  recordRef.current.referencesSource,
202
209
  fileListRef.current ? fileListRef.current.getFileList() : []
203
210
  ];
211
+ let beforeInfo = await beforeSendMsg(...arg);
204
212
  fetchEventSource(url, _object_spread({
205
213
  method,
206
214
  headers: _object_spread({
207
215
  "Content-Type": "application/json",
208
216
  Accept: "text/event-stream,application/json"
209
217
  }, headers),
210
- body: params(...arg),
218
+ body: params(...arg, beforeInfo),
211
219
  openWhenHidden: true,
212
220
  signal: ctrl.current.signal,
213
221
  onopen: (res)=>{
@@ -219,22 +227,31 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
219
227
  let data = onMessage(ev);
220
228
  msgContent += data.content;
221
229
  delete data.content;
222
- apiRef.contentApi.updateMsg(msgId, _object_spread({
230
+ recordMsgObj = _object_spread({
223
231
  createTime: createTime,
224
232
  content: msgContent,
225
233
  location: "left",
226
234
  reference: null,
227
235
  source: null
228
- }, data));
229
- msgId = data.id;
236
+ }, data);
237
+ updateMsgRef.current = setTimeout(()=>{
238
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
239
+ msgId = data.id;
240
+ }, 100);
230
241
  },
231
242
  onclose: ()=>{
232
243
  onClose();
233
244
  setSending(false);
234
- console.log("onclose: ", event);
245
+ if (recordMsgObj.id) {
246
+ apiRef.contentApi.recordMsg(recordMsgObj);
247
+ }
248
+ console.log("onclose: ", recordMsgObj);
235
249
  },
236
250
  onerror: (err)=>{
237
251
  onError(err);
252
+ if (recordMsgObj.id) {
253
+ apiRef.contentApi.recordMsg(recordMsgObj);
254
+ }
238
255
  console.log("onerror: ", err);
239
256
  }
240
257
  }, coverProps));
@@ -43,14 +43,14 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
43
43
  const { getList, coverRenderText, msgAction = [
44
44
  "copy",
45
45
  "references"
46
- ], coverRenderReferences } = contentConfig;
46
+ ], coverRenderReferences, onRecordMessage = ()=>{} } = contentConfig;
47
47
  const loadMoreProps = contentConfig.loadMore || true;
48
48
  const virtuosoRef = useRef(null);
49
49
  const [loading, setLoading] = useState(false); // 是否加载中
50
50
  const [dataSource, setDataSource] = useState([]);
51
51
  const [firstItemIndex, setFirstItemIndex] = useState(0);
52
52
  const [page, setPage] = useState(1);
53
- const [pageSize, setPageSize] = useState(30);
53
+ const [pageSize, setPageSize] = useState(contentConfig.pageSize || 30);
54
54
  const [total, setTotal] = useState(0);
55
55
  const timerRef = useRef({
56
56
  loadMore: null,
@@ -68,6 +68,10 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
68
68
  useImperativeHandle(ref, ()=>{
69
69
  return {
70
70
  addMsg: (msg)=>{
71
+ if (msg.id !== "inputing") {
72
+ // 不记录"正在输入..."的消息
73
+ onRecordMessage(msg);
74
+ }
71
75
  setDataSource((data)=>{
72
76
  return [
73
77
  ...data,
@@ -89,6 +93,9 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
89
93
  setDataSource((data)=>{
90
94
  return data.filter((item)=>item.id !== "inputing");
91
95
  });
96
+ },
97
+ recordMsg: (msg)=>{
98
+ onRecordMessage(msg);
92
99
  }
93
100
  };
94
101
  });
@@ -70,12 +70,12 @@
70
70
  background: rgba(0, 0, 0, 0.02);
71
71
  text-align: right;
72
72
  height: 37px;
73
- line-height: 37px !important;
74
- padding: 0 !important;
75
- padding-right: 16px !important;
73
+ line-height: 37px;
74
+ padding: 0 ;
75
+ padding-right: 16px ;
76
76
  position: relative;
77
77
  cursor: pointer;
78
- font-weight: 400 !important;
78
+ font-weight: 400 ;
79
79
  top: 6px;
80
80
  &.copyCodeFun {
81
81
  display: flex;
@@ -167,20 +167,20 @@
167
167
  list-style: inside;
168
168
  color: rgba(0, 0, 0, 0.85);
169
169
  &::marker {
170
- color: #d9d9d9 !important;
170
+ color: #d9d9d9;
171
171
  }
172
172
  &:first-child {
173
- padding-top: 8px !important;
173
+ padding-top: 8px;
174
174
  }
175
175
  }
176
176
  li > ol li {
177
177
  // padding-bottom: 8px;
178
178
  &::marker {
179
- color: rgba(0, 0, 0, 0.45) !important;
179
+ color: rgba(0, 0, 0, 0.45);
180
180
  }
181
181
 
182
182
  &:first-child {
183
- padding-top: 8px !important;
183
+ padding-top: 8px;
184
184
  }
185
185
  }
186
186
  > li:last-of-type {
@@ -202,10 +202,10 @@
202
202
  padding-top: 8px;
203
203
  padding-bottom: 8px;
204
204
  &:first-child {
205
- padding-top: 0 !important;
205
+ padding-top: 0;
206
206
  }
207
207
  &:last-child {
208
- padding-bottom: 0 !important;
208
+ padding-bottom: 0;
209
209
  }
210
210
  }
211
211
  > h3,
@@ -233,7 +233,7 @@
233
233
  }
234
234
  table {
235
235
  width: 100%;
236
- padding: 0 !important;
236
+ padding: 0;
237
237
  margin: 8px 0;
238
238
  border-collapse: separate;
239
239
  border-top: 1px solid #dfe6ec;
@@ -289,7 +289,7 @@
289
289
  .msgItem-action-popover {
290
290
  position: absolute;
291
291
  width: max-content;
292
- border-radius: 4px !important;
292
+ border-radius: 4px;
293
293
  background: #fff;
294
294
  line-height: 1;
295
295
  z-index: 9;
@@ -47,8 +47,13 @@ export interface contentConfigProps {
47
47
  }>; // 列表数据
48
48
  loadMore?: boolean; // 是否开启加载更多 // 默认为true
49
49
  helloMsg?: string; //欢迎语
50
+ pageSize?: number; //每页数量 默认为30
50
51
  coverRenderText?: (item, html) => React.ReactNode; // 覆盖文本内容
51
- coverRenderReferences?: (item:dataItemType,referenceNode:React.ReactNode) => React.ReactNode;//覆盖引用内容
52
+ coverRenderReferences?: (
53
+ item: dataItemType,
54
+ referenceNode: React.ReactNode
55
+ ) => React.ReactNode; //覆盖引用内容
56
+ onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
52
57
  }
53
58
 
54
59
  // content props
@@ -80,13 +85,19 @@ export interface sendMsgAjaxParams {
80
85
  params: (
81
86
  value: string,
82
87
  refereces: referenceType,
83
- fileList: fileCustomProps[]
88
+ fileList: fileCustomProps[],
89
+ beforeInfo:any,
84
90
  ) => string;
85
91
  onOpen?: (res: Response) => void;
86
92
  onMessage?: (ev: EventSourceMessage) => { id: string; content: string };
87
93
  onClose?: () => void;
88
94
  onError?: (err: any) => void;
89
95
  coverProps?: object;
96
+ beforeSendMsg: (
97
+ value: string,
98
+ refereces: referenceType,
99
+ fileList: fileCustomProps[]
100
+ ) => Promise<any>;
90
101
  }
91
102
 
92
103
  // footer file Props
@@ -98,7 +109,12 @@ export interface fileUploadProps {
98
109
  multiple?: boolean; // 是否允许多选
99
110
  customRequest: (
100
111
  file: File
101
- ) => Promise<{ url: string; fileId: string; source: File,status:fileStatus }>; // 自定义上传方法
112
+ ) => Promise<{
113
+ url: string;
114
+ fileId: string;
115
+ source: File;
116
+ status: fileStatus;
117
+ }>; // 自定义上传方法
102
118
  mapUploadCount?: number; // 并发上传的数量 默认为1
103
119
  deleteFileAjax?: (fileId: string) => Promise<{ fileId: string }>; // 删除文件的ajax 返回删除文件的fileId
104
120
  statusText?: (status: fileStatus) => React.ReactNode; // 自定义状态显示
@@ -125,7 +141,7 @@ export interface footerRefProps {
125
141
  clearText: () => void; // 清空输入框
126
142
  getCanSendMsg: () => boolean; //获取当前是否允许发送消息的状态
127
143
  stopMessage: () => void; //停止发送消息
128
- setReferences:(reference:referenceType)=>void;// 添加引用
144
+ setReferences: (reference: referenceType) => void; // 添加引用
129
145
  }
130
146
 
131
147
  // sendBtn Props
@@ -150,10 +166,9 @@ export interface fileListProps {
150
166
  prefix: string;
151
167
  fileUpload: fileUploadProps;
152
168
  errorCallback: (error: errorMessageProps) => void;
153
- changeFileCanSending:(flag:boolean)=>void;
169
+ changeFileCanSending: (flag: boolean) => void;
154
170
  }
155
171
 
156
-
157
172
  // file 自定义对象
158
173
 
159
174
  export interface fileCustomProps {
@@ -173,8 +188,8 @@ export interface FileListRefProps {
173
188
  deleteFile: (fileId: string) => void;
174
189
  updateFile: (fileId: string, status: fileStatus) => void;
175
190
  getFileList: () => fileCustomProps[];
176
- vaildFile: (file: File,fileId?:string) => boolean;// 校验文件是否合规
177
- fileToCustomFile:(file:File)=>fileCustomProps
191
+ vaildFile: (file: File, fileId?: string) => boolean; // 校验文件是否合规
192
+ fileToCustomFile: (file: File) => fileCustomProps;
178
193
  }
179
194
 
180
195
  // error Message
@@ -220,7 +235,8 @@ export interface VirtuosoListProps {
220
235
  export interface VirtuosoListRefProps {
221
236
  addMsg: (msg: dataItemType) => void;
222
237
  updateMsg: (id: string, obj: any) => void;
223
- clearInputing: () => void;//清楚正在输入的inputing
238
+ clearInputing: () => void; //清楚正在输入的inputing
239
+ recordMsg: (item: dataItemType) => void;
224
240
  }
225
241
 
226
242
  export interface contentRefProps extends VirtuosoListRefProps {}
@@ -1,6 +1,8 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
1
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
3
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
3
4
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
6
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
5
7
  import React, { useState, useEffect, useImperativeHandle, forwardRef, useRef, useMemo } from "react";
6
8
  import styles from "./index.module.less";
@@ -37,6 +39,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
37
39
  var _useState = _sliced_to_array(useState(""), 2), textValue = _useState[0], setTextValue = _useState[1];
38
40
  var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
39
41
  var _useState2 = _sliced_to_array(useState(true), 2), fileCanSending = _useState2[0], setFileCanSending = _useState2[1]; // 是否允许发送 关联文件
42
+ var updateMsgRef = useRef(null);
40
43
  // const [referencesSource, setReferencesSource] = useState<referenceType>({
41
44
  // type: "file",
42
45
  // value: {
@@ -72,6 +75,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
72
75
  }
73
76
  }, fileListRef.current);
74
77
  });
78
+ useEffect(function() {
79
+ return function() {
80
+ clearTimeout(updateMsgRef.current);
81
+ };
82
+ }, []);
75
83
  useEffect(function() {
76
84
  recordRef.current.value = textValue;
77
85
  recordRef.current.referencesSource = referencesSource;
@@ -180,71 +188,105 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
180
188
  sendMsgAjax();
181
189
  };
182
190
  var sendMsgAjax = function() {
183
- 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 ? {} : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
184
- return "";
185
- } : _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) {
186
- return ev;
187
- } : _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;
188
- ctrl.current = new AbortController();
189
- // apiRef
190
- console.log("apiRef", apiRef);
191
- var msgId = "inputing";
192
- var createTime = new Date().getTime();
193
- apiRef.contentApi.addMsg({
194
- id: msgId,
195
- createTime: createTime,
196
- content: "正在输入...",
197
- location: "left",
198
- reference: null,
199
- source: null
191
+ var _ref = _async_to_generator(function() {
192
+ var url, _sendMsgAjaxParams_method, method, _sendMsgAjaxParams_headers, headers, _sendMsgAjaxParams_params, params, _sendMsgAjaxParams_onOpen, onOpen, _sendMsgAjaxParams_onMessage, onMessage, _sendMsgAjaxParams_onClose, onClose, _sendMsgAjaxParams_onError, onError, _sendMsgAjaxParams_coverProps, coverProps, _sendMsgAjaxParams_beforeSendMsg, beforeSendMsg, msgId, createTime, msgContent, recordMsgObj, arg, beforeInfo;
193
+ return _ts_generator(this, function(_state) {
194
+ switch(_state.label){
195
+ case 0:
196
+ url = sendMsgAjaxParams.url, _sendMsgAjaxParams_method = sendMsgAjaxParams.method, method = _sendMsgAjaxParams_method === void 0 ? "POST" : _sendMsgAjaxParams_method, _sendMsgAjaxParams_headers = sendMsgAjaxParams.headers, headers = _sendMsgAjaxParams_headers === void 0 ? {} : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
197
+ return "";
198
+ } : _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) {
199
+ return ev;
200
+ } : _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() {
201
+ return Promise.resolve();
202
+ } : _sendMsgAjaxParams_beforeSendMsg;
203
+ ctrl.current = new AbortController();
204
+ // apiRef
205
+ console.log("apiRef", apiRef);
206
+ msgId = "inputing";
207
+ createTime = new Date().getTime();
208
+ apiRef.contentApi.addMsg({
209
+ id: msgId,
210
+ createTime: createTime,
211
+ content: "正在输入...",
212
+ location: "left",
213
+ reference: null,
214
+ source: null
215
+ });
216
+ msgContent = "";
217
+ setSending(true);
218
+ setTextValue("");
219
+ setReferencesSource(null);
220
+ recordMsgObj = {};
221
+ arg = [
222
+ recordRef.current.value,
223
+ recordRef.current.referencesSource,
224
+ fileListRef.current ? fileListRef.current.getFileList() : []
225
+ ];
226
+ return [
227
+ 4,
228
+ beforeSendMsg.apply(void 0, _to_consumable_array(arg))
229
+ ];
230
+ case 1:
231
+ beforeInfo = _state.sent();
232
+ fetchEventSource(url, _object_spread({
233
+ method: method,
234
+ headers: _object_spread({
235
+ "Content-Type": "application/json",
236
+ Accept: "text/event-stream,application/json"
237
+ }, headers),
238
+ body: params.apply(void 0, _to_consumable_array(arg).concat([
239
+ beforeInfo
240
+ ])),
241
+ openWhenHidden: true,
242
+ signal: ctrl.current.signal,
243
+ onopen: function(res) {
244
+ onOpen(res);
245
+ if (res.status === 200) {}
246
+ return null;
247
+ },
248
+ onmessage: function(ev) {
249
+ var data = onMessage(ev);
250
+ msgContent += data.content;
251
+ delete data.content;
252
+ recordMsgObj = _object_spread({
253
+ createTime: createTime,
254
+ content: msgContent,
255
+ location: "left",
256
+ reference: null,
257
+ source: null
258
+ }, data);
259
+ updateMsgRef.current = setTimeout(function() {
260
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
261
+ msgId = data.id;
262
+ }, 100);
263
+ },
264
+ onclose: function() {
265
+ onClose();
266
+ setSending(false);
267
+ if (recordMsgObj.id) {
268
+ apiRef.contentApi.recordMsg(recordMsgObj);
269
+ }
270
+ console.log("onclose: ", recordMsgObj);
271
+ },
272
+ onerror: function(err) {
273
+ onError(err);
274
+ if (recordMsgObj.id) {
275
+ apiRef.contentApi.recordMsg(recordMsgObj);
276
+ }
277
+ console.log("onerror: ", err);
278
+ }
279
+ }, coverProps));
280
+ return [
281
+ 2
282
+ ];
283
+ }
284
+ });
200
285
  });
201
- var msgContent = "";
202
- setSending(true);
203
- setTextValue("");
204
- setReferencesSource(null);
205
- var arg = [
206
- recordRef.current.value,
207
- recordRef.current.referencesSource,
208
- fileListRef.current ? fileListRef.current.getFileList() : []
209
- ];
210
- fetchEventSource(url, _object_spread({
211
- method: method,
212
- headers: _object_spread({
213
- "Content-Type": "application/json",
214
- Accept: "text/event-stream,application/json"
215
- }, headers),
216
- body: params.apply(void 0, _to_consumable_array(arg)),
217
- openWhenHidden: true,
218
- signal: ctrl.current.signal,
219
- onopen: function(res) {
220
- onOpen(res);
221
- if (res.status === 200) {}
222
- return null;
223
- },
224
- onmessage: function(ev) {
225
- var data = onMessage(ev);
226
- msgContent += data.content;
227
- delete data.content;
228
- apiRef.contentApi.updateMsg(msgId, _object_spread({
229
- createTime: createTime,
230
- content: msgContent,
231
- location: "left",
232
- reference: null,
233
- source: null
234
- }, data));
235
- msgId = data.id;
236
- },
237
- onclose: function() {
238
- onClose();
239
- setSending(false);
240
- console.log("onclose: ", event);
241
- },
242
- onerror: function(err) {
243
- onError(err);
244
- console.log("onerror: ", err);
245
- }
246
- }, coverProps));
247
- };
286
+ return function sendMsgAjax() {
287
+ return _ref.apply(this, arguments);
288
+ };
289
+ }();
248
290
  // 判断是否超出最大字数
249
291
  var judegTextLengthWarn = function() {
250
292
  if (typeof maxLength === "function") {
@@ -47,14 +47,14 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
47
47
  var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
48
48
  "copy",
49
49
  "references"
50
- ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences;
50
+ ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage;
51
51
  var loadMoreProps = contentConfig.loadMore || true;
52
52
  var virtuosoRef = useRef(null);
53
53
  var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
54
54
  var _useState1 = _sliced_to_array(useState([]), 2), dataSource = _useState1[0], setDataSource = _useState1[1];
55
55
  var _useState2 = _sliced_to_array(useState(0), 2), firstItemIndex = _useState2[0], setFirstItemIndex = _useState2[1];
56
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];
57
+ var _useState4 = _sliced_to_array(useState(contentConfig.pageSize || 30), 2), pageSize = _useState4[0], setPageSize = _useState4[1];
58
58
  var _useState5 = _sliced_to_array(useState(0), 2), total = _useState5[0], setTotal = _useState5[1];
59
59
  var timerRef = useRef({
60
60
  loadMore: null,
@@ -72,6 +72,10 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
72
72
  useImperativeHandle(ref, function() {
73
73
  return {
74
74
  addMsg: function(msg) {
75
+ if (msg.id !== "inputing") {
76
+ // 不记录"正在输入..."的消息
77
+ onRecordMessage(msg);
78
+ }
75
79
  setDataSource(function(data) {
76
80
  return _to_consumable_array(data).concat([
77
81
  msg
@@ -94,6 +98,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
94
98
  return item.id !== "inputing";
95
99
  });
96
100
  });
101
+ },
102
+ recordMsg: function(msg) {
103
+ onRecordMessage(msg);
97
104
  }
98
105
  };
99
106
  });
@@ -70,12 +70,12 @@
70
70
  background: rgba(0, 0, 0, 0.02);
71
71
  text-align: right;
72
72
  height: 37px;
73
- line-height: 37px !important;
74
- padding: 0 !important;
75
- padding-right: 16px !important;
73
+ line-height: 37px;
74
+ padding: 0 ;
75
+ padding-right: 16px ;
76
76
  position: relative;
77
77
  cursor: pointer;
78
- font-weight: 400 !important;
78
+ font-weight: 400 ;
79
79
  top: 6px;
80
80
  &.copyCodeFun {
81
81
  display: flex;
@@ -167,20 +167,20 @@
167
167
  list-style: inside;
168
168
  color: rgba(0, 0, 0, 0.85);
169
169
  &::marker {
170
- color: #d9d9d9 !important;
170
+ color: #d9d9d9;
171
171
  }
172
172
  &:first-child {
173
- padding-top: 8px !important;
173
+ padding-top: 8px;
174
174
  }
175
175
  }
176
176
  li > ol li {
177
177
  // padding-bottom: 8px;
178
178
  &::marker {
179
- color: rgba(0, 0, 0, 0.45) !important;
179
+ color: rgba(0, 0, 0, 0.45);
180
180
  }
181
181
 
182
182
  &:first-child {
183
- padding-top: 8px !important;
183
+ padding-top: 8px;
184
184
  }
185
185
  }
186
186
  > li:last-of-type {
@@ -202,10 +202,10 @@
202
202
  padding-top: 8px;
203
203
  padding-bottom: 8px;
204
204
  &:first-child {
205
- padding-top: 0 !important;
205
+ padding-top: 0;
206
206
  }
207
207
  &:last-child {
208
- padding-bottom: 0 !important;
208
+ padding-bottom: 0;
209
209
  }
210
210
  }
211
211
  > h3,
@@ -233,7 +233,7 @@
233
233
  }
234
234
  table {
235
235
  width: 100%;
236
- padding: 0 !important;
236
+ padding: 0;
237
237
  margin: 8px 0;
238
238
  border-collapse: separate;
239
239
  border-top: 1px solid #dfe6ec;
@@ -289,7 +289,7 @@
289
289
  .msgItem-action-popover {
290
290
  position: absolute;
291
291
  width: max-content;
292
- border-radius: 4px !important;
292
+ border-radius: 4px;
293
293
  background: #fff;
294
294
  line-height: 1;
295
295
  z-index: 9;