bhd-components 0.9.11 → 0.9.13

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.
@@ -1,5 +1,5 @@
1
- import { z as zhCN, A as App, _ as _object_spread, a as AntdMessage, M as Modal$1, b as AntdNotification, C as ConfigProvider, c as _extends, d as _object_destructuring_empty, j as jsx, e as _object_spread_props, f as jsxs, t as transform, S as StyleProvider, g as _sliced_to_array, T as Tooltip, h as Table$2, I as Icon, E as ExclamationCircleFilled, i as _to_consumable_array, P as Pagination$1, k as Select, l as CaretDownOutlined, m as _inherits, n as _create_super, o as _create_class, p as _class_call_check, q as _define_property, r as _assert_this_initialized, s as _async_to_generator, L as LeftOutlined, R as RightOutlined, u as MinusOutlined, v as PlusOutlined, w as __generator, x as Input, y as SearchOutlined, B as CloseOutlined, X, D as I, H, F as html2canvas$1, G as Remarkable, J as Drawer, K as HighlightJS, Z as ZoomInOutlined, N as DatePicker, O as Button } from './vendor.esm.es5.development.js';
2
- export { Q as Affix, U as Alert, V as Anchor, a as AntdMessage, A as App, W as AutoComplete, Y as Avatar, a0 as BackTop, a1 as Badge, a2 as Breadcrumb, O as Button, a3 as Calendar, a4 as Card, a5 as Carousel, a6 as Cascader, a7 as Checkbox, a8 as Col, a9 as Collapse, N as DatePicker, aa as Descriptions, ab as Divider, J as Drawer, ac as Dropdown, ad as Empty, $ as FloatButton, ae as Form, af as Grid, ag as Image, x as Input, ah as InputNumber, ai as Layout, aj as List, ak as Mentions, al as Menu, M as Modal, am as Popconfirm, an as Popover, ao as Progress, aN as QRCode, ap as Radio, aq as Rate, ar as Result, as as Row, at as Segmented, k as Select, au as Skeleton, av as Slider, aw as Space, ax as Spin, ay as Statistic, az as Steps, aA as Switch, aB as Tabs, aC as Tag, aE as TimePicker, aF as Timeline, T as Tooltip, aG as Tour, aH as Transfer, aI as Tree, aJ as TreeSelect, aK as Typography, aL as Upload, aM as Watermark, aP as en_US, b as notification, aD as theme, aO as version, z as zh_CN } from './vendor.esm.es5.development.js';
1
+ import { z as zhCN, A as App, _ as _object_spread, a as AntdMessage, M as Modal$1, b as AntdNotification, C as ConfigProvider, c as _extends, d as _object_destructuring_empty, j as jsx, e as _object_spread_props, f as jsxs, t as transform, S as StyleProvider, g as _sliced_to_array, T as Tooltip, h as Table$2, I as Icon, E as ExclamationCircleFilled, i as _to_consumable_array, P as Pagination$1, k as Select, l as CaretDownOutlined, m as _inherits, n as _create_super, o as _create_class, p as _class_call_check, q as _define_property, r as _assert_this_initialized, s as _async_to_generator, L as LeftOutlined, R as RightOutlined, u as MinusOutlined, v as PlusOutlined, w as __generator, x as Input, y as SearchOutlined, B as Spin, D as CloseOutlined, X, F as I, H, G as html2canvas$1, J as Remarkable, K as Drawer, N as HighlightJS, Z as ZoomInOutlined, O as DatePicker, Q as Button } from './vendor.esm.es5.development.js';
2
+ export { U as Affix, V as Alert, W as Anchor, a as AntdMessage, A as App, Y as AutoComplete, $ as Avatar, a1 as BackTop, a2 as Badge, a3 as Breadcrumb, Q as Button, a4 as Calendar, a5 as Card, a6 as Carousel, a7 as Cascader, a8 as Checkbox, a9 as Col, aa as Collapse, O as DatePicker, ab as Descriptions, ac as Divider, K as Drawer, ad as Dropdown, ae as Empty, a0 as FloatButton, af as Form, ag as Grid, ah as Image, x as Input, ai as InputNumber, aj as Layout, ak as List, al as Mentions, am as Menu, M as Modal, an as Popconfirm, ao as Popover, ap as Progress, aN as QRCode, aq as Radio, ar as Rate, as as Result, at as Row, au as Segmented, k as Select, av as Skeleton, aw as Slider, ax as Space, B as Spin, ay as Statistic, az as Steps, aA as Switch, aB as Tabs, aC as Tag, aE as TimePicker, aF as Timeline, T as Tooltip, aG as Tour, aH as Transfer, aI as Tree, aJ as TreeSelect, aK as Typography, aL as Upload, aM as Watermark, aP as en_US, b as notification, aD as theme, aO as version, z as zh_CN } from './vendor.esm.es5.development.js';
3
3
  import * as React from 'react';
4
4
  import React__default, { useState, useRef, useEffect, useLayoutEffect, forwardRef, useImperativeHandle, useCallback } from 'react';
5
5
  import { Fragment } from 'react/jsx-runtime';
