bhd-components 0.7.20 → 0.7.22

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.
@@ -431,6 +431,10 @@
431
431
  }
432
432
  }
433
433
 
434
+ .find_teacher_con{
435
+ color: @color-text-primary;
436
+ cursor: pointer;
437
+ }
434
438
  }
435
439
  .sign{
436
440
  background-color: #1890ff;
@@ -1874,7 +1878,16 @@
1874
1878
  }
1875
1879
  }
1876
1880
  }
1877
-
1881
+ //老师列表
1882
+ .teacher_list{
1883
+ .name{
1884
+ margin-bottom: 0!important;
1885
+ font-weight: 400 !important;
1886
+ .sign{
1887
+ color: @color-text-primary;
1888
+ }
1889
+ }
1890
+ }
1878
1891
  //截图功能
1879
1892
  .screenshot_Modal{
1880
1893
  position: fixed;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ interface data {
3
+ type: number;
4
+ userData: any;
5
+ http: any;
6
+ urllocation: String;
7
+ onClose: any;
8
+ enterTeacherChat: any;
9
+ }
10
+ declare const TeacherList: (props: data) => JSX.Element;
11
+ export default TeacherList;
@@ -0,0 +1,258 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
3
+ import React, { useEffect, useState, useRef } from "react";
4
+ import styles from "./index.module.less";
5
+ import { Input } from "antd";
6
+ import { CustomClose } from "../icons/index";
7
+ import { SearchOutlined } from "@ant-design/icons";
8
+ const TeacherList = (props)=>{
9
+ let { type , userData , http , urllocation , onClose , enterTeacherChat } = props;
10
+ const [keyWordProblem, setKeyWordProblem] = useState(""); //搜索内容
11
+ const [showLoadingState, setShowLoadingState] = useState(1); //1,初始状态,2、无数据 ,3、不显示图片
12
+ const [totalData, setTotalData] = useState([]); //总数据
13
+ // const [teacher_list, setTeacher_list] = useState([]); //老师列表,有头像
14
+ const teacher_list = useRef([]); //老师列表,有头像
15
+ const timer = useRef(null); //文本框输入时
16
+ const page = useRef(1);
17
+ const loading = useRef(true);
18
+ const sliderRef = useRef(null);
19
+ useEffect(()=>{
20
+ const handleScroll = (e)=>{
21
+ // 处理滚轮事件的逻辑
22
+ const container = document.getElementById("teacher_list");
23
+ const scrollTop = container.scrollTop;
24
+ const clientHeight = container.clientHeight;
25
+ const scrollHeight = container.scrollHeight;
26
+ if (scrollTop + clientHeight + 60 >= scrollHeight && loading.current) {
27
+ loading.current = false;
28
+ // console.log('加载下一页');
29
+ page.current = page.current + 1;
30
+ getList(keyWordProblem);
31
+ }
32
+ };
33
+ // 添加滚轮事件监听器
34
+ sliderRef.current.addEventListener('wheel', handleScroll);
35
+ // 清除滚轮事件监听器
36
+ return ()=>{
37
+ sliderRef.current.removeEventListener('wheel', handleScroll);
38
+ };
39
+ }, [
40
+ keyWordProblem
41
+ ]);
42
+ useEffect(()=>{
43
+ getList("");
44
+ return ()=>{
45
+ clearTimeout(timer.current);
46
+ };
47
+ }, []);
48
+ const getList = (val)=>{
49
+ if (page.current == 1) {
50
+ setTotalData([]);
51
+ }
52
+ http.get(`${urllocation}/chat-service/public/v1.0/teachers`, {
53
+ params: {
54
+ name: val,
55
+ page: page.current,
56
+ maxPageSize: 20
57
+ }
58
+ }).then((res)=>{
59
+ console.log(res);
60
+ if (res.data.total > 0) {
61
+ loading.current = true;
62
+ setShowLoadingState(3);
63
+ let data = new Map();
64
+ setTotalData((totalData)=>{
65
+ return totalData.concat(res.data.teachers).filter((a)=>!data.has(a.uid) && data.set(a.uid, 1));
66
+ });
67
+ getUserName(res.data.teachers);
68
+ } else {
69
+ loading.current = false;
70
+ if (page.current == 1) {
71
+ setShowLoadingState(2);
72
+ }
73
+ }
74
+ });
75
+ };
76
+ const getUserName = (dataList)=>{
77
+ try {
78
+ let list = dataList;
79
+ let ids = [];
80
+ list = list.map((item)=>{
81
+ if (!item.headImg && teacher_list.current.filter((v)=>v.uid == item.uid).length <= 0) {
82
+ ids.push(item.uid);
83
+ }
84
+ });
85
+ if (ids.length > 0) {
86
+ userName(ids.join(",")).then((res)=>{
87
+ if (res.data) {
88
+ let nameList = res.data;
89
+ setTotalData((list1)=>{
90
+ let list = list1;
91
+ list = list.map((item)=>{
92
+ let name = nameList.filter((v)=>v.uid == item.uid);
93
+ if (name.length > 0) {
94
+ return _object_spread({}, item, name[0]);
95
+ } else {
96
+ let nameList = teacher_list.current;
97
+ let name = nameList.filter((v)=>v.uid == item.uid);
98
+ if (name.length > 0) {
99
+ return _object_spread({}, item, name[0]);
100
+ } else {
101
+ return item;
102
+ }
103
+ }
104
+ });
105
+ let data = new Map();
106
+ teacher_list.current = teacher_list.current.concat(list).filter((a)=>!data.has(a.uid) && data.set(a.uid, 1));
107
+ return list;
108
+ });
109
+ }
110
+ });
111
+ } else {
112
+ let nameList = teacher_list.current;
113
+ setTotalData((list1)=>{
114
+ let list = list1;
115
+ list = list.map((item)=>{
116
+ let name = nameList.filter((v)=>v.uid == item.uid);
117
+ if (name.length > 0) {
118
+ return _object_spread({}, item, name[0]);
119
+ } else {
120
+ return item;
121
+ }
122
+ });
123
+ return list;
124
+ });
125
+ }
126
+ } catch (error) {}
127
+ };
128
+ const userName = (uid)=>{
129
+ return http.get(`${urllocation}/chat-service/public/v1.0/userinfo`, {
130
+ params: {
131
+ uid: uid
132
+ },
133
+ headers: {
134
+ "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
135
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
136
+ }
137
+ });
138
+ };
139
+ return /*#__PURE__*/ _jsx("div", {
140
+ className: `${styles.history_list} ${type == 2 ? styles.history_list_broadside : ""} ${styles.teacher_list}`,
141
+ children: /*#__PURE__*/ _jsxs("div", {
142
+ className: styles.search_layout,
143
+ children: [
144
+ /*#__PURE__*/ _jsxs("div", {
145
+ className: styles.title,
146
+ children: [
147
+ /*#__PURE__*/ _jsx("span", {
148
+ children: "召唤老师回答"
149
+ }),
150
+ /*#__PURE__*/ _jsx("span", {
151
+ onClick: ()=>{
152
+ // loadSpecifiedData();
153
+ onClose();
154
+ },
155
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
156
+ })
157
+ ]
158
+ }),
159
+ /*#__PURE__*/ _jsxs("div", {
160
+ className: styles.search_top,
161
+ children: [
162
+ /*#__PURE__*/ _jsx(SearchOutlined, {}),
163
+ /*#__PURE__*/ _jsx(Input, {
164
+ placeholder: "请输入您要召唤的老师姓名",
165
+ value: keyWordProblem,
166
+ onChange: (e)=>{
167
+ let val = String(e.target.value);
168
+ setKeyWordProblem(val);
169
+ clearTimeout(timer.current);
170
+ timer.current = setTimeout(()=>{
171
+ page.current = 1;
172
+ setTotalData([]);
173
+ getList(val);
174
+ }, 1000);
175
+ }
176
+ }),
177
+ /*#__PURE__*/ _jsx("i", {
178
+ className: "guanbi_Close",
179
+ onClick: ()=>{
180
+ setShowLoadingState(1);
181
+ setKeyWordProblem("");
182
+ setTotalData([]);
183
+ },
184
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
185
+ })
186
+ ]
187
+ }),
188
+ /*#__PURE__*/ _jsxs("div", {
189
+ className: styles.main_list,
190
+ id: "teacher_list",
191
+ children: [
192
+ showLoadingState == 1 && /*#__PURE__*/ _jsxs("div", {
193
+ className: styles.no_data,
194
+ children: [
195
+ /*#__PURE__*/ _jsx("img", {
196
+ src: "/new_yun/images/aiService/search_for_icon.png"
197
+ }),
198
+ /*#__PURE__*/ _jsx("p", {
199
+ children: "输入关键词,搜索老师姓名"
200
+ })
201
+ ]
202
+ }),
203
+ showLoadingState == 2 && /*#__PURE__*/ _jsxs("div", {
204
+ className: styles.no_data,
205
+ children: [
206
+ /*#__PURE__*/ _jsx("img", {
207
+ src: "/new_yun/images/aiService/no_data.png"
208
+ }),
209
+ /*#__PURE__*/ _jsx("p", {
210
+ children: "未搜索到老师"
211
+ })
212
+ ]
213
+ }),
214
+ /*#__PURE__*/ _jsx("div", {
215
+ className: styles.list_item,
216
+ ref: sliderRef,
217
+ children: totalData.map((item)=>{
218
+ let span = item.name.replaceAll(new RegExp(keyWordProblem, "ig"), (i)=>{
219
+ return `<span class=${styles.sign}>${i}</span>`;
220
+ });
221
+ return /*#__PURE__*/ _jsx(_Fragment, {
222
+ children: /*#__PURE__*/ _jsxs("div", {
223
+ className: `${styles.list_summary}`,
224
+ id: item.roomId,
225
+ onClick: ()=>{
226
+ enterTeacherChat(item);
227
+ },
228
+ children: [
229
+ /*#__PURE__*/ _jsx("div", {
230
+ className: styles.head_img,
231
+ children: /*#__PURE__*/ _jsx("img", {
232
+ src: item.headImg
233
+ })
234
+ }),
235
+ /*#__PURE__*/ _jsx("div", {
236
+ className: styles.list_desc,
237
+ children: /*#__PURE__*/ _jsx("p", {
238
+ className: styles.name,
239
+ style: {
240
+ width: "calc(100% - 36px)"
241
+ },
242
+ dangerouslySetInnerHTML: {
243
+ __html: span
244
+ }
245
+ })
246
+ })
247
+ ]
248
+ })
249
+ });
250
+ })
251
+ })
252
+ ]
253
+ })
254
+ ]
255
+ })
256
+ });
257
+ };
258
+ export default TeacherList;
@@ -4,19 +4,12 @@ import styles from "./index.module.less";
4
4
  import { Tooltip } from "antd";
5
5
  import { CustomAiIcon, CustomRetract } from "../icons/index";
6
6
  import { CloseOutlined } from "@ant-design/icons";
7
- import { getDataTime, getByteLen } from "./function"; //录音使用文件
7
+ import { getByteLen, formatDate } from "./function"; //录音使用文件
8
8
  var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
9
9
  var type = props.type, roomId = props.roomId, userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, switchChatRoom = props.switchChatRoom, contactsList = props.contactsList;
10
- // useImperativeHandle(ref, () => ({
11
- // roomsListTimer: () => {
12
- // return roomsListTimer();
13
- // },
14
- // roomsList:contactsList,
15
- // }),[contactsList]);
16
10
  //删除聊天室
17
11
  var deleteRoom = function(roomId) {
18
- http.delete("".concat(urllocation, "/chat-service/public/v1.0/rooms/").concat(roomId), {
19
- }).then(function(res) {
12
+ http.delete("".concat(urllocation, "/chat-service/public/v1.0/rooms/").concat(roomId), {}).then(function(res) {
20
13
  // roomsListTimer();
21
14
  switchChatRoom(roomId, "1");
22
15
  });
@@ -45,7 +38,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
45
38
  }) ? "AI助手" : "智能问答",
46
39
  /*#__PURE__*/ _jsx("span", {
47
40
  className: styles.time,
48
- children: contactsList.length > 0 && contactsList[0].createdAt != undefined && getDataTime(contactsList[0].createdAt)
41
+ children: contactsList.length > 0 && contactsList[0].createdAt != undefined && formatDate(contactsList[0].createdAt)
49
42
  })
50
43
  ]
51
44
  }),
