bhd-components 0.6.5 → 0.6.7

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 (29) hide show
  1. package/dist/{8bda9e2e.esm.es5.production.js → 0acf50ef.esm.es5.production.js} +1 -1
  2. package/dist/{d4259367.esm.es5.development.js → 4fa3313f.esm.es5.development.js} +1402 -1140
  3. package/dist/index.esm.es5.development.css +864 -732
  4. package/dist/index.esm.es5.development.js +945 -780
  5. package/dist/index.esm.es5.production.css +1 -1
  6. package/dist/index.esm.es5.production.js +1 -1
  7. package/es2017/customerService/contactsList.d.ts +1 -1
  8. package/es2017/customerService/contactsList.js +11 -145
  9. package/es2017/customerService/function.js +20 -13
  10. package/es2017/customerService/historyFun.js +334 -154
  11. package/es2017/customerService/index.js +567 -437
  12. package/es2017/customerService/index.module.less +169 -65
  13. package/es2017/customerService/index2.module.less +170 -65
  14. package/es2017/icons/components/custom-expand.d.ts +4 -0
  15. package/es2017/icons/components/custom-expand.js +22 -0
  16. package/es2017/icons/components/index.d.ts +1 -0
  17. package/es2017/icons/components/index.js +1 -0
  18. package/esm/customerService/contactsList.d.ts +1 -1
  19. package/esm/customerService/contactsList.js +11 -158
  20. package/esm/customerService/function.js +20 -13
  21. package/esm/customerService/historyFun.js +338 -167
  22. package/esm/customerService/index.js +557 -445
  23. package/esm/customerService/index.module.less +169 -65
  24. package/esm/customerService/index2.module.less +170 -65
  25. package/esm/icons/components/custom-expand.d.ts +4 -0
  26. package/esm/icons/components/custom-expand.js +24 -0
  27. package/esm/icons/components/index.d.ts +1 -0
  28. package/esm/icons/components/index.js +1 -0
  29. package/package.json +1 -1
@@ -7,7 +7,7 @@ interface data {
7
7
  urllocation: String;
8
8
  onClose: any;
9
9
  switchChatRoom: any;
10
- saveContactsList: any;
10
+ contactsList: any;
11
11
  ref: any;
12
12
  }
13
13
  declare const ContactsList: import("react").ForwardRefExoticComponent<Omit<data, "ref"> & import("react").RefAttributes<unknown>>;
@@ -1,116 +1,24 @@
1
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
1
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
4
- import React, { useEffect, useState, useRef, useImperativeHandle, forwardRef } from "react";
2
+ import React, { forwardRef } from "react";
5
3
  import styles from "./index.module.less";
6
4
  import { Tooltip } from "antd";
7
5
  import { CustomAiIcon, CustomRetract } from "../icons/index";
8
6
  import { CloseOutlined } from "@ant-design/icons";
9
7
  import { getDataTime, getByteLen } from "./function"; //录音使用文件
10
8
  const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
11
- let { type , roomId , userData , http , urllocation , onClose , switchChatRoom , saveContactsList } = props;
12
- const [contactsList, setContactsList] = useState([]); //老师列表
13
- let timer = useRef(null); //文本框输入时
14
- //获取聊天室列表
15
- useEffect(()=>{
16
- roomsListTimer();
17
- return ()=>{
18
- clearTimeout(timer.current);
19
- };
20
- }, []);
21
- // //获取聊天室列表
22
- // useEffect(() => {
23
- // roomsListTimer();
24
- // }, [contactsList]);
25
- useImperativeHandle(ref, ()=>({
26
- roomsListTimer: ()=>{
27
- return roomsListTimer();
28
- }
29
- }));
30
- const roomsListTimer = ()=>{
31
- if (timer != null) clearTimeout(timer.current);
32
- timer.current = setTimeout(()=>roomsListTimer(), 60000);
33
- http.get(`${urllocation}/chat-service/public/v1.0/rooms`, {
34
- params: {
35
- page: 1,
36
- maxPageSize: 100002
37
- },
38
- headers: {
39
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
40
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
41
- }
42
- }).then((res)=>{
43
- if (res.data) {
44
- let list = res.data.contacts;
45
- setContactsList((contactsList)=>{
46
- list = list.map((item, index)=>{
47
- let c_list = contactsList.filter((e)=>e.sender == item.sender);
48
- let obj = {};
49
- if (c_list.length > 0) {
50
- obj = c_list[0];
51
- }
52
- return _object_spread({}, obj, item);
53
- });
54
- return list;
55
- });
56
- getUserInfo(list);
57
- saveContactsList(list);
58
- }
59
- });
60
- };
9
+ let { type , roomId , userData , http , urllocation , onClose , switchChatRoom , contactsList } = props;
10
+ // useImperativeHandle(ref, () => ({
11
+ // roomsListTimer: () => {
12
+ // return roomsListTimer();
13
+ // },
14
+ // roomsList:contactsList,
15
+ // }),[contactsList]);
61
16
  //删除聊天室