@@ -2396,7 +2396,7 @@ var BhdSelect = function(props) {
2396
2396
  BhdSelect.Option = Select.Option;
2397
2397
  var BhdSelect$1 = BhdSelect;
2398
2398
 
2399
- var modules_63b47c51$2 = {"bhd_app_layout":"index_module_bhd_app_layout__a547e666","bhd_app_layout_header":"index_module_bhd_app_layout_header__a547e666","bhd_app_layout_main":"index_module_bhd_app_layout_main__a547e666","bhd_app_layout_main_filter":"index_module_bhd_app_layout_main_filter__a547e666","bhd_app_layout_main_filter_title":"index_module_bhd_app_layout_main_filter_title__a547e666","bhd_app_layout_main_filter_ul":"index_module_bhd_app_layout_main_filter_ul__a547e666","bhd_app_layout_main_filter_show_value":"index_module_bhd_app_layout_main_filter_show_value__a547e666","bhd_app_layout_main_filter_clear":"index_module_bhd_app_layout_main_filter_clear__a547e666","bhd_app_layout_main_table":"index_module_bhd_app_layout_main_table__a547e666","bhd_app_layout_footer":"index_module_bhd_app_layout_footer__a547e666"};
2399
+ var modules_63b47c51$2 = {"bhd_app_layout":"index_module_bhd_app_layout__6a2d2320","bhd_app_layout_header":"index_module_bhd_app_layout_header__6a2d2320","bhd_app_layout_main":"index_module_bhd_app_layout_main__6a2d2320","bhd_app_layout_main_filter":"index_module_bhd_app_layout_main_filter__6a2d2320","bhd_app_layout_main_filter_title":"index_module_bhd_app_layout_main_filter_title__6a2d2320","bhd_app_layout_main_filter_ul":"index_module_bhd_app_layout_main_filter_ul__6a2d2320","bhd_app_layout_main_filter_show_value":"index_module_bhd_app_layout_main_filter_show_value__6a2d2320","bhd_app_layout_main_filter_clear":"index_module_bhd_app_layout_main_filter_clear__6a2d2320","bhd_app_layout_main_table":"index_module_bhd_app_layout_main_table__6a2d2320","bhd_app_layout_footer":"index_module_bhd_app_layout_footer__6a2d2320"};
2400
2400
 
2401
2401
  function BhdAppLayout(props) {
2402
2402
  var _filterRef_current, _filterRef, _headRef_current, _headRef, _otherHeadRef_current, _otherHeadRef, _otherContentRef_current, _otherContentRef, _filterConfig, _filterConfig1, _footerConfig;
@@ -2665,15 +2665,40 @@ var formatDate = function(dateStr) {
2665
2665
  return date.toLocaleDateString("zh-CN");
2666
2666
  }
2667
2667
  };
2668
+ var urlToBase64 = function(url) {
2669
+ return new Promise(function(resolve) {
2670
+ var image = new Image();
2671
+ // 先设置图片跨域属性
2672
+ image.crossOrigin = "Anonymous";
2673
+ // 再给image赋值src属性,先后顺序不能颠倒
2674
+ image.src = url;
2675
+ image.onload = function() {
2676
+ var canvas = document.createElement("CANVAS");
2677
+ // 设置canvas宽高等于图片实际宽高
2678
+ canvas.width = image.width;
2679
+ canvas.height = image.height;
2680
+ canvas.getContext("2d").drawImage(image, 0, 0);
2681
+ // toDataUrl可以接收2个参数,参数一:图片类型,参数二: 图片质量0-1(不传默认为0.92)
2682
+ var dataURL = canvas.toDataURL("image/jpeg");
2683
+ resolve(dataURL);
2684
+ };
2685
+ image.onerror = function() {
2686
+ resolve({
2687
+ message: "相片处理失败"
2688
+ });
2689
+ };
2690
+ });
2691
+ };
2668
2692
 
2669
2693
  var HistoryFun = function(props) {
2670
2694
  var type = props.type; props.roomId; var userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, loadSpecifiedData = props.loadSpecifiedData;
2671
- var _useState = _sliced_to_array(useState(""), 2), keyWordProblem = _useState[0], setKeyWordProblem = _useState[1]; //搜索内容
2672
- var _useState1 = _sliced_to_array(useState(1), 2), showLoadingState = _useState1[0], setShowLoadingState = _useState1[1]; //1,初始状态,2、无数据 ,3、不显示图片
2673
- var _useState2 = _sliced_to_array(useState(1), 2), pageNum = _useState2[0], setPageNum = _useState2[1];
2674
- var _useState3 = _sliced_to_array(useState(0), 2), pageCount = _useState3[0], setPageCount = _useState3[1];
2675
- var _useState4 = _sliced_to_array(useState(10), 2), maxPageSize = _useState4[0]; _useState4[1];
2676
- var _useState5 = _sliced_to_array(useState([]), 2), totalData = _useState5[0], setTotalData = _useState5[1]; //总数据
2695
+ var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1];
2696
+ var _useState1 = _sliced_to_array(useState(""), 2), keyWordProblem = _useState1[0], setKeyWordProblem = _useState1[1]; //搜索内容
2697
+ var _useState2 = _sliced_to_array(useState(1), 2), showLoadingState = _useState2[0], setShowLoadingState = _useState2[1]; //1,初始状态,2、无数据 ,3、不显示图片
2698
+ var _useState3 = _sliced_to_array(useState(1), 2), pageNum = _useState3[0], setPageNum = _useState3[1];
2699
+ var _useState4 = _sliced_to_array(useState(0), 2), pageCount = _useState4[0], setPageCount = _useState4[1];
2700
+ var _useState5 = _sliced_to_array(useState(10), 2), maxPageSize = _useState5[0]; _useState5[1];
2701
+ var _useState6 = _sliced_to_array(useState([]), 2), totalData = _useState6[0], setTotalData = _useState6[1]; //总数据
2677
2702
  var timer = useRef(null); //文本框输入时
2678
2703
  useEffect(function() {
2679
2704
  function handleScroll() {
@@ -2706,6 +2731,7 @@ var HistoryFun = function(props) {
2706
2731
  pageNum
2707
2732
  ]);
2708
2733
  var getList = function(val, pageNum) {
2734
+ setLoading(true);
2709
2735
  return http.get("".concat(urllocation, "/chat-service/public/v1.0/history-messages-total"), {
2710
2736
  params: {
2711
2737
  message: val,
@@ -2713,6 +2739,7 @@ var HistoryFun = function(props) {
2713
2739
  maxPageSize: maxPageSize
2714
2740
  }
2715
2741
  }).then(function(res) {
2742
+ setLoading(false);
2716
2743
  var data = res.data;
2717
2744
  if (data.total > 0) {
2718
2745
  setShowLoadingState(3);
@@ -2727,7 +2754,9 @@ var HistoryFun = function(props) {
2727
2754
  } else {
2728
2755
  setShowLoadingState(2);
2729
2756
  }
2730
- }).catch(function(res) {});
2757
+ }).catch(function(res) {
2758
+ setLoading(false);
2759
+ });
2731
2760
  };
2732
2761
  //获取全部数据
2733
2762
  var allData = function(roomId) {
@@ -2978,181 +3007,185 @@ var HistoryFun = function(props) {
2978
3007
  })
2979
3008
  ]
2980
3009
  }),