@@ -60,18 +53,10 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
60
53
  }),
61
54
  userData.modules.some(function(item) {
62
55
  return item.short == "TeacherAnswer";
63
- }) ? /*#__PURE__*/ _jsx("div", {
56
+ }) && /*#__PURE__*/ _jsx("div", {
64
57
  className: styles.bottom,
65
58
  children: contactsList.map(function(item, index) {
66
59
  if (index != 0) {
67
- var time = "";
68
- var currentTime = getDataTime(-1, 1); //当前时间
69
- var updatedAt = getDataTime(item.createdAt, 1);
70
- if (currentTime == updatedAt) {
71
- time = getDataTime(item.createdAt, 2);
72
- } else {
73
- time = getDataTime(item.createdAt);
74
- }
75
60
  return /*#__PURE__*/ _jsxs("div", {
76
61
  className: "".concat(styles.ai, " ").concat(item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""),
77
62
  onClick: function() {
@@ -99,7 +84,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
99
84
  }),
100
85
  /*#__PURE__*/ _jsx("span", {
101
86
  className: styles.time,
102
- children: getDataTime(item.createdAt)
87
+ children: formatDate(item.createdAt)
103
88
  })
104
89
  ]
105
90
  }),
@@ -115,7 +100,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
115
100
  return null;
116
101
  }
117
102
  })
