bhd-components 0.5.7 → 0.5.8

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 (32) hide show
  1. package/dist/5764783e.esm.es5.production.js +468 -0
  2. package/dist/{535fc6c5.esm.es5.development.js → f2b01b9c.esm.es5.development.js} +98068 -25721
  3. package/dist/index.esm.es5.development.css +8467 -0
  4. package/dist/index.esm.es5.development.js +5835 -0
  5. package/dist/index.esm.es5.production.css +1 -0
  6. package/dist/index.esm.es5.production.js +1 -0
  7. package/es2017/customerService/contactsList/index.d.ts +3 -2
  8. package/es2017/customerService/contactsList/index.js +93 -90
  9. package/es2017/customerService/contactsList/index.module.less +32 -13
  10. package/es2017/customerService/function.js +18 -13
  11. package/es2017/customerService/historyFun/index.d.ts +2 -1
  12. package/es2017/customerService/historyFun/index.js +121 -86
  13. package/es2017/customerService/historyFun/index.module.less +40 -6
  14. package/es2017/customerService/index.js +771 -577
  15. package/es2017/customerService/index.module.less +747 -684
  16. package/es2017/icons/components/custom-duihao.js +1 -1
  17. package/esm/customerService/contactsList/index.d.ts +3 -2
  18. package/esm/customerService/contactsList/index.js +104 -97
  19. package/esm/customerService/contactsList/index.module.less +32 -13
  20. package/esm/customerService/function.js +18 -13
  21. package/esm/customerService/historyFun/index.d.ts +2 -1
  22. package/esm/customerService/historyFun/index.js +127 -94
  23. package/esm/customerService/historyFun/index.module.less +40 -6
  24. package/esm/customerService/index.js +836 -619
  25. package/esm/customerService/index.module.less +747 -684
  26. package/esm/icons/components/custom-duihao.js +1 -1
  27. package/package.json +4 -3
  28. package/dist/1bddec89.esm.es5.production.js +0 -72
  29. package/dist/CustomerService.esm.es5.development.css +0 -2827
  30. package/dist/CustomerService.esm.es5.development.js +0 -3823
  31. package/dist/CustomerService.esm.es5.production.css +0 -1
  32. package/dist/CustomerService.esm.es5.production.js +0 -1
