@fle-ui/plus-im-record 0.0.7-beta.0 → 0.0.8-beta.1

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 (47) hide show
  1. package/es/ChatMessageItem/index.d.ts +2 -4
  2. package/es/ChatMessageItem/index.less +1 -1
  3. package/es/ChatMessageList/index.d.ts +7 -5
  4. package/es/ChatMessageList/index.js +4 -2
  5. package/es/ChatMessageList/index.less +2 -1
  6. package/es/GoodsCard/index.d.ts +1 -0
  7. package/es/GoodsCard/index.js +4 -2
  8. package/es/GoodsCard/index.less +1 -1
  9. package/es/GoodsOrderCard/index.d.ts +2 -5
  10. package/es/GoodsOrderCard/index.js +1 -1
  11. package/es/GoodsOrderCard/index.less +1 -1
  12. package/es/ParseSession/AudioPlayer.d.ts +14 -0
  13. package/es/ParseSession/AudioPlayer.js +89 -0
  14. package/es/ParseSession/audioAndVideoTool.d.ts +3 -0
  15. package/es/ParseSession/audioAndVideoTool.js +21 -0
  16. package/es/ParseSession/index.d.ts +2 -8
  17. package/es/ParseSession/index.js +109 -71
  18. package/es/ParseSession/index.less +46 -1
  19. package/es/api/index.d.ts +2 -1
  20. package/es/audioAndVideoTool.d.ts +3 -0
  21. package/es/audioAndVideoTool.js +21 -0
  22. package/es/index.d.ts +12 -9
  23. package/es/index.js +15 -14
  24. package/lib/ChatMessageItem/index.d.ts +2 -4
  25. package/lib/ChatMessageItem/index.less +1 -1
  26. package/lib/ChatMessageList/index.d.ts +7 -5
  27. package/lib/ChatMessageList/index.js +4 -2
  28. package/lib/ChatMessageList/index.less +2 -1
  29. package/lib/GoodsCard/index.d.ts +1 -0
  30. package/lib/GoodsCard/index.js +4 -2
  31. package/lib/GoodsCard/index.less +1 -1
  32. package/lib/GoodsOrderCard/index.d.ts +2 -5
  33. package/lib/GoodsOrderCard/index.js +1 -1
  34. package/lib/GoodsOrderCard/index.less +1 -1
  35. package/lib/ParseSession/AudioPlayer.d.ts +14 -0
  36. package/lib/ParseSession/AudioPlayer.js +98 -0
  37. package/lib/ParseSession/audioAndVideoTool.d.ts +3 -0
  38. package/lib/ParseSession/audioAndVideoTool.js +27 -0
  39. package/lib/ParseSession/index.d.ts +2 -8
  40. package/lib/ParseSession/index.js +112 -74
  41. package/lib/ParseSession/index.less +46 -1
  42. package/lib/api/index.d.ts +2 -1
  43. package/lib/audioAndVideoTool.d.ts +3 -0
  44. package/lib/audioAndVideoTool.js +27 -0
  45. package/lib/index.d.ts +12 -9
  46. package/lib/index.js +14 -13
  47. package/package.json +2 -2
package/es/index.d.ts CHANGED
@@ -1,21 +1,24 @@
1
- import React from 'react';
1
+ import React, { UIEventHandler } from 'react';
2
+ import { RecordSession } from './ChatMessageList';
2
3
  import { apiCreate, Env } from './api';
3
4
  import { IMMessage } from './@types';
4
5
  import './styles/index.less';
5
6
  /**
6
7
  * @name 客服记录组件
7
- * @description 代码由小鲤客服平台搬运简化而来
8
+ * @description 代码由小鲤客服平台搬运简来.
8
9
  */
