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
@@ -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,26 +1,40 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
3
- import React, { useEffect, useState, useRef } from "react";
3
+ import React, { useEffect, useState, useRef, useImperativeHandle, forwardRef } from "react";
4
4
  import styles from "./index.module.less";
5
5
  import { CustomAiIcon, CustomRetract } from "../../icons/index";
6
6
  import { CloseOutlined } from "@ant-design/icons";
7
7
  import { getDataTime } from "../function"; //录音使用文件
8
- const ContactsList = (props)=>{
8
+ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
9
9
  let { type , roomId , userData , http , urllocation , onClose , switchChatRoom , saveContactsList } = props;
10
10
  const [contactsList, setContactsList] = useState([]); //老师列表
11
+ const [newRoomId, setNewRoomId] = useState("");
12
+ const [firstLoading, setFirstLoading] = useState(true);
13
+ // const [type,setType] = useState(0);
11
14
  let timer = useRef(null); //文本框输入时
12
15
  //获取聊天室列表
13
16
  useEffect(()=>{
14
- // if (roomId != "") {
15
17
  roomsListTimer();
16
- // }
18
+ if (roomId != '') {
19
+ setNewRoomId(roomId);
20
+ }
17
21
  return ()=>{
18
22
  clearTimeout(timer.current);
19
23
  };
20
24
  }, []);
25
+ useImperativeHandle(ref, ()=>({
26
+ roomsListTimer: ()=>{
27
+ return roomsListTimer();
28
+ }
29
+ }));
30
+ // useEffect(()=>{
31
+ // //重新调用接口
32
+ // console.log(44444444,contactsList)
33
+ // roomsListTimer();
34
+ // },[type])
21
35
  const roomsListTimer = ()=>{
22
36
  if (timer != null) clearTimeout(timer.current);
23
- timer.current = setTimeout(()=>roomsListTimer(), 100000);
37
+ timer.current = setTimeout(()=>roomsListTimer(), 60000);
24
38
  http.get(`${urllocation}/chat-service/public/v1.0/rooms`, {
25
39
  params: {
26
40
  page: 1,
@@ -33,52 +47,49 @@ const ContactsList = (props)=>{
33
47
  }).then((res)=>{
34
48
  if (res.data) {
35
49
  let list = res.data.contacts;
36
- // let list2 = list.slice(1);
37
- let list2 = list;
50
+ // let newMessage = false;
38
51
  setContactsList((contactsList)=>{
39
- if (contactsList.length > 0 && roomId != '') {
40
- //查找当前聊天室的未读消息
41
- let message = 0;
42
- let messageList = contactsList.filter((item)=>item.id == roomId);
43
- if (messageList.length > 0) {
44
- // console.log(messageList,'messagemessagemessage');
45
- message = messageList[0].unreadCount;
46
- }
47
- let new_message = 0;
48
- if (list.length > 0) {
49
- let new_message_list = list.filter((item)=>item.id == roomId);
50
- if (new_message_list.length > 0) {
51
- console.log(new_message_list, "new_messagenew_messagenew_messagenew_message");
52
- new_message = new_message_list[0].unreadCount;
53
- }
54
- }
55
- // console.log(message,new_message,'lsdlcksdcmsdlkc')
56
- //存在新消息
57
- if (message != new_message) {
58
- console.log("有新消息");
59
- switchChatRoom(roomId, "renew");
52
+ list = list.map((item, index)=>{
53
+ let c_list = contactsList.filter((e)=>e.sender == item.sender);
54
+ let obj = {};
55
+ if (c_list.length > 0) {
56
+ obj = c_list[0];
60
57
  }
61
- }
62
- list2 = list2.map((item, index)=>{
63
- // if(contactsList[index] != undefined){
64
- return _object_spread({}, item, contactsList[index] || "");
65
- // }else{
66
- // return item
67
- // }
58
+ return _object_spread({}, obj, item);
68
59
  });
69
- return list2;
70
- });
71
- console.log(list2, "list2list2list2list2");
72
- // setAi(res.data.contacts[0]);
73
- getUserInfo(list2);
74
- //切换到有聊天的窗口
75
- list2.forEach((ele)=>{
76
- console.log(ele);
77
- if (ele.unreadCount > 0) {
78
- switchChatRoom(ele.roomId, "");
79
- return;
80
- }
60
+ return list;
81
61
  });
62
+ getUserInfo(list);
63
+ // if(firstLoading){
64
+ // setFirstLoading(false);
65
+ // let isRoom = false;
66
+ // for (let index = 0; index < list.length; index++) {
67
+ // let count = list[index].unreadCount;
68
+ // if(count > 0 && list[index].roomId == roomId){
69
+ // isRoom = true;
70
+ // //在当前窗口
71
+ // return null;
72
+ // }else if(count > 0){
73
+ // isRoom = true;
74
+ // switchChatRoom(list[index].roomId, "");
75
+ // setContactsList((contactsList)=>{
76
+ // let new_list = contactsList;
77
+ // new_list = new_list.map((item)=>{
78
+ // if(item.roomId == list[index].roomId){
79
+ // return {
80
+ // ...item,
81
+ // unreadCount:0,
82
+ // }
83
+ // }else{
84
+ // return item;
85
+ // }
86
+ // })
87
+ // return new_list;
88
+ // })
89
+ // return null;
90
+ // }
91
+ // }
92
+ // }
82
93
  saveContactsList(list);
83
94
  }
84
95
  });
@@ -91,14 +102,22 @@ const ContactsList = (props)=>{
91
102
  "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
92
103
  }
93
104
  }).then((res)=>{
94
- console.log(res, "sdcsdcsdc");
95
- // roomsList();
96
105
  roomsListTimer();
106
+ // let contactsList;
107
+ // setContactsList((list)=>{
108
+ // contactsList = list.filter(e=>e.roomId != roomId);
109
+ // //切换到AI聊天窗口
110
+ // if(roomId == props.roomId){
111
+ // switchChatRoom(contactsList[0].roomId, "");
112
+ // }
113
+ // return contactsList;
114
+ // })
115
+ // saveContactsList(contactsList);
97
116
  });
98
117
  };
99
118
  //获取老师的信息等
100
- const getUserInfo = (list2)=>{
101
- list2.map((item, i)=>{
119
+ const getUserInfo = (list)=>{
120
+ list.map((item, i)=>{
102
121
  if (!item.name && !item.headImg && item.sender != 'AI') {
103
122
  getUserName(item.sender).then((res)=>{
104
123
  if (res.data) {
@@ -130,34 +149,6 @@ const ContactsList = (props)=>{
130
149
  }
131
150
  });
132
151
  };
133
- // //获取当前时间
134
- // const getDataTime = (time: string | number | Date) => {
135
- // let currentDate;
136
- // if (time != undefined && time != -1) {
137
- // currentDate = new Date(time);
138
- // } else {
139
- // currentDate = new Date();
140
- // }
141
- // const currentYear = currentDate.getFullYear();
142
- // const currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
143
- // const currentDay = currentDate.getDate();
144
- // const hour = currentDate.getHours();
145
- // const minute = currentDate.getMinutes();
146
- // const second = currentDate.getSeconds();
147
- // let dataTime =
148
- // currentYear +
149
- // "-" +
150
- // currentMonth +
151
- // "-" +
152
- // currentDay +
153
- // " " +
154
- // hour +
155
- // ":" +
156
- // minute +
157
- // ":" +
158
- // second;
159
- // return dataTime;
160
- // };
161
152
  return type == 2 || type == 4 ? //联系人展开
162
153
  /*#__PURE__*/ _jsxs("div", {
163
154
  className: styles.teacher_layout_modal,
@@ -165,9 +156,11 @@ const ContactsList = (props)=>{
165
156
  /*#__PURE__*/ _jsx("div", {
166
157
  className: styles.top,
167
158
  children: /*#__PURE__*/ _jsxs("div", {
168
- className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId ? styles.active : ""}`,
159
+ className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
169
160
  onClick: ()=>{
161
+ setNewRoomId(contactsList[0].roomId);
170
162
  switchChatRoom(contactsList[0].roomId, "");
163
+ roomsListTimer();
171
164
  },
172
165
  children: [
173
166
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -193,14 +186,16 @@ const ContactsList = (props)=>{
193
186
  ]
194
187
  })
195
188
  }),
196
- /*#__PURE__*/ _jsx("div", {
189
+ userData.modules.some((item)=>item.short == "TeacherAnswer") ? /*#__PURE__*/ _jsx("div", {
197
190
  className: styles.bottom,
198
191
  children: contactsList.map((item, index)=>{
199
192
  if (index != 0) {
200
193
  return /*#__PURE__*/ _jsxs("div", {
201
194
  className: `${styles.ai} ${item.roomId != undefined && roomId != '' && item.roomId == roomId ? styles.active : ""}`,
202
195
  onClick: ()=>{
196
+ setNewRoomId(item.roomId);
203
197
  switchChatRoom(item.roomId, "");
198
+ roomsListTimer();
204
199
  },
205
200
  children: [
206
201
  /*#__PURE__*/ _jsx("img", {
@@ -213,9 +208,9 @@ const ContactsList = (props)=>{
213
208
  className: styles.message,
214
209
  children: [
215
210
  item.name,
216
- item.unreadCount != undefined && item.unreadCount > 0 && /*#__PURE__*/ _jsx("span", {
211
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != '' && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
217
212
  className: styles.num,
218
- children: item.unreadCount
213
+ children: item.unreadCount > 99 ? '99+' : item.unreadCount
219
214
  }),
220
215
  /*#__PURE__*/ _jsx("span", {
221
216
  className: styles.time,
@@ -235,7 +230,7 @@ const ContactsList = (props)=>{
235
230
  return null;
236
231
  }
237
232
  })
238
- })
233
+ }) : ''
239
234
  ]
240
235
  }) : /*#__PURE__*/ _jsxs("div", {
241
236
  className: `${styles.teacher_layout} ${type == 3 ? styles.teacher_layout_newlabo : ""}`,
@@ -254,14 +249,19 @@ const ContactsList = (props)=>{
254
249
  children: [
255
250
  /*#__PURE__*/ _jsx(CustomRetract, {}),
256
251
  /*#__PURE__*/ _jsx("p", {
252
+ style: {
253
+ marginTop: '8px'
254
+ },
257
255
  children: "收起"
258
256
  })
259
257
  ]
260
258
  }),
261
259
  /*#__PURE__*/ _jsxs("div", {
262
- className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId ? styles.active : ""}`,
260
+ className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != '' && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
263
261
  onClick: ()=>{
262
+ setNewRoomId(contactsList[0].roomId);
264
263
  switchChatRoom(contactsList[0].roomId, "");
264
+ roomsListTimer();
265
265
  },
266
266
  children: [
267
267
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
@@ -272,14 +272,16 @@ const ContactsList = (props)=>{
272
272
  })
273
273
  ]
274
274
  }),
275
- /*#__PURE__*/ _jsx("div", {
275
+ userData.modules.some((item)=>item.short == "TeacherAnswer") && /*#__PURE__*/ _jsx("div", {
276
276
  className: styles.bottom,
277
277
  children: contactsList.map((item, index)=>{
278
278
  if (index != 0) {
279
279
  return /*#__PURE__*/ _jsxs("div", {
280
280
  className: `${styles.ai} ${item.roomId != undefined && roomId != '' && item.roomId == roomId ? styles.active : ""}`,
281
281
  onClick: ()=>{
282
+ setNewRoomId(item.roomId);
282
283
  switchChatRoom(item.roomId, "");
284
+ roomsListTimer();
283
285
  },
284
286
  children: [
285
287
  /*#__PURE__*/ _jsx("img", {
@@ -288,11 +290,12 @@ const ContactsList = (props)=>{
288
290
  /*#__PURE__*/ _jsx("p", {
289
291
  children: item.name
290
292
  }),
291
- item.unreadCount != undefined && item.unreadCount > 0 && /*#__PURE__*/ _jsx("span", {
293
+ item.unreadCount != undefined && item.unreadCount > 0 && !(item.roomId != undefined && roomId != '' && item.roomId == roomId) && /*#__PURE__*/ _jsx("span", {
292
294
  className: styles.num,
293
- children: item.unreadCount
295
+ children: item.unreadCount > 99 ? '99+' : item.unreadCount
294
296
  }),
295
- /*#__PURE__*/ _jsx("span", {
297
+ // 没有消息时,可点击删除
298
+ !item.unreadCount && /*#__PURE__*/ _jsx("span", {
296
299
  className: styles.delete,
297
300
  onClick: (e)=>{
298
301
  e.stopPropagation();
@@ -309,5 +312,5 @@ const ContactsList = (props)=>{
309
312
  })
310
313
  ]
311
314
  });
312
- };
315
+ });
313
316
  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 {
@@ -49,19 +49,24 @@ const copyText = (text)=>{
49
49
  };
50
50
  //获取当前时间
51
51
  const getDataTime = (time)=>{
52
- let currentDate;
53
- if (time != undefined && time != -1) {
54
- currentDate = new Date(time);
55
- } else {
56
- currentDate = new Date();
52
+ try {
53
+ let now;
54
+ if (time != undefined && time != -1) {
55
+ now = new Date(time);
56
+ } else {
57
+ now = new Date();
58
+ }
59
+ // const now = new Date();
60
+ const year = now.getFullYear();
61
+ const month = String(now.getMonth() + 1).padStart(2, "0");
62
+ const day = String(now.getDate()).padStart(2, "0");
63
+ const hours = String(now.getHours()).padStart(2, "0");
64
+ const minutes = String(now.getMinutes()).padStart(2, "0");
65
+ const seconds = String(now.getSeconds()).padStart(2, "0");
66
+ const currentDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
67
+ return currentDateTime;
68
+ } catch (error) {
69
+ return '';
57
70
  }
58
- const currentYear = currentDate.getFullYear();
59
- const currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
60
- const currentDay = currentDate.getDate();
61
- const hour = currentDate.getHours();
62
- const minute = currentDate.getMinutes();
63
- const second = currentDate.getSeconds();
64
- let dataTime = currentYear + "-" + currentMonth + "-" + currentDay + " " + hour + ":" + minute + ":" + second;
65
- return dataTime;
66
71
  };
67
72
  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;