62
17
  const deleteRoom = (roomId)=>{
63
- let contactsList;
64
- setContactsList((list)=>{
65
- contactsList = list.filter((e)=>e.roomId != roomId);
66
- //切换到AI聊天窗口
67
- if (roomId == props.roomId) {
68
- switchChatRoom(contactsList[0].roomId, "");
69
- }
70
- saveContactsList(contactsList);
71
- return contactsList;
72
- });
73
18
  http.delete(`${urllocation}/chat-service/public/v1.0/rooms/${roomId}`, {
74
- headers: {
75
- "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
76
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
77
- }
78
19
  }).then((res)=>{
79
- roomsListTimer();
80
- });
81
- };
82
- //获取老师的信息等
83
- const getUserInfo = (list)=>{
84
- list.map((item, i)=>{
85
- if (!item.name && !item.headImg && item.sender != "AI") {
86
- getUserName(item.sender).then((res)=>{
87
- if (res.data) {
88
- let list;
89
- setContactsList((contactsList)=>{
90
- list = contactsList.map((item, index)=>{
91
- if (item.sender == res.data.uid) {
92
- return _object_spread({}, item, res.data);
93
- } else {
94
- return item;
95
- }
96
- });
97
- return list;
98
- });
99
- saveContactsList(list);
100
- }
101
- });
102
- }
103
- });
104
- };
105
- const getUserName = (uid)=>{
106
- return http.get(`${urllocation}/chat-service/public/v1.0/userinfo`, {
107
- params: {
108
- uid: uid
109
- },
110
- headers: {
111
- "x-module-id": userData.modules.find((ele)=>ele.short == "TeacherAnswer").id,
112
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
113
- }
20
+ // roomsListTimer();
21
+ switchChatRoom(roomId, '1');
114
22
  });
115
23
  };
116
24
  return type == 2 || type == 4 ? //联系人展开
@@ -121,10 +29,7 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
121
29
  className: styles.top,
122
30
  children: /*#__PURE__*/ _jsxs("div", {
123
31
  className: `${styles.ai} ${contactsList.length > 0 && contactsList[0].roomId != undefined && roomId != "" && contactsList[0].roomId == roomId || contactsList.length == 0 ? styles.active : ""}`,
124
- onClick: ()=>{
125
- switchChatRoom(contactsList[0].roomId, "");
126
- // roomsListTimer();
127
- },
32
+ onClick: ()=>switchChatRoom(contactsList[0].roomId, ""),
128
33
  children: [
129
34
  /*#__PURE__*/ _jsx(CustomAiIcon, {}),
130
35
  /*#__PURE__*/ _jsxs("div", {
@@ -165,25 +70,6 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
165
70
  className: `${styles.ai} ${item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""}`,
166
71
  onClick: ()=>{
167
72
  switchChatRoom(item.roomId, "");
168
- // roomsListTimer();
169
- let newList = [];
170
- setContactsList((list)=>{
171
- newList = list;
172
- newList = newList.map((v)=>{
173
- if (v.roomId == item.roomId) {
174
- return _object_spread_props(_object_spread({}, v), {
175
- unreadCount: 0
176
- });
177
- } else {
178
- return v;
179
- }
180
- });
181
- return newList;
182
- });
183
- // console.log(newList,9999999999)
184
- setTimeout(()=>{
185
- saveContactsList(newList);
186
- }, 100);
187
73
  },
188
74
  children: [
189
75
  /*#__PURE__*/ _jsx("img", {
@@ -272,26 +158,6 @@ const ContactsList = /*#__PURE__*/ forwardRef((props, ref)=>{
272
158
  className: `${styles.ai} ${item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""}`,
273
159
  onClick: ()=>{
274
160
  switchChatRoom(item.roomId, "");
275
- // roomsListTimer();
276
- //消息更改为已读
277
- let newList = [];
278
- setContactsList((list)=>{
279
- newList = list;
280
- newList = newList.map((v)=>{
281
- if (v.roomId == item.roomId) {
282
- return _object_spread_props(_object_spread({}, v), {
283
- unreadCount: 0
284
- });
285
- } else {
286
- return v;
287
- }
288
- });
289
- return newList;
290
- });
291
- // console.log(newList,9999999999)
292
- setTimeout(()=>{
293
- saveContactsList(newList);
294
- }, 100);
295
161
  },
296
162
  children: [
297
163
  /*#__PURE__*/ _jsx("img", {
@@ -32,19 +32,26 @@ const serverUrl = ()=>{
32
32
  };
33
33
  //复制内容
34
34
  const copyText = (text)=>{
35
- // text是复制文本
36
- // 创建input元素
37
- const el = document.createElement("input");
38
- // 给input元素赋值需要复制的文本
39
- el.setAttribute("value", text);
40
- // 将input元素插入页面
41
- document.body.appendChild(el);
42
- // 选中input元素的文本
43
- el.select();
44
- // 复制内容到剪贴板
35
+ // // text是复制文本
36
+ // // 创建input元素
37
+ // const el = document.createElement("textarea");
38
+ // // 给input元素赋值需要复制的文本
39
+ // el.setAttribute("value", text);
40
+ // // 将input元素插入页面
41
+ // document.body.appendChild(el);
42
+ // // 选中input元素的文本
43
+ // el.select();
44
+ // // 复制内容到剪贴板
45
+ // document.execCommand("copy");
46
+ // // 删除input元素
47
+ // document.body.removeChild(el);
48
+ // return true;
49
+ var tempInput = document.createElement("textarea");
50
+ document.body.appendChild(tempInput);
51
+ tempInput.value = text;
52
+ tempInput.select();
45
53
  document.execCommand("copy");
46
- // 删除input元素
47
- document.body.removeChild(el);
54
+ document.body.removeChild(tempInput);
48
55
  return true;
49
56
  };
50
57
  //获取当前时间
@@ -65,7 +72,7 @@ const getDataTime = (time, type = -1)=>{
65
72
  const hours = String(now.getHours()).padStart(2, "0");
66
73
  const minutes = String(now.getMinutes()).padStart(2, "0");
67
74
  const seconds = String(now.getSeconds()).padStart(2, "0");
68
- const currentDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
75
+ const currentDateTime = `${year}-${month}-${day} ${hours}:${minutes}`;
69
76
  if (type == 1) {
70
77
  return `${year}-${month}-${day}`;
71
78
  } else if (type == 2) {