@@ -8,7 +8,7 @@ const CustomDuihaoSvg = ()=>/*#__PURE__*/ _jsx("svg", {
8
8
  height: "1em",
9
9
  "shape-rendering": "geometricPrecision",
10
10
  fill: "currentColor",
11
- viewBox: "0 0 14 14",
11
+ viewBox: "0 0 12 7",
12
12
  xmlns: "http://www.w3.org/2000/svg",
13
13
  children: /*#__PURE__*/ _jsx("path", {
14
14
  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"
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  interface data {
3
3
  type: number;
4
- roomId: String;
4
+ roomId: string;
5
5
  userData: any;
6
6
  http: any;
7
7
  urllocation: String;
8
8
  onClose: any;
9
9
  switchChatRoom: any;
10
10
  saveContactsList: any;
11
+ ref: any;
11
12
  }
12
- declare const ContactsList: (props: data) => JSX.Element;
13
+ declare const ContactsList: import("react").ForwardRefExoticComponent<Omit<data, "ref"> & import("react").RefAttributes<unknown>>;
13
14
  export default ContactsList;
@@ -1,29 +1,45 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
4
- import React, { useEffect, useState, useRef } from "react";
4
+ import React, { useEffect, useState, useRef, useImperativeHandle, forwardRef } from "react";
5
5
  import styles from "./index.module.less";
6
6
  import { CustomAiIcon, CustomRetract } from "../../icons/index";
7
7
  import { CloseOutlined } from "@ant-design/icons";
8
8
  import { getDataTime } from "../function"; //录音使用文件
9
- var ContactsList = function(props) {
9
+ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
10
10
  var type = props.type, roomId = props.roomId, userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, switchChatRoom = props.switchChatRoom, saveContactsList = props.saveContactsList;
11
11
  var _useState = _sliced_to_array(useState([]), 2), contactsList = _useState[0], setContactsList = _useState[1]; //老师列表
12
+ var _useState1 = _sliced_to_array(useState(""), 2), newRoomId = _useState1[0], setNewRoomId = _useState1[1];
13
+ var _useState2 = _sliced_to_array(useState(true), 2), firstLoading = _useState2[0], setFirstLoading = _useState2[1];
14
+ // const [type,setType] = useState(0);
12
15
  var timer = useRef(null); //文本框输入时
13
16
  //获取聊天室列表
14
17
  useEffect(function() {
15
- // if (roomId != "") {
16
18
  roomsListTimer();
17
- // }
19
+ if (roomId != "") {
20
+ setNewRoomId(roomId);
21
+ }
18
22
  return function() {
19
23
  clearTimeout(timer.current);
20
24
  };
21
25
  }, []);
26
+ useImperativeHandle(ref, function() {
27
+ return {
28
+ roomsListTimer: function() {
29
+ return roomsListTimer();
30
+ }
31
+ };
32
+ });
33
+ // useEffect(()=>{
34
+ // //重新调用接口
35
+ // console.log(44444444,contactsList)
36
+ // roomsListTimer();
37
+ // },[type])
22
38
  var roomsListTimer = function() {
23
39
  if (timer != null) clearTimeout(timer.current);
24
40
  timer.current = setTimeout(function() {
25
41
  return roomsListTimer();
26
- }, 100000);
42
+ }, 60000);
27
43
  http.get("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
28
44
  params: {
29
45
  page: 1,
@@ -38,56 +54,51 @@ var ContactsList = function(props) {
38
54
  }).then(function(res) {
39
55
  if (res.data) {
40
56
  var list = res.data.contacts;
41
- // let list2 = list.slice(1);
42
- var list2 = list;
57
+ // let newMessage = false;
43
58
  setContactsList(function(contactsList) {
44
- if (contactsList.length > 0 && roomId != "") {
45
- //查找当前聊天室的未读消息
46
- var message = 0;
47
- var messageList = contactsList.filter(function(item) {
48
- return item.id == roomId;
59
+ list = list.map(function(item, index) {
60
+ var c_list = contactsList.filter(function(e) {
61
+ return e.sender == item.sender;
49
62
  });
50
- if (messageList.length > 0) {
51
- // console.log(messageList,'messagemessagemessage');
52
- message = messageList[0].unreadCount;
53
- }
54
- var new_message = 0;
55
- if (list.length > 0) {
56
- var new_message_list = list.filter(function(item) {
57
- return item.id == roomId;
58
- });
59
- if (new_message_list.length > 0) {
60
- console.log(new_message_list, "new_messagenew_messagenew_messagenew_message");
61
- new_message = new_message_list[0].unreadCount;
62
- }
63
- }
64
- // console.log(message,new_message,'lsdlcksdcmsdlkc')
65
- //存在新消息
66
- if (message != new_message) {
67
- console.log("有新消息");
68
- switchChatRoom(roomId, "renew");
63
+ var obj = {};
64
+ if (c_list.length > 0) {
65
+ obj = c_list[0];
69
66
  }
70
- }
71
- list2 = list2.map(function(item, index) {
72
- // if(contactsList[index] != undefined){
73
- return _object_spread({}, item, contactsList[index] || "");
74
- // }else{
75
- // return item
76
- // }
67
+ return _object_spread({}, obj, item);
77
68
  });
78
- return list2;
79
- });
80
- console.log(list2, "list2list2list2list2");
81
- // setAi(res.data.contacts[0]);
82
- getUserInfo(list2);
83
- //切换到有聊天的窗口
84
- list2.forEach(function(ele) {
85
- console.log(ele);
86
- if (ele.unreadCount > 0) {
87
- switchChatRoom(ele.roomId, "");
88
- return;
89
- }
69
+ return list;
90
70
  });
71
+ getUserInfo(list);
72
+ // if(firstLoading){
73
+ // setFirstLoading(false);
74
+ // let isRoom = false;
75
+ // for (let index = 0; index < list.length; index++) {
76
+ // let count = list[index].unreadCount;
77
+ // if(count > 0 && list[index].roomId == roomId){
78
+ // isRoom = true;
79
+ // //在当前窗口
80
+ // return null;
81
+ // }else if(count > 0){
82
+ // isRoom = true;
83
+ // switchChatRoom(list[index].roomId, "");
84
+ // setContactsList((contactsList)=>{
85
+ // let new_list = contactsList;
86
+ // new_list = new_list.map((item)=>{
87
+ // if(item.roomId == list[index].roomId){
88
+ // return {
89
+ // ...item,
90
+ // unreadCount:0,
91
+ // }
92
+ // }else{
93
+ // return item;
94
+ // }
95
+ // })
96
+ // return new_list;
97
+ // })
98
+ // return null;
99
+ // }
100
+ // }
101
+ // }
91
102
  saveContactsList(list);
92
103
  }
93
104
  });
@@ -102,29 +113,37 @@ var ContactsList = function(props) {
102
113
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
103
114
  }
104
115
  }).then(function(res) {
105
- console.log(res, "sdcsdcsdc");
106
- // roomsList();
107
116
  roomsListTimer();
117
+ // let contactsList;
118
+ // setContactsList((list)=>{
119
+ // contactsList = list.filter(e=>e.roomId != roomId);
120
+ // //切换到AI聊天窗口
121
+ // if(roomId == props.roomId){
122
+ // switchChatRoom(contactsList[0].roomId, "");
123
+ // }
124
+ // return contactsList;
125
+ // })
126
+ // saveContactsList(contactsList);
108
127
  });
109
128
  };
110
129
  //获取老师的信息等
111
- var getUserInfo = function(list2) {
112
- list2.map(function(item, i) {
130
+ var getUserInfo = function(list) {
131
+ list.map(function(item, i) {
113
132
  if (!item.name && !item.headImg && item.sender != "AI") {
114
133
  getUserName(item.sender).then(function(res) {
115
134
  if (res.data) {
116
- var list;
135
+ var _$list;
117
136
  setContactsList(function(contactsList) {
118
- list = contactsList.map(function(item, index) {
137
+ _$list = contactsList.map(function(item, index) {
119
138
  if (item.sender == res.data.uid) {
120
139
  return _object_spread({}, item, res.data);
121
140
  } else {
122
141
  return item;
123
142
  }
124
143
  });
125
- return list;
144
+ return _$list;
126
145
  });
127
- saveContactsList(list);
146
+ saveContactsList(_$list);
128
147
  }
129
148
  });
130
149
  }
@@ -143,34 +162,6 @@ var ContactsList = function(props) {
143
162
  }
144
163
  });
145
164
  };
146
- // //获取当前时间
147
- // const getDataTime = (time: string | number | Date) => {
148
- // let currentDate;
149
- // if (time != undefined && time != -1) {
150
- // currentDate = new Date(time);
151
- // } else {
152
- // currentDate = new Date();
153
- // }
154
- // const currentYear = currentDate.getFullYear();
155
- // const currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
156
- // const currentDay = currentDate.getDate();
157
- // const hour = currentDate.getHours();
158
- // const minute = currentDate.getMinutes();
159
- // const second = currentDate.getSeconds();
160
- // let dataTime =
161
- // currentYear +
162
- // "-" +
163
- // currentMonth +
164
- // "-" +
165
- // currentDay +
166
- // " " +
167
- // hour +
168
- // ":" +
169
- // minute +
170
- // ":" +
171
- // second;
172
- // return dataTime;
173
- // };
174
165
  return type == 2 || type == 4 ? //联系人展开
175
166
  /*#__PURE__*/ _jsxs("div", {
176
167
  className: styles.teacher_layout_modal,
@@ -178,9 +169,11 @@ var ContactsList = function(props) {
178
169
  /*#__PURE__*/ _jsx("div", {
179
170
  className: styles.top,
180
171
  children: /*#__PURE__*/ _jsxs("div", {
181
- className: "".concat(styles.ai, " ").concat(contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId ? styles.active : ""),
172
+ className: "".concat(styles.ai, " ").concat(contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""),
182
173
  onClick: function() {
174
+ setNewRoomId(contactsList[0].roomId);
183
175
  switchChatRoom(contactsList[0].roomId, "");
176
+ roomsListTimer();
184
177
  },
185
178
  children: [
186
179
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -206,14 +199,18 @@ var ContactsList = function(props) {
206
199
  ]
207
200
  })
208
201
  }),
209
- /*#__PURE__*/ _jsx("div", {
202
+ userData.modules.some(function(item) {
203
+ return item.short == "TeacherAnswer";
204
+ }) ? /*#__PURE__*/ _jsx("div", {
210
205
  className: styles.bottom,
211
206
  children: contactsList.map(function(item, index) {
212
207
  if (index != 0) {
213
208
  return /*#__PURE__*/ _jsxs("div", {
214
209
  className: "".concat(styles.ai, " ").concat(item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""),
215
210
  onClick: function() {
211
+ setNewRoomId(item.roomId);
216
212
  switchChatRoom(item.roomId, "");
213
+ roomsListTimer();
217
214
  },
218
215
  children: [
219
216
  /*#__PURE__*/ _jsx("img", {
@@ -226,9 +223,9 @@ var ContactsList = function(props) {
226
223
  className: styles.message,
227
224
  children: [
228
225
  item.name,
229
- item.unreadCount != undefined && item.unreadCount > 0 && /*#__PURE__*/ _jsx("span", {
226
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != "" && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
230
227
  className: styles.num,
231
- children: item.unreadCount
228
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
232
229
  }),
233
230
  /*#__PURE__*/ _jsx("span", {
234
231
  className: styles.time,
@@ -248,7 +245,7 @@ var ContactsList = function(props) {
248
245
  return null;
249
246
  }
250
247
  })
251
- })
248
+ }) : ""
252
249
  ]
253
250
  }) : /*#__PURE__*/ _jsxs("div", {
254
251
  className: "".concat(styles.teacher_layout, " ").concat(type == 3 ? styles.teacher_layout_newlabo : ""),
@@ -267,14 +264,19 @@ var ContactsList = function(props) {
267
264
  children: [
268
265
  /*#__PURE__*/ _jsx(CustomRetract, {}),
269
266
  /*#__PURE__*/ _jsx("p", {
267
+ style: {
268
+ marginTop: "8px"
269
+ },
270
270
  children: "收起"
271
271
  })
272
272
  ]
273
273
  }),
274
274
  /*#__PURE__*/ _jsxs("div", {
275
- className: "".concat(styles.ai, " ").concat(contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId ? styles.active : ""),
275
+ className: "".concat(styles.ai, " ").concat(contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""),
276
276
  onClick: function() {
277
+ setNewRoomId(contactsList[0].roomId);
277
278
  switchChatRoom(contactsList[0].roomId, "");
279
+ roomsListTimer();
278
280
  },
279
281
  children: [
280
282
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -285,14 +287,18 @@ var ContactsList = function(props) {
285
287
  })
286
288
  ]
287
289
  }),
288
- /*#__PURE__*/ _jsx("div", {
290
+ userData.modules.some(function(item) {
291
+ return item.short == "TeacherAnswer";
292
+ }) && /*#__PURE__*/ _jsx("div", {
289
293
  className: styles.bottom,
290
294
  children: contactsList.map(function(item, index) {
291
295
  if (index != 0) {
292
296
  return /*#__PURE__*/ _jsxs("div", {
293
297
  className: "".concat(styles.ai, " ").concat(item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""),
294
298
  onClick: function() {
299
+ setNewRoomId(item.roomId);
295
300
  switchChatRoom(item.roomId, "");
301
+ roomsListTimer();
296
302
  },
297
303
  children: [
298
304
  /*#__PURE__*/ _jsx("img", {
@@ -301,11 +307,12 @@ var ContactsList = function(props) {
301
307
  /*#__PURE__*/ _jsx("p", {
302
308
  children: item.name
303
309
  }),
304
- item.unreadCount != undefined && item.unreadCount > 0 && /*#__PURE__*/ _jsx("span", {
310
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != "" && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
305
311
  className: styles.num,
306
- children: item.unreadCount
312
+ children: item.unreadCount > 99 ? "99+" : item.unreadCount
307
313
  }),
308
- /*#__PURE__*/ _jsx("span", {
314
+ // 没有消息时,可点击删除
315
+ !item.unreadCount && /*#__PURE__*/ _jsx("span", {
309
316
  className: styles.delete,
310
317
  onClick: function(e) {
311
318
  e.stopPropagation();
@@ -322,5 +329,5 @@ var ContactsList = function(props) {
322
329
  })
323
330
  ]
324
331
  });
325
- };
332
+ });
326
333
  export default ContactsList;
@@ -1,4 +1,6 @@
1
1
  @import "../../theme/variable.less";
2
+ // @color-background-primary-weak-hover:@color-background-info-weak;
3
+
2
4
  //联系人列表
3
5
  .teacher_layout {
4
6
  position: fixed;
@@ -49,19 +51,17 @@
49
51
  border-radius: 26px;
50
52
  background-color: #f4523b;
51
53
  color: #fff;
52
- padding: 2px 5px;
54
+ padding: 0 5px;
53
55
  border-radius: 25px;
54
56
  font-size: 12px;
55
57
  line-height: 1.2;
56
58
  }
57
-
58
59
  .delete {
59
- font-size: 18px;
60
60
  position: absolute;
61
- top: -2px;
62
- right: 0;
61
+ top: 2px;
62
+ right: 2px;
63
63
  color: rgba(0, 0, 0, 0.65);
64
- font-size: 14px;
64
+ font-size: 12px;
65
65
  display: none;
66
66
  }
67
67
  }
@@ -80,7 +80,7 @@
80
80
  padding-top: 0;
81
81
  }
82
82
  &:hover {
83
- background-color: #fff;
83
+ background-color: #fff !important;
84
84
  }
85
85
  }
86
86
  .top .active,
@@ -114,11 +114,16 @@
114
114
  }
115
115
  .teacher_layout_newlabo {
116
116
  top: 50px;
117
- right: 0;
118
- }
117
+ right: 0;
118
+ .top{
119
+ svg{
120
+ transform: rotate(180deg);
121
+ }
122
+ }
123
+ }
119
124
  .teacher_layout_modal {
120
125
  width: 328px;
121
- height: 100%;
126
+ height: calc(100% - 48px);
122
127
  background-color: #fff;
123
128
  position: absolute;
124
129
  border-top: 1px solid @color-border-secondary;
@@ -151,10 +156,10 @@
151
156
  border-radius: 26px;
152
157
  background-color: #f4523b;
153
158
  color: #fff;
154
- padding: 2px 5px;
159
+ padding: 0 5px;
155
160
  border-radius: 25px;
156
161
  font-size: 12px;
157
- line-height: 1.2;
162
+ line-height: 1;
158
163
  }
159
164
 
160
165
  .time {
@@ -175,9 +180,23 @@
175
180
  }
176
181
  }
177
182
  .active {
178
- background: var(--color-background-primary-weak, #fff4f0);
183
+ background: @color-background-primary-weak-hover;
179
184
  }
180
185
  }
186
+ .bottom{
187
+ overflow: auto;
188
+ height: calc(100% - 70px);
189
+ }
190
+ .bottom::-webkit-scrollbar {
191
+ background-color: #eaedf1;
192
+ background-color: transparent;
193
+ width: 4px;
194
+ height: 4px;
195
+ }
196
+ .bottom::-webkit-scrollbar-thumb {
197
+ border-radius: 4px;
198
+ background-color: rgba(0, 0, 0, 0.25);
199
+ }
181
200
 
182
201
  :global {
183
202
  .anticon {
@@ -51,19 +51,24 @@ var copyText = function(text) {
51
51
  };
52
52
  //获取当前时间
53
53
  var getDataTime = function(time) {
54
- var currentDate;
55
- if (time != undefined && time != -1) {
56
- currentDate = new Date(time);
57
- } else {
58
- currentDate = new Date();
54
+ try {
55
+ var now;
56
+ if (time != undefined && time != -1) {
57
+ now = new Date(time);
58
+ } else {
59
+ now = new Date();
60
+ }
61
+ // const now = new Date();
62
+ var year = now.getFullYear();
63
+ var month = String(now.getMonth() + 1).padStart(2, "0");
64
+ var day = String(now.getDate()).padStart(2, "0");
65
+ var hours = String(now.getHours()).padStart(2, "0");
66
+ var minutes = String(now.getMinutes()).padStart(2, "0");
67
+ var seconds = String(now.getSeconds()).padStart(2, "0");
68
+ var currentDateTime = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
69
+ return currentDateTime;
70
+ } catch (error) {
71
+ return "";
59
72
  }
60
- var currentYear = currentDate.getFullYear();
61
- var currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
62
- var currentDay = currentDate.getDate();
63
- var hour = currentDate.getHours();
64
- var minute = currentDate.getMinutes();
65
- var second = currentDate.getSeconds();
66
- var dataTime = currentYear + "-" + currentMonth + "-" + currentDay + " " + hour + ":" + minute + ":" + second;
67
- return dataTime;
68
73
  };
69
74
  export { readMessage, getByteLen, serverUrl, copyText, getDataTime };
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import "highlight.js/styles/default.css";
2
3
  interface data {
3
4
  type: number;
4
5
  roomId: String | number;
@@ -7,7 +8,7 @@ interface data {
7
8
  urllocation: String;
8
9
  onClose: any;
9
10
  loadSpecifiedData: any;
10
- roomList: [];
11
+ roomList: any;
11
12
  }
12
13
  declare const HistoryFun: (props: data) => JSX.Element;
13
14
  export default HistoryFun;