9
10
  export interface IMRecordProps {
10
11
  env?: Env;
11
12
  token?: string;
12
- msgRecords: IMMessage[];
13
- onScrollTop?: () => void;
14
- recordSession?: {
15
- relationId: string | number;
16
- accid: string;
17
- relationType?: number;
18
- };
13
+ h5?: boolean;
14
+ msgs: IMMessage[];
15
+ myAccount?: string;
16
+ loadingStarus?: 'loading' | 'nomore';
17
+ onScrollTop?: UIEventHandler<HTMLDivElement>;
18
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
19
+ style?: React.CSSProperties;
20
+ isSessionEnd?: boolean;
21
+ recordSession?: RecordSession;
19
22
  }
20
23
  export interface ImContextProps {
21
24
  api: ReturnType<typeof apiCreate>;
package/es/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["env", "token", "msgs", "recordSession"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -14,30 +16,33 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
14
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { createContext, useEffect, useState } from 'react';
19
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
21
+ import React, { createContext, useEffect, useRef, useState } from 'react';
18
22
  import ChatMessageList from './ChatMessageList';
19
23
  import { apiCreate } from './api';
20
24
  import './styles/index.less';
21
25
  export var ImContext = /*#__PURE__*/createContext({});
22
26
  var IMRecord = function IMRecord(_ref) {
23
27
  var env = _ref.env,
24
- msgRecords = _ref.msgRecords,
25
28
  token = _ref.token,
29
+ msgs = _ref.msgs,
26
30
  recordSession = _ref.recordSession,
27
- onScrollTop = _ref.onScrollTop;
31
+ restProps = _objectWithoutProperties(_ref, _excluded);
28
32
  var api = apiCreate(env, token);
29
33
  var _useState = useState({}),
30
34
  _useState2 = _slicedToArray(_useState, 2),
31
35
  accountsMap = _useState2[0],
32
36
  setAccountsMap = _useState2[1];
37
+ var messageListDomRef = useRef(null);
33
38
  useEffect(function () {
34
- var accids = _toConsumableArray(new Set(msgRecords.map(function (x) {
39
+ var accids = _toConsumableArray(new Set(msgs.map(function (x) {
35
40
  return x.from;
36
41
  })));
37
42
  if (accids.length) {
38
43
  getAccountByAccids(accids);
39
44
  }
40
- }, [msgRecords]);
45
+ }, [msgs]);
41
46
  function getAccountByAccids(accids) {
42
47
  api.getAccountInfoByAccid({
43
48
  accids: accids
@@ -60,17 +65,13 @@ var IMRecord = function IMRecord(_ref) {
60
65
  value: {
61
66
  api: api
62
67
  }
63
- }, /*#__PURE__*/React.createElement(ChatMessageList, {
64
- msgs: msgRecords,
68
+ }, /*#__PURE__*/React.createElement(ChatMessageList, _extends({
69
+ ref: messageListDomRef,
70
+ msgs: msgs,
65
71
  h5: true,
66
- style: {
67
- height: '100%',
68
- background: '#f7f7f7'
69
- },
70
72
  accountsMap: accountsMap,
71
73
  isSessionEnd: true,
72
- recordSession: recordSession,
73
- onScrollTop: onScrollTop
74
- }));
74
+ recordSession: recordSession
75
+ }, restProps)));
75
76
  };
76
77
  export default IMRecord;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  declare const ChatMessageItem: React.FC<{
5
6
  h5?: boolean;
@@ -9,9 +10,6 @@ declare const ChatMessageItem: React.FC<{
9
10
  myAccount?: string;
10
11
  accountInfo: any;
11
12
  isSessionEnd: boolean;
12
- recordSession?: {
13
- relationId: string | number;
14
- accid: string;
15
- };
13
+ recordSession?: RecordSession;
16
14
  }>;
17
15
  export default ChatMessageItem;
@@ -103,6 +103,6 @@
103
103
  // 对话-H5
104
104
  .@{prefix}.h5 {
105
105
  .@{prefix}-body {
106
- max-width: 270px;
106
+ max-width: 276px;
107
107
  }
108
108
  }
@@ -3,12 +3,18 @@ import { IMMessage } from '../@types';
3
3
  import './index.less';
4
4
  declare const LOADING_STATUS: any;
5
5
  export type LoadingStatus = keyof typeof LOADING_STATUS | undefined;
6
+ export interface RecordSession {
7
+ relationId?: string | number;
8
+ accid?: string;
9
+ relationType?: number;
10
+ }
6
11
  export interface ChatMessageListProps {
7
12
  h5?: boolean;
8
13
  msgs: IMMessage[];
9
14
  myAccount?: string;
10
15
  loadingStarus?: LoadingStatus;
11
16
  onScrollTop?: UIEventHandler<HTMLDivElement>;
17
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
12
18
  accountsMap?: Record<string, {
13
19
  accid: string;
14
20
  nickname: string;
@@ -16,11 +22,7 @@ export interface ChatMessageListProps {
16
22
  }>;
17
23
  style?: React.CSSProperties;
18
24
  isSessionEnd?: boolean;
19
- recordSession?: {
20
- relationId: string | number;
21
- accid: string;
22
- relationType?: number;
23
- };
25
+ recordSession?: RecordSession;
24
26
  }
25
27
  declare const ChatMessageList: React.ForwardRefExoticComponent<ChatMessageListProps & React.RefAttributes<HTMLDivElement>>;
26
28
  export default ChatMessageList;
@@ -17,8 +17,8 @@ var LOAD_LIMIT = 15;
17
17
  var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
18
18
  var h5 = _ref.h5,
19
19
  msgs = _ref.msgs,
20
- _ref$onScrollTop = _ref.onScrollTop,
21
- onScrollTop = _ref$onScrollTop === void 0 ? function () {} : _ref$onScrollTop,
20
+ onScrollTop = _ref.onScrollTop,
21
+ onScrollBottom = _ref.onScrollBottom,
22
22
  _ref$loadingStarus = _ref.loadingStarus,
23
23
  loadingStarus = _ref$loadingStarus === void 0 ? '' : _ref$loadingStarus,
24
24
  myAccount = _ref.myAccount,
@@ -32,8 +32,10 @@ var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
32
32
  var onScrollHandler = (0, _utils.debounce)(function (e) {
33
33
  var scrollElRef = ref;
34
34
  if (!(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current)) return;
35
+ var isBottom = scrollElRef.current.scrollTop >= scrollElRef.current.scrollHeight - scrollElRef.current.clientHeight - 20;
35
36
  var isTop = scrollElRef.current.scrollTop < 20;
36
37
  isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
38
+ isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
37
39
  }, 200);
38
40
  return /*#__PURE__*/_react.default.createElement("div", {
39
41
  className: prefixCls,
@@ -1,7 +1,8 @@
1
1
  @prefix: chart;
2
2
 
3
3
  .@{prefix}-messages {
4
- flex: 1;
4
+ width: 100%;
5
+ height: 100%;
5
6
  position: relative;
6
7
  overflow: hidden;
7
8
  display: flex;
@@ -9,6 +9,7 @@ declare const OrderCard: React.FC<{
9
9
  productId: any;
10
10
  relationId?: any;
11
11
  relationType?: any;
12
+ orderProductId?: number;
12
13
  };
13
14
  }>;
14
15
  export default OrderCard;
@@ -26,7 +26,8 @@ var OrderCard = function OrderCard(props) {
26
26
  content = props.content;
27
27
  var productId = content.productId,
28
28
  relationId = content.relationId,
29
- relationType = content.relationType;
29
+ relationType = content.relationType,
30
+ orderProductId = content.orderProductId;
30
31
  var _useState = (0, _react.useState)({}),
31
32
  _useState2 = _slicedToArray(_useState, 2),
32
33
  data = _useState2[0],
@@ -38,7 +39,8 @@ var OrderCard = function OrderCard(props) {
38
39
  api.getProductById({
39
40
  productId: productId,
40
41
  relationId: relationId,
41
- relationType: relationType
42
+ relationType: relationType,
43
+ orderProductId: orderProductId
42
44
  }).then(function (_ref) {
43
45
  var data = _ref.data;
44
46
  setData(data || {});
@@ -1,7 +1,7 @@
1
1
  @prefix: chart-messages-item;
2
2
 
3
3
  .@{prefix}-goods {
4
- width: 272px;
4
+ max-width: 272px;
5
5
  padding-bottom: 2px;
6
6
  &-info {
7
7
  display: flex;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { RecordSession } from '../ChatMessageList';
2
3
  import './index.less';
3
4
  export declare function fitUrl(url: string): string;
4
5
  declare const GoodsOrderCard: React.FC<{
@@ -8,10 +9,6 @@ declare const GoodsOrderCard: React.FC<{
8
9
  onClose?: Function;
9
10
  orderSn?: any;
10
11
  orderId?: any;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }>;
17
14
  export default GoodsOrderCard;
@@ -70,7 +70,7 @@ var GoodsOrderCard = function GoodsOrderCard(props) {
70
70
  data = _useState2[0],
71
71
  setData = _useState2[1];
72
72
  (0, _react.useEffect)(function () {
73
- if ((orderId || orderSn) && relationId && accid) {
73
+ if (orderId || orderSn) {
74
74
  api.getCSOrder({
75
75
  orderSn: orderSn,
76
76
  orderId: Number(orderId) || orderId,
@@ -1,7 +1,7 @@
1
1
  @prefix: chart-messages-item;
2
2
 
3
3
  .@{prefix}-order {
4
- width: 272px;
4
+ max-width: 272px;
5
5
  padding-bottom: 2px;
6
6
 
7
7
  &-info {
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface AudioPlayerProps {
3
+ prefix: string;
4
+ msg: {
5
+ idClient: string;
6
+ flow: string;
7
+ };
8
+ url: string;
9
+ dur: number;
10
+ text?: string;
11
+ style?: React.CSSProperties;
12
+ }
13
+ declare const AudioPlayer: React.FC<AudioPlayerProps>;
14
+ export default AudioPlayer;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _Icon = _interopRequireDefault(require("../Icon"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
22
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+ var AudioPlayer = function AudioPlayer(_ref) {
25
+ var prefix = _ref.prefix,
26
+ msg = _ref.msg,
27
+ url = _ref.url,
28
+ dur = _ref.dur,
29
+ text = _ref.text,
30
+ _ref$style = _ref.style,
31
+ style = _ref$style === void 0 ? {} : _ref$style;
32
+ var audioRef = (0, _react.useRef)(null);
33
+ var _useState = (0, _react.useState)(false),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ animationFlag = _useState2[0],
36
+ setAnimationFlag = _useState2[1];
37
+ var pauseAllAudio = function pauseAllAudio() {
38
+ var audio = document.getElementById('fxMessageAudio');
39
+ audio === null || audio === void 0 ? void 0 : audio.pause();
40
+ return audio;
41
+ };
42
+ var pauseAllVideo = function pauseAllVideo() {
43
+ var videoElements = document.getElementsByTagName('video');
44
+ for (var i = 0; i < videoElements.length; i++) {
45
+ if (videoElements[i].id.startsWith('fxMessageVideo-')) {
46
+ videoElements[i].pause();
47
+ }
48
+ }
49
+ };
50
+ var handleAudioClick = function handleAudioClick() {
51
+ var _audioRef$current;
52
+ pauseAllVideo();
53
+ var oldAudio = pauseAllAudio();
54
+ var msgId = oldAudio === null || oldAudio === void 0 ? void 0 : oldAudio.getAttribute('msgId');
55
+ if (msgId === msg.idClient) {
56
+ setAnimationFlag(false);
57
+ return;
58
+ }
59
+ var audio = new Audio(url);
60
+ audio.id = 'fxMessageAudio';
61
+ audio.setAttribute('msgId', msg.idClient);
62
+ audio.play();
63
+ (_audioRef$current = audioRef.current) === null || _audioRef$current === void 0 ? void 0 : _audioRef$current.appendChild(audio);
64
+ audio.addEventListener('ended', function () {
65
+ var _audio$parentNode;
66
+ setAnimationFlag(false);
67
+ (_audio$parentNode = audio.parentNode) === null || _audio$parentNode === void 0 ? void 0 : _audio$parentNode.removeChild(audio);
68
+ });
69
+ audio.addEventListener('pause', function () {
70
+ var _audio$parentNode2;
71
+ setAnimationFlag(false);
72
+ (_audio$parentNode2 = audio.parentNode) === null || _audio$parentNode2 === void 0 ? void 0 : _audio$parentNode2.removeChild(audio);
73
+ });
74
+ setAnimationFlag(true);
75
+ };
76
+ var duration = Math.floor(dur) || 0;
77
+ var durations = {
78
+ mm: Math.floor(duration / 60),
79
+ ss: duration % 60
80
+ };
81
+ return /*#__PURE__*/_react.default.createElement("div", {
82
+ className: "".concat(prefix, "-audio"),
83
+ ref: audioRef,
84
+ style: _objectSpread({}, style)
85
+ }, /*#__PURE__*/_react.default.createElement("div", {
86
+ className: msg.flow === 'in' ? "".concat(prefix, "-audio-in") : "".concat(prefix, "-audio-out"),
87
+ onClick: handleAudioClick
88
+ }, /*#__PURE__*/_react.default.createElement("span", null, ' ', "".concat(durations.mm > 0 ? "".concat(durations.mm, "'") : '', " ").concat(durations.ss, "\"")), /*#__PURE__*/_react.default.createElement("span", {
89
+ className: "".concat(prefix, "-audio-icon")
90
+ }, animationFlag ? /*#__PURE__*/_react.default.createElement("img", {
91
+ src: "https://qa-oss.elebuys.com/tmpdir/202401152050070000640984.gif"
92
+ }) : /*#__PURE__*/_react.default.createElement(_Icon.default, {
93
+ type: "icon-a-yuyin2"
94
+ }))), text && /*#__PURE__*/_react.default.createElement("div", {
95
+ className: "".concat(prefix, "-audio-audio2text")
96
+ }, text));
97
+ };
98
+ var _default = exports.default = AudioPlayer;
@@ -0,0 +1,3 @@
1
+ export declare const pauseAllAudio: () => HTMLAudioElement;
2
+ export declare const pauseOtherVideo: (idClient: string) => void;
3
+ export declare const pauseAllVideo: () => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pauseOtherVideo = exports.pauseAllVideo = exports.pauseAllAudio = void 0;
7
+ var pauseAllAudio = exports.pauseAllAudio = function pauseAllAudio() {
8
+ var audio = document.getElementById('fxMessageAudio');
9
+ audio === null || audio === void 0 ? void 0 : audio.pause();
10
+ return audio;
11
+ };
12
+ var pauseOtherVideo = exports.pauseOtherVideo = function pauseOtherVideo(idClient) {
13
+ var videoElements = document.getElementsByTagName('video');
14
+ for (var i = 0; i < videoElements.length; i++) {
15
+ if (videoElements[i].id !== "fxMessageVideo-".concat(idClient)) {
16
+ videoElements[i].pause();
17
+ }
18
+ }
19
+ };
20
+ var pauseAllVideo = exports.pauseAllVideo = function pauseAllVideo() {
21
+ var videoElements = document.getElementsByTagName('video');
22
+ for (var i = 0; i < videoElements.length; i++) {
23
+ if (videoElements[i].id.startsWith('fxMessageVideo-')) {
24
+ videoElements[i].pause();
25
+ }
26
+ }
27
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  export interface IParseSessionProps {
5
6
  prefix?: string;
@@ -8,14 +9,7 @@ export interface IParseSessionProps {
8
9
  msg: IMMessage;
9
10
  isSessionEnd?: boolean;
10
11
  onChartHistoryClick?: Function;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }
17
- export declare const pauseAllAudio: () => HTMLAudioElement;
18
- export declare const pauseOtherVideo: (idClient: string) => void;
19
- export declare const pauseAllVideo: () => void;
20
14
  declare const ParseSession: React.FC<IParseSessionProps>;
21
15
  export default ParseSession;