118
- }) : ""
103
+ })
119
104
  ]
120
105
  }) : /*#__PURE__*/ _jsxs("div", {
121
106
  className: "".concat(styles.teacher_layout, " ").concat(type == 3 ? styles.teacher_layout_newlabo : ""),
@@ -19,4 +19,6 @@ declare const getQuery: (name: string) => string;
19
19
  declare const findParent: (e: any, className: string) => any;
20
20
  declare const delegate: (element: any, eventType: string, selector: string, callback: any) => void;
21
21
  declare const getBase64Image: (src: any) => Promise<unknown>;
22
- export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image };
22
+ declare const formatDate: (dateStr: any) => any;
23
+ declare const urlToBase64: (url: string) => Promise<unknown>;
24
+ export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
@@ -137,4 +137,48 @@ var getBase64Image = function(src) {
137
137
  };
138
138
  });
139
139
  };
140
- export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image };
140
+ var formatDate = function(dateStr) {
141
+ var today = new Date();
142
+ var date = new Date(dateStr);
143
+ var dayDiff = Math.ceil((today - date) / (1000 * 60 * 60 * 24)); // 计算天数差
144
+ // console.log(dayDiff,'dayDiffdayDiff',today,'___',date);
145
+ if (dayDiff === 0 || dayDiff === 1) {
146
+ // 今天
147
+ return date.toLocaleTimeString("zh-CN", {
148
+ hour12: false
149
+ }).substring(0, 5);
150
+ } else if (dayDiff <= 7) {
151
+ // 一周内
152
+ return date.toLocaleString("zh-CN", {
153
+ weekday: "short"
154
+ }).replace("周", "星期");
155
+ } else {
156
+ // 超过一周
157
+ return date.toLocaleDateString("zh-CN");
158
+ }
159
+ };
160
+ var urlToBase64 = function(url) {
161
+ return new Promise(function(resolve) {
162
+ var image = new Image();
163
+ // 先设置图片跨域属性
164
+ image.crossOrigin = "Anonymous";
165
+ // 再给image赋值src属性,先后顺序不能颠倒
166
+ image.src = url;
167
+ image.onload = function() {
168
+ var canvas = document.createElement("CANVAS");
169
+ // 设置canvas宽高等于图片实际宽高
170
+ canvas.width = image.width;
171
+ canvas.height = image.height;
172
+ canvas.getContext("2d").drawImage(image, 0, 0);
173
+ // toDataUrl可以接收2个参数,参数一:图片类型,参数二: 图片质量0-1(不传默认为0.92)
174
+ var dataURL = canvas.toDataURL("image/jpeg");
175
+ resolve(dataURL);
176
+ };
177
+ image.onerror = function() {
178
+ resolve({
179
+ message: "相片处理失败"
180
+ });
181
+ };
182
+ });
183
+ };
184
+ export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
@@ -8,7 +8,7 @@ import "highlight.js/styles/default.css";
8
8
  import { Input } from "antd";