2981
- /*#__PURE__*/ jsxs("div", {
3010
+ /*#__PURE__*/ jsx("div", {
2982
3011
  className: modules_63b47c51$1.main_list,
2983
3012
  id: "history_list",
2984
- children: [
2985
- showLoadingState == 1 && /*#__PURE__*/ jsxs("div", {
2986
- className: modules_63b47c51$1.no_data,
2987
- children: [
2988
- /*#__PURE__*/ jsx("img", {
2989
- src: "/new_yun/images/aiService/search_for_icon.png"
2990
- }),
2991
- /*#__PURE__*/ jsx("p", {
2992
- children: "输入关键词,搜索聊天记录"
2993
- })
2994
- ]
2995
- }),
2996
- showLoadingState == 2 && /*#__PURE__*/ jsxs("div", {
2997
- className: modules_63b47c51$1.no_data,
2998
- children: [
2999
- /*#__PURE__*/ jsx("img", {
3000
- src: "/new_yun/images/aiService/no_data.png"
3001
- }),
3002
- /*#__PURE__*/ jsx("p", {
3003
- children: "暂无记录"
3004
- })
3005
- ]
3006
- }),
3007
- /*#__PURE__*/ jsx("div", {
3008
- className: modules_63b47c51$1.list_item,
3009
- children: totalData.map(function(item) {
3010
- var span = "";
3011
- var time = "";
3012
- if (item.count == 1) {
3013
- var message = item.message;
3014
- var position_i = message.indexOf(keyWordProblem);
3015
- if (position_i > 30) {
3016
- message = message.substring(position_i - 15);
3017
- }
3018
- var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3019
- //搜索内容是否有特殊字符
3020
- if (reg.test(keyWordProblem)) {
3021
- span = message.replaceAll(keyWordProblem, function(e) {
3022
- return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(e, "</span>");
3023
- });
3024
- } else {
3025
- span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
3026
- return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(i, "</span>");
3027
- });
3013
+ children: /*#__PURE__*/ jsxs(Spin, {
3014
+ spinning: loading,
3015
+ tip: "加载中...",
3016
+ children: [
3017
+ showLoadingState == 1 && /*#__PURE__*/ jsxs("div", {
3018
+ className: modules_63b47c51$1.no_data,
3019
+ children: [
3020
+ /*#__PURE__*/ jsx("img", {
3021
+ src: "/new_yun/images/aiService/search_for_icon.png"
3022
+ }),
3023
+ /*#__PURE__*/ jsx("p", {
3024
+ children: "输入关键词,搜索聊天记录"
3025
+ })
3026
+ ]
3027
+ }),
3028
+ showLoadingState == 2 && /*#__PURE__*/ jsxs("div", {
3029
+ className: modules_63b47c51$1.no_data,
3030
+ children: [
3031
+ /*#__PURE__*/ jsx("img", {
3032
+ src: "/new_yun/images/aiService/no_data.png"
3033
+ }),
3034
+ /*#__PURE__*/ jsx("p", {
3035
+ children: "暂无记录"
3036
+ })
3037
+ ]
3038
+ }),
3039
+ /*#__PURE__*/ jsx("div", {
3040
+ className: modules_63b47c51$1.list_item,
3041
+ children: totalData.map(function(item) {
3042
+ var span = "";
3043
+ var time = "";
3044
+ if (item.count == 1) {
3045
+ var message = item.message;
3046
+ var position_i = message.indexOf(keyWordProblem);
3047
+ if (position_i > 30) {
3048
+ message = message.substring(position_i - 15);
3049
+ }
3050
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3051
+ //搜索内容是否有特殊字符
3052
+ if (reg.test(keyWordProblem)) {
3053
+ span = message.replaceAll(keyWordProblem, function(e) {
3054
+ return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(e, "</span>");
3055
+ });
3056
+ } else {
3057
+ span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
3058
+ return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(i, "</span>");
3059
+ });
3060
+ }
3061
+ time = formatDate(item.createdAt);
3028
3062
  }
3029
- time = formatDate(item.createdAt);
3030
- }
3031
- return /*#__PURE__*/ jsxs(Fragment, {
3032
- children: [
3033
- /*#__PURE__*/ jsxs("div", {
3034
- className: "".concat(modules_63b47c51$1.list_summary, " ").concat(item.show ? modules_63b47c51$1.list_summary_active : ""),
3035
- id: item.roomId,
3036
- onClick: function() {
3037
- if (item.count == 1) {
3038
- calculationData(item.roomId, item.id, item.member);
3039
- } else {
3040
- showDetails(item.roomId, item.show);
3041
- }
3042
- },
3043
- children: [
3044
- /*#__PURE__*/ jsx("div", {
3045
- className: modules_63b47c51$1.head_img,
3046
- children: item.member == "AI" ? /*#__PURE__*/ jsx(CustomAiIcon$1, {}) : /*#__PURE__*/ jsx("img", {
3047
- src: item.headImg
3048
- })
3049
- }),
3050
- /*#__PURE__*/ jsxs("div", {
3051
- className: modules_63b47c51$1.list_desc,
3052
- children: [
3053
- /*#__PURE__*/ jsxs("p", {
3054
- className: modules_63b47c51$1.name,
3055
- children: [
3056
- item.member == "AI" ? "AI助手" : item.name,
3057
- item.count == 1 ? /*#__PURE__*/ jsx("span", {
3058
- className: modules_63b47c51$1.time,
3059
- children: time
3060
- }) : ""
3061
- ]
3062
- }),
3063
- item.count == 1 ? /*#__PURE__*/ jsx("p", {
3064
- className: modules_63b47c51$1.decs,
3065
- style: {
3066
- width: "calc(100% - 36px)"
3067
- },
3068
- dangerouslySetInnerHTML: {
3069
- __html: span
3070
- }
3071
- }) : /*#__PURE__*/ jsx("p", {
3072
- className: modules_63b47c51$1.decs,
3073
- children: "".concat(item.count, "条相关聊天记录")
3074
- })
3075
- ]
3076
- }),
3077
- item.count != 1 ? /*#__PURE__*/ jsx("div", {
3078
- className: "".concat(modules_63b47c51$1.open, " ").concat(item.show ? modules_63b47c51$1.active : ""),
3079
- children: /*#__PURE__*/ jsx(CustomExpand$1, {})
3080
- }) : ""
3081
- ]
3082
- }),
3083
- /*#__PURE__*/ jsxs("div", {
3084
- className: modules_63b47c51$1.list_detail,
3085
- children: [
3086
- item.show && item.detailsList && item.detailsList.map(function(list) {
3087
- // console.log(list,item,'dklfvmdflkvmdfklv')
3088
- var name = "";
3089
- if (list.sender == "AI") {
3090
- name = "AI助手";
3091
- } else if (list.sender == item.member) {
3092
- name = item.name;
3093
- } else {
3094
- name = userData.real_name;
3095
- }
3096
- var time = formatDate(list.updatedAt);
3097
- var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3098
- var span = "";
3099
- var message = list.message;
3100
- var position_i = message.indexOf(keyWordProblem);
3101
- if (position_i > 30) {
3102
- message = message.substring(position_i - 15);
3103
- }
3104
- //搜索内容是否有特殊字符
3105
- if (reg.test(keyWordProblem)) {
3106
- span = message.replaceAll(keyWordProblem, function(e) {
3107
- return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(e, "</span>");
3108
- });
3063
+ return /*#__PURE__*/ jsxs(Fragment, {
3064
+ children: [
3065
+ /*#__PURE__*/ jsxs("div", {
3066
+ className: "".concat(modules_63b47c51$1.list_summary, " ").concat(item.show ? modules_63b47c51$1.list_summary_active : ""),
3067
+ id: item.roomId,
3068
+ onClick: function() {
3069
+ if (item.count == 1) {
3070
+ calculationData(item.roomId, item.id, item.member);
3109
3071
  } else {
3110
- span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
3111
- // console.log(i,'skdcnsdjk')
3112
- return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(i, "</span>");
3113
- });
3072
+ showDetails(item.roomId, item.show);
3114
3073
  }
3115
- return /*#__PURE__*/ jsxs("div", {
3116
- className: modules_63b47c51$1.list,
3117
- onClick: function() {
3118
- calculationData(item.roomId, list.id, list.receiver);
3119
- },
3074
+ },
3075
+ children: [
3076
+ /*#__PURE__*/ jsx("div", {
3077
+ className: modules_63b47c51$1.head_img,
3078
+ children: item.member == "AI" ? /*#__PURE__*/ jsx(CustomAiIcon$1, {}) : /*#__PURE__*/ jsx("img", {
3079
+ src: item.headImg
3080
+ })
3081
+ }),
3082
+ /*#__PURE__*/ jsxs("div", {
3083
+ className: modules_63b47c51$1.list_desc,
3120
3084
  children: [
3121
- /*#__PURE__*/ jsxs("div", {
3085
+ /*#__PURE__*/ jsxs("p", {
3122
3086
  className: modules_63b47c51$1.name,
3123
3087
  children: [
3124
- /*#__PURE__*/ jsx("p", {
3125
- children: name
3126
- }),
3127
- /*#__PURE__*/ jsx("span", {
3088
+ item.member == "AI" ? "AI助手" : item.name,
3089
+ item.count == 1 ? /*#__PURE__*/ jsx("span", {
3128
3090
  className: modules_63b47c51$1.time,
3129
3091
  children: time
3130
- })
3092
+ }) : ""
3131
3093
  ]
3132
3094
  }),
3133
- /*#__PURE__*/ jsx("div", {
3134
- className: modules_63b47c51$1.con,
3095
+ item.count == 1 ? /*#__PURE__*/ jsx("p", {
3096
+ className: modules_63b47c51$1.decs,
3097
+ style: {
3098
+ width: "calc(100% - 36px)"
3099
+ },
3135
3100
  dangerouslySetInnerHTML: {
3136
3101
  __html: span
3137
3102
  }
3103
+ }) : /*#__PURE__*/ jsx("p", {
3104
+ className: modules_63b47c51$1.decs,
3105
+ children: "".concat(item.count, "条相关聊天记录")
3138
3106
  })
3139
3107
  ]
3140
- }, list.id);
3141
- }),
3142
- item.show && item.pageCount > 1 && item.pageCount > item.pageNum && /*#__PURE__*/ jsx("div", {
3143
- className: "".concat(modules_63b47c51$1.list, " ").concat(modules_63b47c51$1.list_more),
3144
- onClick: function() {
3145
- loadMore(item.pageNum + 1, item.roomId);
3146
- },
3147
- children: "点击加载更多"
3148
- })
3149
- ]
3150
- })
3151
- ]
3152
- });
3108
+ }),
3109
+ item.count != 1 ? /*#__PURE__*/ jsx("div", {
3110
+ className: "".concat(modules_63b47c51$1.open, " ").concat(item.show ? modules_63b47c51$1.active : ""),
3111
+ children: /*#__PURE__*/ jsx(CustomExpand$1, {})
3112
+ }) : ""
3113
+ ]
3114
+ }),
3115
+ /*#__PURE__*/ jsxs("div", {
3116
+ className: modules_63b47c51$1.list_detail,
3117
+ children: [
3118
+ item.show && item.detailsList && item.detailsList.map(function(list) {
3119
+ // console.log(list,item,'dklfvmdflkvmdfklv')
3120
+ var name = "";
3121
+ if (list.sender == "AI") {
3122
+ name = "AI助手";
3123
+ } else if (list.sender == item.member) {
3124
+ name = item.name;
3125
+ } else {
3126
+ name = userData.real_name;
3127
+ }
3128
+ var time = formatDate(list.updatedAt);
3129
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
3130
+ var span = "";
3131
+ var message = list.message;
3132
+ var position_i = message.indexOf(keyWordProblem);
3133
+ if (position_i > 30) {
3134
+ message = message.substring(position_i - 15);
3135
+ }
3136
+ //搜索内容是否有特殊字符
3137
+ if (reg.test(keyWordProblem)) {
3138
+ span = message.replaceAll(keyWordProblem, function(e) {
3139
+ return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(e, "</span>");
3140
+ });
3141
+ } else {
3142
+ span = message.replaceAll(new RegExp(keyWordProblem, "ig"), function(i) {
3143
+ // console.log(i,'skdcnsdjk')
3144
+ return "<span class=".concat(modules_63b47c51$1.sign, ">").concat(i, "</span>");
3145
+ });
3146
+ }
3147
+ return /*#__PURE__*/ jsxs("div", {
3148
+ className: modules_63b47c51$1.list,
3149
+ onClick: function() {
3150
+ calculationData(item.roomId, list.id, list.receiver);
3151
+ },
3152
+ children: [
3153
+ /*#__PURE__*/ jsxs("div", {
3154
+ className: modules_63b47c51$1.name,
3155
+ children: [
3156
+ /*#__PURE__*/ jsx("p", {
3157
+ children: name
3158
+ }),
3159
+ /*#__PURE__*/ jsx("span", {
3160
+ className: modules_63b47c51$1.time,
3161
+ children: time
3162
+ })
3163
+ ]
3164
+ }),
3165
+ /*#__PURE__*/ jsx("div", {
3166
+ className: modules_63b47c51$1.con,
3167
+ dangerouslySetInnerHTML: {
3168
+ __html: span
3169
+ }
3170
+ })
3171
+ ]
3172
+ }, list.id);
3173
+ }),
3174
+ item.show && item.pageCount > 1 && item.pageCount > item.pageNum && /*#__PURE__*/ jsx("div", {
3175
+ className: "".concat(modules_63b47c51$1.list, " ").concat(modules_63b47c51$1.list_more),
3176
+ onClick: function() {
3177
+ loadMore(item.pageNum + 1, item.roomId);
3178
+ },
3179
+ children: "点击加载更多"
3180
+ })
3181
+ ]
3182
+ })
3183
+ ]
3184
+ });
3185
+ })
3153
3186
  })
3154
- })
3155
- ]
3187
+ ]
3188
+ })
3156
3189
  })
3157
3190
  ]
3158
3191
  })
@@ -7866,7 +7899,7 @@ var ScreenShot = /*#__PURE__*/ function() {
7866
7899
 
7867
7900
  var styles = modules_63b47c51$1;
7868
7901
  var TextArea = Input.TextArea;
7869
- /*
7902
+ /*
7870
7903
  自定义remarkable的text解析规则
7871
7904
  */ var HTML_ESCAPE_TEST_RE = /[&<>"]/;
7872
7905
  var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
@@ -7904,6 +7937,7 @@ var CustomerService = function(props) {
7904
7937
  var _useState11 = _sliced_to_array(useState(false), 2), loading = _useState11[0], setLoading = _useState11[1]; //上拉显示加载图标
7905
7938
  var _useState12 = _sliced_to_array(useState(false), 2), bottomLoading = _useState12[0], setBottomLoading = _useState12[1]; //下拉显示加载图标
7906
7939
  var _useState13 = _sliced_to_array(useState(true), 2), finished = _useState13[0], setFinished = _useState13[1]; //是否结束生成
7940
+ var finishedRef = useRef(true); //是否结束生成
7907
7941
  var _useState14 = _sliced_to_array(useState(""), 2), lastId = _useState14[0], setLastId = _useState14[1]; //最后一条数据的id,可用于定位当前位置
7908
7942
  var _useState15 = _sliced_to_array(useState({}), 2), chatWith = _useState15[0], setChatWith = _useState15[1]; //聊天的老师id或ai
7909
7943
  var _useState16 = _sliced_to_array(useState(false), 2), firstLoad = _useState16[0], setFirstLoad = _useState16[1]; //第一次切换全屏时滚动到页面底部
@@ -8163,12 +8197,13 @@ var CustomerService = function(props) {
8163
8197
  }, 1000);
8164
8198
  }
8165
8199
  //生成答案过程中
8166
- if (!finished && scrollTopHei.current > scrollTop) {
8200
+ if (!finished && scrollHeight > scrollTop) {
8201
+ console.log("生成答案过程中", scrollTopHei.current, scrollTop);
8167
8202
  // setIsPosition(false);
8168
8203
  isPosition.current = false;
8169
8204
  }
8170
8205
  if (!finished && clientHeight + scrollTop >= scrollHeight) {
8171
- // console.log('到顶了111');
8206
+ console.log("到顶了111", clientHeight, scrollTop, scrollHeight);
8172
8207
  isPosition.current = true;
8173
8208
  }
8174
8209
  scrollTopHei.current = scrollTop;
@@ -8363,7 +8398,7 @@ var CustomerService = function(props) {
8363
8398
  roomId: roomId,
8364
8399
  sender: "AI",
8365
8400
  recevier: mid,
8366
- message: "Hi,我是智能学习助手,你遇到了什么问题?",
8401
+ message: "Hi,我是智能学习助手,你遇到了什么问题?111",
8367
8402
  extraInfos: questionsList == null ? null : questionsList
8368
8403
  };
8369
8404
  if (pageNumHistory <= 1) {
@@ -8393,7 +8428,7 @@ var CustomerService = function(props) {
8393
8428
  roomId: roomId,
8394
8429
  sender: "AI",
8395
8430
  recevier: mid,
8396
- message: "Hi,我是智能学习助手,你遇到了什么问题?"
8431
+ message: "Hi,我是智能学习助手,你遇到了什么问题?222哈哈"
8397
8432
  };
8398
8433
  if (pageNumHistory <= 1) {
8399
8434
  setHistoryMessageList(function(historyMessageList) {
@@ -8559,217 +8594,283 @@ var CustomerService = function(props) {
8559
8594
  });
8560
8595
  };
8561
8596
  //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
8562
- var sendToTeacher = function(type) {
8563
- var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
8564
- console.log("消息发送给老师111");
8565
- var obj = {};
8566
- if (type == 1) {
8567
- obj = {
8568
- roomId: roomId,
8569
- sender: mid,
8570
- recevier: chatWith.uid,
8571
- message: problem.question
8572
- };
8573
- if (problem.url) {
8574
- obj.image = problem.url;
8575
- }
8576
- setProblem({});
8577
- } else if (type == 2 || type == 3) {
8578
- var list = contactsList.filter(function(item) {
8579
- return item.roomId == roomId;
8580
- });
8581
- var recevier = "";
8582
- if (list.length > 0) {
8583
- recevier = list[0].sender;
8584
- }
8585
- obj = {
8586
- roomId: roomId,
8587
- sender: mid,
8588
- recevier: recevier,
8589
- message: type == 2 ? keyWord : message,
8590
- quotedMessage: citationContent.content || ""
8591
- };
8592
- if (citationContent.imageUrl) {
8593
- obj.image = citationContent.imageUrl;
8594
- }
8595
- if (screenshotBese64) {
8596
- obj.image = screenshotBese64;
8597
- setScreenshotBese64("");
8598
- }
8599
- }
8600
- http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
8601
- if (res.data.id) {
8602
- // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
8603
- if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
8604
- setHistoryMessageList(function(historyMessageList) {
8605
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
8606
- id: res.data.id,
8607
- upvoted: false,
8608
- downvoted: false,
8609
- createdAt: getDataTime(-1),
8610
- extraInfo: obj.image ? JSON.stringify([
8611
- {
8612
- key: "imageUrl",
8613
- value: obj.image
8614
- }
8615
- ]) : null
8616
- }));
8617
- return newHistoryMessageList;
8618
- });
8619
- // console.log(lastId,'消息发送给老师111');
8620
- scrollToBottom();
8621
- }
8622
- //判断当前窗口是否是
8623
- if (type == 1) {
8624
- var roomList = [
8625
- {
8597
+ var sendToTeacher = function() {
8598
+ var _ref = _async_to_generator(function(type) {
8599
+ var message, obj, list, recevier, base64;
8600
+ var _arguments = arguments;
8601
+ return __generator(this, function(_state) {
8602
+ switch(_state.label){
8603
+ case 0:
8604
+ message = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "";
8605
+ console.log("消息发送给老师111");
8606
+ obj = {};
8607
+ if (!(type == 1)) return [
8608
+ 3,
8609
+ 1
8610
+ ];
8611
+ obj = {
8626
8612
  roomId: roomId,
8627
- id: res.data.id
8613
+ sender: mid,
8614
+ recevier: chatWith.uid,
8615
+ message: problem.question
8616
+ };
8617
+ if (problem.url) {
8618
+ obj.image = problem.url;
8628
8619
  }
8629
- ];
8630
- setChatObj(function(list) {
8631
- var list2 = list.filter(function(item) {
8632
- return item.id != roomList[0].id;
8620
+ setProblem({});
8621
+ return [
8622
+ 3,
8623
+ 4
8624
+ ];
8625
+ case 1:
8626
+ if (!(type == 2 || type == 3)) return [
8627
+ 3,
8628
+ 4
8629
+ ];
8630
+ list = contactsList.filter(function(item) {
8631
+ return item.roomId == roomId;
8633
8632
  });
8634
- return list2.concat(roomList);
8635
- });
8633
+ recevier = "";
8634
+ if (list.length > 0) {
8635
+ recevier = list[0].sender;
8636
+ }
8637
+ obj = {
8638
+ roomId: roomId,
8639
+ sender: mid,
8640
+ recevier: recevier,
8641
+ message: type == 2 ? keyWord : message,
8642
+ quotedMessage: citationContent.content || ""
8643
+ };
8644
+ if (!citationContent.imageUrl) return [
8645
+ 3,
8646
+ 3
8647
+ ];
8648
+ return [
8649
+ 4,
8650
+ urlToBase64(citationContent.imageUrl)
8651
+ ];
8652
+ case 2:
8653
+ base64 = _state.sent();
8654
+ console.log("citationContent.imageUrl", citationContent.imageUrl);
8655
+ //imageUrl = citationContent.imageUrl;
8656
+ obj.image = base64;
8657
+ _state.label = 3;
8658
+ case 3:
8659
+ if (screenshotBese64) {
8660
+ obj.image = screenshotBese64;
8661
+ setScreenshotBese64("");
8662
+ }
8663
+ _state.label = 4;
8664
+ case 4:
8665
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
8666
+ if (res.data.id) {
8667
+ // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
8668
+ if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
8669
+ setHistoryMessageList(function(historyMessageList) {
8670
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
8671
+ id: res.data.id,
8672
+ upvoted: false,
8673
+ downvoted: false,
8674
+ createdAt: getDataTime(-1),
8675
+ extraInfo: obj.image ? JSON.stringify([
8676
+ {
8677
+ key: "imageUrl",
8678
+ value: obj.image
8679
+ }
8680
+ ]) : null
8681
+ }));
8682
+ return newHistoryMessageList;
8683
+ });
8684
+ // console.log(lastId,'消息发送给老师111');
8685
+ scrollToBottom();
8686
+ }
8687
+ //判断当前窗口是否是
8688
+ if (type == 1) {
8689
+ var roomList = [
8690
+ {
8691
+ roomId: roomId,
8692
+ id: res.data.id
8693
+ }
8694
+ ];
8695
+ setChatObj(function(list) {
8696
+ var list2 = list.filter(function(item) {
8697
+ return item.id != roomList[0].id;
8698
+ });
8699
+ return list2.concat(roomList);
8700
+ });
8701
+ }
8702
+ }
8703
+ }).catch(function(err) {
8704
+ console.log(err);
8705
+ });
8706
+ return [
8707
+ 2
8708
+ ];
8636
8709
  }
8637
- }
8638
- }).catch(function(err) {
8639
- console.log(err);
8710
+ });
8640
8711
  });
8641
- };
8712
+ return function sendToTeacher(type) {
8713
+ return _ref.apply(this, arguments);
8714
+ };
8715
+ }();
8642
8716
  //发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息,flag == 3 是针对视频页面点击底部推荐问题