9
9
  import { CustomClose, CustomExpand, CustomAiIcon } from "../icons/index";
10
10
  import { SearchOutlined } from "@ant-design/icons";
11
- import { getDataTime } from "./function"; //录音使用文件
11
+ import { formatDate } from "./function"; //录音使用文件
12
12
  var HistoryFun = function(props) {
13
13
  var type = props.type, roomId = props.roomId, userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, loadSpecifiedData = props.loadSpecifiedData;
14
14
  var _useState = _sliced_to_array(useState(""), 2), keyWordProblem = _useState[0], setKeyWordProblem = _useState[1]; //搜索内容
@@ -56,13 +56,11 @@ var HistoryFun = function(props) {
56
56
  maxPageSize: maxPageSize
57
57
  }
58
58
  }).then(function(res) {
59
- console.log(res, 7777779999);
60
59
  var data = res.data;
61
60
  if (data.total > 0) {
62
61
  setShowLoadingState(3);
63
62
  var list = data.messageHistories;
64
63
  setPageCount(Math.ceil(data.total / maxPageSize));
65
- // setTotalData(totalData.concat(list));
66
64
  setTotalData(function(list1) {
67
65
  var new_list = list1;
68
66
  new_list = new_list.concat(list);
@@ -355,25 +353,23 @@ var HistoryFun = function(props) {
355
353
  var span = "";
356
354
  var time = "";
357
355
  if (item.count == 1) {
356
+ var message = item.message;
357
+ var position_i = message.indexOf(keyWordProblem);
358
+ if (position_i > 30) {
359
+ message = message.substring(position_i - 15);
360
+ }
358
361
  var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
359
362
  //搜索内容是否有特殊字符
360
363
  if (reg.test(keyWordProblem)) {
361
- span = item.message.replaceAll(keyWordProblem, function(e) {
364
+ span = message.replaceAll(keyWordProblem, function(e) {
362
365
  return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
363
366
  });
364
367
  } else {
365
- span = item.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
366
- // console.log(i,'skdcnsdjk')
368
+ span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
367
369
  return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
368
370
  });
369
371
  }
370
- var currentTime = getDataTime(-1, 1); //当前时间
371
- var createdAt = getDataTime(item.createdAt, 1);
372
- if (currentTime == createdAt) {
373
- time = getDataTime(item.createdAt, 2);
374
- } else {
375
- time = getDataTime(item.createdAt);
376
- }
372
+ time = formatDate(item.createdAt);
377
373
  }
378
374
  return /*#__PURE__*/ _jsxs(_Fragment, {
379
375
  children: [
@@ -440,23 +436,21 @@ var HistoryFun = function(props) {
440
436
  } else {
441
437
  name = userData.real_name;
442
438
  }
443
- var time = "";
444
- var currentTime = getDataTime(-1, 1); //当前时间
445
- var updatedAt = getDataTime(list.updatedAt, 1);
446
- if (currentTime == updatedAt) {
447
- time = getDataTime(list.updatedAt, 2);
448
- } else {
449
- time = getDataTime(list.updatedAt);
450
- }
439
+ var time = formatDate(list.updatedAt);
451
440
  var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
452
441
  var span = "";
442
+ var message = list.message;
443
+ var position_i = message.indexOf(keyWordProblem);
444
+ if (position_i > 30) {
445
+ message = message.substring(position_i - 15);
446
+ }
453
447
  //搜索内容是否有特殊字符
454
448
  if (reg.test(keyWordProblem)) {
455
- span = list.message.replaceAll(keyWordProblem, function(e) {
449
+ span = message.replaceAll(keyWordProblem, function(e) {
456
450
  return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
457
451
  });
458
452
  } else {
459
- span = list.message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
453
+ span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
460
454
  // console.log(i,'skdcnsdjk')
461
455
  return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
462
456
  });