8643
8717
  var sendMessage = function() {
8644
8718
  var _ref = _async_to_generator(function(item, flag) {
8645
- var type, questions, sendData, obj, sendData1, imageUrl;
8719
+ var type, questions, sendData, obj, sendData1, imageUrl, base64;
8646
8720
  var _arguments = arguments;
8647
8721
  return __generator(this, function(_state) {
8648
- type = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "";
8649
- console.log(item, flag, 888888888);
8650
- questions = [];
8651
- if (item && flag) {
8652
- questions = [
8653
- item
8654
- ];
8655
- }
8656
- //点击知识库的问题,或者是点击问候消息
8657
- if (questions.length > 0) {
8658
- questions = questions[0];
8659
- //知识库联想的问题没有答案
8660
- if (!questions.answer && userData.modules.some(function(item) {
8661
- return item.short == "AIservice";
8662
- })) {
8663
- sendData = {
8664
- //相关数据
8722
+ switch(_state.label){
8723
+ case 0:
8724
+ type = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "";
8725
+ console.log(item, flag, 888888888);
8726
+ questions = [];
8727
+ if (item && flag) {
8728
+ questions = [
8729
+ item
8730
+ ];
8731
+ }
8732
+ if (!(questions.length > 0)) return [
8733
+ 3,
8734
+ 1
8735
+ ];
8736
+ questions = questions[0];
8737
+ //知识库联想的问题没有答案
8738
+ if (!questions.answer && userData.modules.some(function(item) {
8739
+ return item.short == "AIservice";
8740
+ })) {
8741
+ sendData = {
8742
+ //相关数据
8743
+ roomId: roomId,
8744
+ message: questions.question,
8745
+ quotedMessage: "",
8746
+ regenerate: true,
8747
+ generateUpvoteOrDownvoteMessage: false
8748
+ };
8749
+ if (pageNumHistory <= 1) {
8750
+ setHistoryMessageList(function(historyMessageList) {
8751
+ var newHistoryMessageList = historyMessageList.concat({
8752
+ roomId: roomId,
8753
+ sender: mid,
8754
+ recevier: "AI",
8755
+ message: questions.question,
8756
+ quotedMessage: "",
8757
+ id: "p" + new Date().getTime(),
8758
+ upvoted: false,
8759
+ downvoted: false,
8760
+ createdAt: getDataTime(-1),
8761
+ extraInfo: JSON.stringify([])
8762
+ });
8763
+ return newHistoryMessageList;
8764
+ });
8765
+ }
8766
+ setFinished(false);
8767
+ aiSendQuestions(3, sendData, 1);
8768
+ return [
8769
+ 2
8770
+ ];
8771
+ }
8772
+ console.log(questions, "知识库内容11111");
8773
+ obj = {
8665
8774
  roomId: roomId,
8775
+ sender: mid,
8776
+ recevier: "AI",
8666
8777
  message: questions.question,
8667
- quotedMessage: "",
8668
- regenerate: true,
8778
+ extraInfos: [
8779
+ {
8780
+ key: "questionId",
8781
+ value: flag == 1 ? questions.value : questions.id
8782
+ }
8783
+ ]
8784
+ };
8785
+ //发送问题 1 类型,发送问题需要的参数,问题的答案id等
8786
+ sendingExistingIssues(1, obj, {
8787
+ key: "questionId",
8788
+ value: flag == 1 ? questions.value : questions.id,
8789
+ answer: questions.answer
8790
+ }, type);
8791
+ setKeyWord("");
8792
+ setQuestionsList([]);
8793
+ setCitationContent({});
8794
+ return [
8795
+ 3,
8796
+ 5
8797
+ ];
8798
+ case 1:
8799
+ if (!userData.modules.some(function(item) {
8800
+ return item.short == "AIservice";
8801
+ })) return [
8802
+ 3,
8803
+ 4
8804
+ ];
8805
+ console.log("citationContent", citationContent);
8806
+ sendData1 = {
8807
+ //相关数据
8808
+ roomId: roomId,
8809
+ message: keyWord,
8810
+ quotedMessage: citationContent.content || "",
8811
+ regenerate: citationContent.content != "" ? false : true,
8669
8812
  generateUpvoteOrDownvoteMessage: false
8670
8813
  };
8814
+ imageUrl = "";
8815
+ if (!citationContent.imageUrl) return [
8816
+ 3,
8817
+ 3
8818
+ ];
8819
+ return [
8820
+ 4,
8821
+ urlToBase64(citationContent.imageUrl)
8822
+ ];
8823
+ case 2:
8824
+ base64 = _state.sent();
8825
+ console.log("citationContent.imageUrl", citationContent.imageUrl);
8826
+ sendData1.image = citationContent.imageUrl;
8827
+ //imageUrl = citationContent.imageUrl;
8828
+ imageUrl = base64;
8829
+ _state.label = 3;
8830
+ case 3:
8831
+ if (screenshotBese64) {
8832
+ console.log("screenshotBese64", screenshotBese64);
8833
+ sendData1.image = screenshotBese64;
8834
+ imageUrl = screenshotBese64;
8835
+ }
8671
8836
  if (pageNumHistory <= 1) {
8672
8837
  setHistoryMessageList(function(historyMessageList) {
8673
8838
  var newHistoryMessageList = historyMessageList.concat({
8674
8839
  roomId: roomId,
8675
8840
  sender: mid,
8676
8841
  recevier: "AI",
8677
- message: questions.question,
8678
- quotedMessage: "",
8842
+ message: keyWord,
8843
+ quotedMessage: citationContent.content,
8679
8844
  id: "p" + new Date().getTime(),
8680
8845
  upvoted: false,
8681
8846
  downvoted: false,
8682
8847
  createdAt: getDataTime(-1),
8683
- extraInfo: JSON.stringify([])
8848
+ extraInfo: imageUrl ? JSON.stringify([
8849
+ {
8850
+ key: "imageUrl",
8851
+ value: imageUrl
8852
+ }
8853
+ ]) : JSON.stringify([])
8684
8854
  });
8685
8855
  return newHistoryMessageList;
8686
8856
  });
8687
8857
  }
8688
8858
  setFinished(false);
8689
- aiSendQuestions(3, sendData, 1);
8859
+ aiSendQuestions(3, sendData1, 1);
8860
+ setScreenshotBese64("");
8861
+ return [
8862
+ 3,
8863
+ 5
8864
+ ];
8865
+ case 4:
8866
+ //不存在AI客服
8867
+ sendGreetingMessage(4);
8868
+ _state.label = 5;
8869
+ case 5:
8690
8870
  return [
8691
8871
  2
8692
8872
  ];
8693
- }
8694
- console.log(questions, "知识库内容11111");
8695
- obj = {
8696
- roomId: roomId,
8697
- sender: mid,
8698
- recevier: "AI",
8699
- message: questions.question,
8700
- extraInfos: [
8701
- {
8702
- key: "questionId",
8703
- value: flag == 1 ? questions.value : questions.id
8704
- }
8705
- ]
8706
- };
8707
- //发送问题 1 类型,发送问题需要的参数,问题的答案id等
8708
- sendingExistingIssues(1, obj, {
8709
- key: "questionId",
8710
- value: flag == 1 ? questions.value : questions.id,
8711
- answer: questions.answer
8712
- }, type);
8713
- setKeyWord("");
8714
- setQuestionsList([]);
8715
- setCitationContent({});
8716
- } else if (userData.modules.some(function(item) {
8717
- return item.short == "AIservice";
8718
- })) {
8719
- console.log("citationContent", citationContent);
8720
- sendData1 = {
8721
- //相关数据
8722
- roomId: roomId,
8723
- message: keyWord,
8724
- quotedMessage: citationContent.content || "",
8725
- regenerate: citationContent.content != "" ? false : true,
8726
- generateUpvoteOrDownvoteMessage: false
8727
- };
8728
- imageUrl = "";
8729
- if (citationContent.imageUrl) {
8730
- // let base64:string=await urlToBase64(citationContent.imageUrl) as string
8731
- console.log("citationContent.imageUrl", citationContent.imageUrl);
8732
- sendData1.image = citationContent.imageUrl;
8733
- imageUrl = citationContent.imageUrl;
8734
- }
8735
- if (screenshotBese64) {
8736
- console.log("screenshotBese64", screenshotBese64);
8737
- sendData1.image = screenshotBese64;
8738
- imageUrl = screenshotBese64;
8739
- }
8740
- if (pageNumHistory <= 1) {
8741
- setHistoryMessageList(function(historyMessageList) {
8742
- var newHistoryMessageList = historyMessageList.concat({
8743
- roomId: roomId,
8744
- sender: mid,
8745
- recevier: "AI",
8746
- message: keyWord,
8747
- quotedMessage: citationContent.content,
8748
- id: "p" + new Date().getTime(),
8749
- upvoted: false,
8750
- downvoted: false,
8751
- createdAt: getDataTime(-1),
8752
- extraInfo: imageUrl ? JSON.stringify([
8753
- {
8754
- key: "imageUrl",
8755
- value: imageUrl
8756
- }
8757
- ]) : JSON.stringify([])
8758
- });
8759
- return newHistoryMessageList;
8760
- });
8761
- }
8762
- setFinished(false);
8763
- aiSendQuestions(3, sendData1, 1);
8764
- setScreenshotBese64("");
8765
- //存在AI客服
8766
- } else {
8767
- //不存在AI客服
8768
- sendGreetingMessage(4);
8769
8873
  }
8770
- return [
8771
- 2
8772
- ];
8773
8874
  });
8774
8875
  });
8775
8876
  return function sendMessage(item, flag) {
@@ -8938,67 +9039,74 @@ var CustomerService = function(props) {
8938
9039
  signal: ctrl.current.signal,
8939
9040
  openWhenHidden: true,
8940
9041
  onopen: function(res) {
8941
- console.info("eventSource open: ", res);
8942
- clearTimeout(receiveMessageTimer.current);
8943
- if (res.status >= 300) {
8944
- console.log("sdckjsdncskdcjsdc", res.status);
8945
- setFinished(true);
8946
- setHistoryMessageList(function(historyMessageList) {
8947
- return historyMessageList.filter(function(item) {
8948
- return item.id != "123456" && item.id != "654321";
8949
- });
8950
- });
8951
- ctrl.current.abort();
8952
- }
8953
- if (res.status == 200) {
8954
- setFinished(false);
8955
- }
8956
- if (res.status == 401) {
8957
- //身份认证未通过,从新请求新的token后再次发送请求
8958
- verifyJWT(urllocation).then(function() {
8959
- console.log("重新请求");
8960
- setHistoryMessageList(function(historyMessageList) {
8961
- return historyMessageList.filter(function(item) {
8962
- return item.id != "123456" && item.id != "654321";
9042
+ return _async_to_generator(function() {
9043
+ return __generator(this, function(_state) {
9044
+ console.info("eventSource open: ", res);
9045
+ clearTimeout(receiveMessageTimer.current);
9046
+ if (res.status >= 300) {
9047
+ console.log("sdckjsdncskdcjsdc", res.status);
9048
+ setFinished(true);
9049
+ setHistoryMessageList(function(historyMessageList) {
9050
+ return historyMessageList.filter(function(item) {
9051
+ return item.id != "123456" && item.id != "654321";
9052
+ });
8963
9053
  });
8964
- });
8965
- aiSendQuestions(type, obj, id);
8966
- });
8967
- }
8968
- if (res.status == 403) {
8969
- //暂无权限
8970
- console.log("暂无权限");
8971
- setHistoryMessageList(function(historyMessageList) {
8972
- return historyMessageList.concat({
8973
- roomId: roomId,
8974
- sender: "AI",
8975
- recevier: mid,
8976
- message: "暂无权限",
8977
- id: "123456",
8978
- createdAt: "",
8979
- extraInfo: null
8980
- });
8981
- });
8982
- }
8983
- if (res.status == 429) ;
8984
- if (res.status == 429) {
8985
- //每天问答的 Token 数必须小于等于 10 万。
8986
- sendGreetingMessage(5);
8987
- }
8988
- if (res.status == 500) {
8989
- // 系统错误,请稍后再试。
8990
- setHistoryMessageList(function(historyMessageList) {
8991
- return historyMessageList.concat({
8992
- roomId: roomId,
8993
- sender: "AI",
8994
- recevier: mid,
8995
- message: "系统出错了,请稍后重试!",
8996
- id: "123456",
8997
- createdAt: "",
8998
- extraInfo: null
8999
- });
9054
+ ctrl.current.abort();
9055
+ }
9056
+ if (res.status == 200) {
9057
+ setFinished(false);
9058
+ }
9059
+ if (res.status == 401) {
9060
+ //身份认证未通过,从新请求新的token后再次发送请求
9061
+ verifyJWT(urllocation).then(function() {
9062
+ console.log("重新请求");
9063
+ setHistoryMessageList(function(historyMessageList) {
9064
+ return historyMessageList.filter(function(item) {
9065
+ return item.id != "123456" && item.id != "654321";
9066
+ });
9067
+ });
9068
+ aiSendQuestions(type, obj, id);
9069
+ });
9070
+ }
9071
+ if (res.status == 403) {
9072
+ //暂无权限
9073
+ console.log("暂无权限");
9074
+ setHistoryMessageList(function(historyMessageList) {
9075
+ return historyMessageList.concat({
9076
+ roomId: roomId,
9077
+ sender: "AI",
9078
+ recevier: mid,
9079
+ message: "暂无权限",
9080
+ id: "123456",
9081
+ createdAt: "",
9082
+ extraInfo: null
9083
+ });
9084
+ });
9085
+ }
9086
+ if (res.status == 429) ;
9087
+ if (res.status == 429) {
9088
+ //每天问答的 Token 数必须小于等于 10 万。
9089
+ sendGreetingMessage(5);
9090
+ }
9091
+ if (res.status == 500) {
9092
+ // 系统错误,请稍后再试。
9093
+ setHistoryMessageList(function(historyMessageList) {
9094
+ return historyMessageList.concat({
9095
+ roomId: roomId,
9096
+ sender: "AI",
9097
+ recevier: mid,
9098
+ message: "系统出错了,请稍后重试!",
9099
+ id: "123456",
9100
+ createdAt: "",
9101
+ extraInfo: null
9102
+ });
9103
+ });
9104
+ }
9105
+ return [
9106
+ 2
9107
+ ];
9000
9108
  });
9001
- }
9109
+ })();
9002
9110
  },
9003
9111
  onerror: function(err) {
9004
9112
  console.log(err, "dflkvdmfvlkdfv");
@@ -9019,31 +9127,39 @@ var CustomerService = function(props) {
9019
9127
  //识别的内容
9020
9128
  // console.log("eventSource msg: ", event.data);
9021
9129
  var msg = JSON.parse(event.data);
9022
- if (msg.message) {
9023
- content = content + msg.message;
9024
- // isPosition.current = true;
9025
- renderAiAnswerTimer.current = setTimeout(function() {
9130
+ if (msg.message) ;
9131
+ setFinished(function(prevData) {
9132
+ finishedRef.current = false;
9133
+ return finishedRef.current;
9134
+ });
9135
+ console.log("返回中", msg);
9136
+ content = content + msg.message;
9137
+ // isPosition.current = true;
9138
+ renderAiAnswerTimer.current = setTimeout(function() {
9139
+ if (!finishedRef.current) {
9026
9140
  renderAiAnswer(msg, id, type);
9027
- }, 100);
9028
- }
9141
+ }
9142
+ }, 100);
9029
9143
  if (msg.finished) {
9030
- setFinished(true); //发送结束
9144
+ // console.log('返回完成',msg)
9145
+ // setFinished(true); //发送结束
9031
9146
  if (!flagKeyWord) {
9032
9147
  videoPageQuestiionsList(2);
9033
9148
  }
9034
9149
  // isPosition.current = true;
9035
- setTimeout(function() {
9036
- isPosition.current = true;
9037
- }, 100);
9150
+ // setTimeout(()=>{
9151
+ // isPosition.current = true;
9152
+ // },100)
9038
9153
  testLabQuestion(JSON.parse(data).message, content, "");
9039
9154
  }
9040
9155
  },
9041
9156
  onclose: function() {
9042
- setFinished(true); //发送结束
9043
- // isPosition.current = true;
9044
- setTimeout(function() {
9045
- isPosition.current = true;
9046
- }, 100);
9157
+ console.log("eventSource close");
9158
+ // setFinished(true); //发送结束
9159
+ // // isPosition.current = true;
9160
+ // setTimeout(()=>{
9161
+ // isPosition.current = true;
9162
+ // },100)
9047
9163
  setHistoryMessageList(function(historyMessageList) {
9048
9164
  return historyMessageList.filter(function(item) {
9049
9165
  return item.id != "123456";
@@ -9124,9 +9240,20 @@ var CustomerService = function(props) {
9124
9240
  return newHistoryMessageList2;
9125
9241
  }
9126
9242
  });
9127
- var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
9128
- if (container) {
9129
- container.scrollTop = container.scrollHeight;
9243
+ console.log("isPosition", isPosition.current);
9244
+ if (isPosition.current) {
9245
+ var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
9246
+ if (container) {
9247
+ container.scrollTop = container.scrollHeight;
9248
+ }
9249
+ }
9250
+ if (msg.finished) {
9251
+ console.log("返回完成", msg);
9252
+ //发送结束
9253
+ setFinished(function(prevData) {
9254
+ finishedRef.current = true;
9255
+ return finishedRef.current;
9256
+ });
9130
9257
  }
9131
9258
  // console.log('historyMessageList',historyMessageList)
9132
9259
  // if(isPosition.current){
@@ -10526,7 +10653,11 @@ var CustomerService = function(props) {
10526
10653
  return item.id != "123456";
10527
10654
  });
10528
10655
  });
10529
- setFinished(true);
10656
+ // setFinished(true);
10657
+ setFinished(function(prevData) {
10658
+ finishedRef.current = true;
10659
+ return finishedRef.current;
10660
+ });
10530
10661
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
10531
10662
  }
10532
10663
  }),
@@ -10544,7 +10675,11 @@ var CustomerService = function(props) {
10544
10675
  return item.id != "123456";
10545
10676
  });
10546
10677
  });
10547
- setFinished(true);
10678
+ // setFinished(true);
10679
+ setFinished(function(prevData) {
10680
+ finishedRef.current = true;
10681
+ return finishedRef.current;
10682
+ });
10548
10683
  onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
10549
10684
  },
10550
10685
  children: "停止生成"