@fle-ui/plus-im-record 0.0.8-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.
- package/es/@types/index.d.ts +620 -0
- package/es/CardTag/index.d.ts +3 -0
- package/es/CardTag/index.js +18 -0
- package/es/ChatMessageItem/index.d.ts +15 -0
- package/es/ChatMessageItem/index.js +130 -0
- package/es/ChatMessageItem/index.less +108 -0
- package/es/ChatMessageList/index.d.ts +28 -0
- package/es/ChatMessageList/index.js +58 -0
- package/es/ChatMessageList/index.less +34 -0
- package/es/GoodsCard/index.d.ts +15 -0
- package/es/GoodsCard/index.js +95 -0
- package/es/GoodsCard/index.less +49 -0
- package/es/GoodsOrderCard/index.d.ts +14 -0
- package/es/GoodsOrderCard/index.js +161 -0
- package/es/GoodsOrderCard/index.less +81 -0
- package/es/Icon/index.d.ts +8 -0
- package/es/Icon/index.js +11 -0
- package/es/ParseSession/AudioPlayer.d.ts +14 -0
- package/es/ParseSession/AudioPlayer.js +89 -0
- package/es/ParseSession/audioAndVideoTool.d.ts +3 -0
- package/es/ParseSession/audioAndVideoTool.js +21 -0
- package/es/ParseSession/index.d.ts +15 -0
- package/es/ParseSession/index.js +492 -0
- package/es/ParseSession/index.less +226 -0
- package/es/api/index.d.ts +30 -0
- package/es/api/index.js +48 -0
- package/es/audioAndVideoTool.d.ts +3 -0
- package/es/audioAndVideoTool.js +21 -0
- package/es/common/const/index.d.ts +46 -0
- package/es/common/const/index.js +82 -0
- package/es/common/utils/index.d.ts +33 -0
- package/es/common/utils/index.js +169 -0
- package/es/index.d.ts +28 -0
- package/es/index.js +77 -0
- package/es/styles/extends.less +50 -0
- package/es/styles/index.less +35 -0
- package/es/styles/vars.less +8 -0
- package/es/utils/index.d.ts +14 -0
- package/es/utils/index.js +50 -0
- package/lib/@types/index.d.ts +620 -0
- package/lib/CardTag/index.d.ts +3 -0
- package/lib/CardTag/index.js +25 -0
- package/lib/ChatMessageItem/index.d.ts +15 -0
- package/lib/ChatMessageItem/index.js +136 -0
- package/lib/ChatMessageItem/index.less +108 -0
- package/lib/ChatMessageList/index.d.ts +28 -0
- package/lib/ChatMessageList/index.js +65 -0
- package/lib/ChatMessageList/index.less +34 -0
- package/lib/GoodsCard/index.d.ts +15 -0
- package/lib/GoodsCard/index.js +105 -0
- package/lib/GoodsCard/index.less +49 -0
- package/lib/GoodsOrderCard/index.d.ts +14 -0
- package/lib/GoodsOrderCard/index.js +169 -0
- package/lib/GoodsOrderCard/index.less +81 -0
- package/lib/Icon/index.d.ts +8 -0
- package/lib/Icon/index.js +18 -0
- package/lib/ParseSession/AudioPlayer.d.ts +14 -0
- package/lib/ParseSession/AudioPlayer.js +98 -0
- package/lib/ParseSession/audioAndVideoTool.d.ts +3 -0
- package/lib/ParseSession/audioAndVideoTool.js +27 -0
- package/lib/ParseSession/index.d.ts +15 -0
- package/lib/ParseSession/index.js +494 -0
- package/lib/ParseSession/index.less +226 -0
- package/lib/api/index.d.ts +30 -0
- package/lib/api/index.js +55 -0
- package/lib/audioAndVideoTool.d.ts +3 -0
- package/lib/audioAndVideoTool.js +27 -0
- package/lib/common/const/index.d.ts +46 -0
- package/lib/common/const/index.js +88 -0
- package/lib/common/utils/index.d.ts +33 -0
- package/lib/common/utils/index.js +183 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.js +86 -0
- package/lib/styles/extends.less +50 -0
- package/lib/styles/index.less +35 -0
- package/lib/styles/vars.less +8 -0
- package/lib/utils/index.d.ts +14 -0
- package/lib/utils/index.js +56 -0
- package/package.json +2 -2
|
@@ -0,0 +1,492 @@
|
|
|
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
|
+
import "antd/es/message/style";
|
|
3
|
+
import _message from "antd/es/message";
|
|
4
|
+
import "antd/es/button/style";
|
|
5
|
+
import _Button from "antd/es/button";
|
|
6
|
+
import "antd/es/image/style";
|
|
7
|
+
import _Image from "antd/es/image";
|
|
8
|
+
import "antd/es/space/style";
|
|
9
|
+
import _Space from "antd/es/space";
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
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."); }
|
|
15
|
+
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); }
|
|
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; }
|
|
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; } }
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import reactStringReplace from 'react-string-replace';
|
|
21
|
+
import { parseFileSize, addUrlSearch } from '../utils';
|
|
22
|
+
import { ProForm, ProFormText } from '@ant-design/pro-components';
|
|
23
|
+
import { DownloadOutlined } from '@ant-design/icons';
|
|
24
|
+
import { fileTypes, imMsgTypes } from '../common/const';
|
|
25
|
+
import { downloadByUrl, getSimplifyMsg } from '../common/utils';
|
|
26
|
+
import Icon from '../Icon';
|
|
27
|
+
import GoodsCard from '../GoodsCard';
|
|
28
|
+
import GoodsOrderCard from '../GoodsOrderCard';
|
|
29
|
+
import { ImContext } from '..';
|
|
30
|
+
import { pauseAllAudio, pauseOtherVideo } from '../audioAndVideoTool';
|
|
31
|
+
import AudioPlayer from './AudioPlayer';
|
|
32
|
+
import './index.less';
|
|
33
|
+
//
|
|
34
|
+
var ParseSession = function ParseSession(_ref) {
|
|
35
|
+
var prefix = _ref.prefix,
|
|
36
|
+
keyword = _ref.keyword,
|
|
37
|
+
msg = _ref.msg,
|
|
38
|
+
h5 = _ref.h5,
|
|
39
|
+
isSessionEnd = _ref.isSessionEnd,
|
|
40
|
+
onChartHistoryClick = _ref.onChartHistoryClick,
|
|
41
|
+
recordSession = _ref.recordSession;
|
|
42
|
+
var _useContext = useContext(ImContext),
|
|
43
|
+
api = _useContext.api;
|
|
44
|
+
var formRef = useRef();
|
|
45
|
+
var _useState = useState(),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
contactInfo = _useState2[0],
|
|
48
|
+
setContactInfo = _useState2[1];
|
|
49
|
+
var attach = msg.attach || {};
|
|
50
|
+
var renderText = function renderText(preset) {
|
|
51
|
+
if (attach.refMsg) {
|
|
52
|
+
return renderRefMsg();
|
|
53
|
+
}
|
|
54
|
+
var text = reactStringReplace(attach.content, /(https?:\/\/\S+)/gi, function (match) {
|
|
55
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
56
|
+
key: msg.idClient,
|
|
57
|
+
href: match,
|
|
58
|
+
target: "_blank",
|
|
59
|
+
rel: "noreferrer"
|
|
60
|
+
}, match);
|
|
61
|
+
});
|
|
62
|
+
var renderKeywordText = function renderKeywordText(str) {
|
|
63
|
+
if (!str || !keyword || typeof str !== 'string') return str;
|
|
64
|
+
var strArr = str.split(keyword);
|
|
65
|
+
return strArr.map(function (item, index) {
|
|
66
|
+
var isKeyword = index < strArr.length - 1;
|
|
67
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
key: index
|
|
69
|
+
}, item, isKeyword && /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
style: {
|
|
71
|
+
backgroundColor: 'orange',
|
|
72
|
+
borderRadius: 3
|
|
73
|
+
}
|
|
74
|
+
}, keyword));
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "".concat(prefix, "-text")
|
|
79
|
+
}, preset || text.map(renderKeywordText));
|
|
80
|
+
};
|
|
81
|
+
var renderRefMsg = function renderRefMsg() {
|
|
82
|
+
var refContent = attach.refMsg.type !== 'text' ? JSON.parse(attach.refMsg.content) : attach.refMsg.content;
|
|
83
|
+
var nickname = attach.refMsg.nickname;
|
|
84
|
+
var content = attach.content;
|
|
85
|
+
var renderers = {
|
|
86
|
+
image: function image() {
|
|
87
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: "".concat(prefix, "-ref-img-body")
|
|
89
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
90
|
+
src: refContent.url,
|
|
91
|
+
alt: ""
|
|
92
|
+
}));
|
|
93
|
+
},
|
|
94
|
+
video: function video() {
|
|
95
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: "".concat(prefix, "-ref-video-body")
|
|
97
|
+
}, /*#__PURE__*/React.createElement("video", {
|
|
98
|
+
key: msg.idServer,
|
|
99
|
+
playsInline: true,
|
|
100
|
+
preload: "auto",
|
|
101
|
+
controls: true,
|
|
102
|
+
autoPlay: false,
|
|
103
|
+
onLoadedData: function onLoadedData(event) {
|
|
104
|
+
return event.currentTarget.pause();
|
|
105
|
+
}
|
|
106
|
+
}, /*#__PURE__*/React.createElement("source", {
|
|
107
|
+
src: refContent.url,
|
|
108
|
+
type: "video/mp4"
|
|
109
|
+
}), "Your browser does not support the video element."));
|
|
110
|
+
},
|
|
111
|
+
audio: function audio() {
|
|
112
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: "".concat(prefix, "-ref-audio-body")
|
|
114
|
+
}, /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
115
|
+
style: {
|
|
116
|
+
backgroundColor: '#fff',
|
|
117
|
+
borderRadius: 4,
|
|
118
|
+
width: 80
|
|
119
|
+
},
|
|
120
|
+
prefix: prefix || '',
|
|
121
|
+
msg: msg,
|
|
122
|
+
url: refContent.url,
|
|
123
|
+
dur: refContent.dur,
|
|
124
|
+
text: refContent.text
|
|
125
|
+
}));
|
|
126
|
+
},
|
|
127
|
+
file: function file() {
|
|
128
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
129
|
+
className: "".concat(prefix, "-ref-file")
|
|
130
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Icon, {
|
|
131
|
+
className: "".concat(prefix, "-file-icon"),
|
|
132
|
+
type: 'icon-wenjian',
|
|
133
|
+
style: {
|
|
134
|
+
fontSize: 16
|
|
135
|
+
}
|
|
136
|
+
}), /*#__PURE__*/React.createElement("a", {
|
|
137
|
+
style: {
|
|
138
|
+
marginLeft: 8
|
|
139
|
+
},
|
|
140
|
+
download: refContent.fileName,
|
|
141
|
+
href: addUrlSearch(refContent.url, "download=".concat(refContent.fileName)),
|
|
142
|
+
target: "_blank",
|
|
143
|
+
rel: "noreferrer"
|
|
144
|
+
}, refContent.fileName)));
|
|
145
|
+
},
|
|
146
|
+
product: function product() {
|
|
147
|
+
return /*#__PURE__*/React.createElement(GoodsCard, {
|
|
148
|
+
prefix: prefix,
|
|
149
|
+
content: refContent
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
order: function order() {
|
|
153
|
+
return /*#__PURE__*/React.createElement(GoodsOrderCard, {
|
|
154
|
+
prefix: prefix,
|
|
155
|
+
recordSession: recordSession,
|
|
156
|
+
orderSn: refContent.orderSn,
|
|
157
|
+
orderId: refContent.orderId
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
text: function text() {
|
|
161
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
className: "".concat(prefix, "-ref-text-body")
|
|
163
|
+
}, refContent);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
167
|
+
className: "".concat(prefix, "-ref")
|
|
168
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
169
|
+
className: "".concat(prefix, "-ref-body")
|
|
170
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "".concat(prefix, "-ref-nickname")
|
|
172
|
+
}, nickname, ":"), renderers[attach.refMsg.type]()), /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
className: "".concat(prefix, "-text")
|
|
174
|
+
}, content));
|
|
175
|
+
};
|
|
176
|
+
var renderImage = function renderImage() {
|
|
177
|
+
return /*#__PURE__*/React.createElement(_Image, {
|
|
178
|
+
loading: "lazy",
|
|
179
|
+
className: "".concat(prefix, "-image"),
|
|
180
|
+
fallback: "https://yx-web-nosdn.netease.im/common/33d3e1fa8de771277ea4466564ef37aa/emptyImg.png",
|
|
181
|
+
src: "".concat(attach.content.url, "?x-oss-process=image/resize,h_150,m_lfit"),
|
|
182
|
+
height: 150,
|
|
183
|
+
preview: {
|
|
184
|
+
src: attach.content.url,
|
|
185
|
+
toolbarRender: function toolbarRender(originalNode) {
|
|
186
|
+
var _originalNode$props;
|
|
187
|
+
return h5 ? null : /*#__PURE__*/React.createElement(_Space, {
|
|
188
|
+
size: 12,
|
|
189
|
+
className: "fx-preview-toolbar-wrapper"
|
|
190
|
+
}, /*#__PURE__*/React.createElement(DownloadOutlined, {
|
|
191
|
+
onClick: function onClick() {
|
|
192
|
+
attach.content.url && downloadByUrl(attach.content.url);
|
|
193
|
+
}
|
|
194
|
+
}), (_originalNode$props = originalNode.props) === null || _originalNode$props === void 0 ? void 0 : _originalNode$props.children);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
var renderFaq = function renderFaq() {
|
|
200
|
+
var faqList = attach.content || [];
|
|
201
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
202
|
+
className: "".concat(prefix, "-helps")
|
|
203
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
204
|
+
src: "https://qa-oss.elebuys.com/tmpdir/202402241614290002520093.png"
|
|
205
|
+
}), faqList.map(function (item) {
|
|
206
|
+
return /*#__PURE__*/React.createElement("p", {
|
|
207
|
+
key: item.id,
|
|
208
|
+
onClick: function onClick() {}
|
|
209
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
210
|
+
className: "title"
|
|
211
|
+
}, item.title), /*#__PURE__*/React.createElement(Icon, {
|
|
212
|
+
type: 'icon-zhankaishouqi',
|
|
213
|
+
rotate: -90,
|
|
214
|
+
style: {
|
|
215
|
+
color: '#aaa',
|
|
216
|
+
fontSize: 13,
|
|
217
|
+
flexShrink: 0,
|
|
218
|
+
fontWeight: 400
|
|
219
|
+
}
|
|
220
|
+
}));
|
|
221
|
+
}));
|
|
222
|
+
};
|
|
223
|
+
var renderFaqLink = function renderFaqLink() {
|
|
224
|
+
var _attach$content, _attach$content2, _attach$content3;
|
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
226
|
+
className: "".concat(prefix, "-faqlink")
|
|
227
|
+
}, /*#__PURE__*/React.createElement("h3", null, (_attach$content = attach.content) === null || _attach$content === void 0 ? void 0 : _attach$content.title), /*#__PURE__*/React.createElement("a", {
|
|
228
|
+
href: (_attach$content2 = attach.content) === null || _attach$content2 === void 0 ? void 0 : _attach$content2.url,
|
|
229
|
+
target: "_blank",
|
|
230
|
+
rel: "noreferrer"
|
|
231
|
+
}, (_attach$content3 = attach.content) === null || _attach$content3 === void 0 ? void 0 : _attach$content3.url));
|
|
232
|
+
};
|
|
233
|
+
useEffect(function () {
|
|
234
|
+
if (attach.type === 'formCustomer' && msg.idServer) {
|
|
235
|
+
api.getContact({
|
|
236
|
+
msgId: msg.idServer
|
|
237
|
+
}).then(function (res) {
|
|
238
|
+
var _formRef$current;
|
|
239
|
+
setContactInfo(res.data);
|
|
240
|
+
(_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.setFieldsValue(res.data || {});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}, [msg.idServer, attach.type, attach.submission]);
|
|
244
|
+
var isSubmitForm = useMemo(function () {
|
|
245
|
+
if (contactInfo && contactInfo.contactName && contactInfo.contactPhone || attach.submission) {
|
|
246
|
+
return true;
|
|
247
|
+
} else {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}, [contactInfo, attach]);
|
|
251
|
+
var renderFormCustomer = function renderFormCustomer() {
|
|
252
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "".concat(prefix, "-form")
|
|
254
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
255
|
+
src: "https://qa-oss.elebuys.com/tmpdir/202402261955060002520212.png"
|
|
256
|
+
}), /*#__PURE__*/React.createElement(ProForm, {
|
|
257
|
+
formRef: formRef,
|
|
258
|
+
autoFocusFirstInput: false,
|
|
259
|
+
disabled: isSubmitForm || isSessionEnd,
|
|
260
|
+
initialValues: contactInfo || {},
|
|
261
|
+
submitter: {
|
|
262
|
+
render: function render() {
|
|
263
|
+
return /*#__PURE__*/React.createElement(_Button, {
|
|
264
|
+
style: {
|
|
265
|
+
width: '100%'
|
|
266
|
+
},
|
|
267
|
+
type: "primary",
|
|
268
|
+
size: "large",
|
|
269
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
270
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
271
|
+
while (1) switch (_context.prev = _context.next) {
|
|
272
|
+
case 0:
|
|
273
|
+
case "end":
|
|
274
|
+
return _context.stop();
|
|
275
|
+
}
|
|
276
|
+
}, _callee);
|
|
277
|
+
}))
|
|
278
|
+
}, isSubmitForm ? '已提交' : '提交');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}, /*#__PURE__*/React.createElement(ProFormText, {
|
|
282
|
+
rules: [{
|
|
283
|
+
required: true,
|
|
284
|
+
message: '请输入企业名称'
|
|
285
|
+
}],
|
|
286
|
+
name: "enterpriseName",
|
|
287
|
+
placeholder: "\u8BF7\u8F93\u5165\u4F01\u4E1A\u540D\u79F0"
|
|
288
|
+
}), /*#__PURE__*/React.createElement(ProFormText, {
|
|
289
|
+
rules: [{
|
|
290
|
+
required: true,
|
|
291
|
+
message: '请输入姓名'
|
|
292
|
+
}],
|
|
293
|
+
name: "contactName",
|
|
294
|
+
placeholder: "\u8BF7\u8F93\u5165\u8054\u7CFB\u4EBA\u59D3\u540D"
|
|
295
|
+
}), /*#__PURE__*/React.createElement(ProFormText, {
|
|
296
|
+
rules: [{
|
|
297
|
+
required: true,
|
|
298
|
+
message: '请输入手机号'
|
|
299
|
+
}, {
|
|
300
|
+
validator: function () {
|
|
301
|
+
var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_, value) {
|
|
302
|
+
var reg;
|
|
303
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
304
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
305
|
+
case 0:
|
|
306
|
+
reg = /^1\d{10}$/;
|
|
307
|
+
if (!(value && (value === null || value === void 0 ? void 0 : value.length) !== 11 && !reg.test(value))) {
|
|
308
|
+
_context2.next = 5;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
return _context2.abrupt("return", Promise.reject(new Error('手机号格式不正确')));
|
|
312
|
+
case 5:
|
|
313
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
314
|
+
case 6:
|
|
315
|
+
case "end":
|
|
316
|
+
return _context2.stop();
|
|
317
|
+
}
|
|
318
|
+
}, _callee2);
|
|
319
|
+
}));
|
|
320
|
+
function validator(_x, _x2) {
|
|
321
|
+
return _validator.apply(this, arguments);
|
|
322
|
+
}
|
|
323
|
+
return validator;
|
|
324
|
+
}()
|
|
325
|
+
}],
|
|
326
|
+
name: "contactPhone",
|
|
327
|
+
placeholder: "\u8BF7\u8F93\u5165\u60A8\u7684\u8054\u7CFB\u7535\u8BDD"
|
|
328
|
+
})));
|
|
329
|
+
};
|
|
330
|
+
var renderNotification = function renderNotification() {
|
|
331
|
+
return null;
|
|
332
|
+
};
|
|
333
|
+
var renderAudio = function renderAudio() {
|
|
334
|
+
var flow = msg.flow;
|
|
335
|
+
var duration = Math.floor(attach.content.dur) || 0;
|
|
336
|
+
return /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
337
|
+
prefix: prefix || '',
|
|
338
|
+
msg: msg,
|
|
339
|
+
url: attach.content.url,
|
|
340
|
+
dur: duration
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
var renderVideo = function renderVideo() {
|
|
344
|
+
var _attach$content4;
|
|
345
|
+
var url = "".concat(attach.content.url, "?download=").concat(msg.idClient, ".").concat((_attach$content4 = attach.content) === null || _attach$content4 === void 0 ? void 0 : _attach$content4.ext);
|
|
346
|
+
var poster = "".concat(attach.content.url, "?x-oss-process=video/snapshot,t_100,f_jpg,m_fast");
|
|
347
|
+
return /*#__PURE__*/React.createElement("video", {
|
|
348
|
+
poster: poster,
|
|
349
|
+
playsInline: true,
|
|
350
|
+
preload: "auto",
|
|
351
|
+
src: url,
|
|
352
|
+
id: "fxMessageVideo-".concat(msg.idClient),
|
|
353
|
+
controls: true,
|
|
354
|
+
onPlay: function onPlay() {
|
|
355
|
+
pauseOtherVideo(msg.idClient);
|
|
356
|
+
pauseAllAudio();
|
|
357
|
+
}
|
|
358
|
+
// onCanPlay={(e: any) => {
|
|
359
|
+
// setTimeout(() => {
|
|
360
|
+
// e.target?.pause();
|
|
361
|
+
// }, 0);
|
|
362
|
+
// }}
|
|
363
|
+
,
|
|
364
|
+
onError: function onError() {
|
|
365
|
+
_message.warning('视频播放失败');
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
var renderFile = function renderFile() {
|
|
370
|
+
var _attach$content5, _attach$content6, _attach$content7;
|
|
371
|
+
if (fileTypes.video.includes((_attach$content5 = attach.content) === null || _attach$content5 === void 0 ? void 0 : _attach$content5.ext)) {
|
|
372
|
+
return renderVideo();
|
|
373
|
+
}
|
|
374
|
+
if (fileTypes.audio.includes((_attach$content6 = attach.content) === null || _attach$content6 === void 0 ? void 0 : _attach$content6.ext)) {
|
|
375
|
+
return renderAudio();
|
|
376
|
+
}
|
|
377
|
+
if (fileTypes.img.includes((_attach$content7 = attach.content) === null || _attach$content7 === void 0 ? void 0 : _attach$content7.ext)) {
|
|
378
|
+
return renderImage();
|
|
379
|
+
}
|
|
380
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
381
|
+
className: "".concat(prefix, "-file")
|
|
382
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
383
|
+
className: "".concat(prefix, "-file-icon"),
|
|
384
|
+
type: 'icon-wenjian'
|
|
385
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
386
|
+
className: "".concat(prefix, "-file-info")
|
|
387
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
388
|
+
download: attach.content.fileName,
|
|
389
|
+
href: addUrlSearch(attach.content.url, "download=".concat(attach.content.fileName)),
|
|
390
|
+
target: "_blank",
|
|
391
|
+
rel: "noreferrer"
|
|
392
|
+
}, attach.content.fileName), /*#__PURE__*/React.createElement("span", null, parseFileSize(attach.content.size))));
|
|
393
|
+
};
|
|
394
|
+
var renderOrderCard = function renderOrderCard() {
|
|
395
|
+
var _attach$content8, _attach$content9;
|
|
396
|
+
return /*#__PURE__*/React.createElement(GoodsOrderCard, {
|
|
397
|
+
prefix: prefix,
|
|
398
|
+
recordSession: recordSession,
|
|
399
|
+
orderSn: (_attach$content8 = attach.content) === null || _attach$content8 === void 0 ? void 0 : _attach$content8.orderSn,
|
|
400
|
+
orderId: (_attach$content9 = attach.content) === null || _attach$content9 === void 0 ? void 0 : _attach$content9.orderId
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
var renderGoodsCard = function renderGoodsCard() {
|
|
404
|
+
return /*#__PURE__*/React.createElement(GoodsCard, {
|
|
405
|
+
prefix: prefix,
|
|
406
|
+
content: attach.content || {}
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
var renderChartRecord = function renderChartRecord() {
|
|
410
|
+
var _attach$content10, _attach$content11, _attach$content12;
|
|
411
|
+
var records = ((_attach$content10 = attach.content) === null || _attach$content10 === void 0 ? void 0 : _attach$content10.items) || [];
|
|
412
|
+
var msgIds = ((_attach$content11 = attach.content) === null || _attach$content11 === void 0 ? void 0 : _attach$content11.msgIds) || [];
|
|
413
|
+
var title = (_attach$content12 = attach.content) === null || _attach$content12 === void 0 ? void 0 : _attach$content12.title;
|
|
414
|
+
var list = records.filter(function (v) {
|
|
415
|
+
var _v$attach;
|
|
416
|
+
return ![imMsgTypes.event].includes((_v$attach = v.attach) === null || _v$attach === void 0 ? void 0 : _v$attach.type);
|
|
417
|
+
}).slice(0, 4);
|
|
418
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "".concat(prefix, "-charthistory"),
|
|
420
|
+
onClick: function onClick() {
|
|
421
|
+
return onChartHistoryClick === null || onChartHistoryClick === void 0 ? void 0 : onChartHistoryClick({
|
|
422
|
+
title: title,
|
|
423
|
+
msgIds: msgIds
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}, /*#__PURE__*/React.createElement("h4", null, title), list.map(function (item, i) {
|
|
427
|
+
return /*#__PURE__*/React.createElement("p", {
|
|
428
|
+
key: i,
|
|
429
|
+
className: "one-line-text"
|
|
430
|
+
}, item.from, ": ", getSimplifyMsg(item));
|
|
431
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
432
|
+
className: "".concat(prefix, "-charthistory-from")
|
|
433
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
434
|
+
className: "".concat(prefix, "-charthistory-from-icon")
|
|
435
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
436
|
+
type: 'icon-kefu',
|
|
437
|
+
style: {
|
|
438
|
+
fontSize: 12,
|
|
439
|
+
color: '#fff'
|
|
440
|
+
}
|
|
441
|
+
})), "\u7CFB\u7EDF\u8F6C\u53D1"));
|
|
442
|
+
};
|
|
443
|
+
var renderOfflineSupport = function renderOfflineSupport() {
|
|
444
|
+
var _attach$content13, _attach$content14;
|
|
445
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
446
|
+
className: "".concat(prefix, "-text")
|
|
447
|
+
}, (_attach$content13 = attach.content) === null || _attach$content13 === void 0 ? void 0 : _attach$content13.supportDesc, ((_attach$content14 = attach.content) === null || _attach$content14 === void 0 ? void 0 : _attach$content14.contact) && /*#__PURE__*/React.createElement("a", {
|
|
448
|
+
href: "tel:".concat(attach.content.contact),
|
|
449
|
+
rel: "noreferrer"
|
|
450
|
+
}, attach.content.contact));
|
|
451
|
+
};
|
|
452
|
+
var renderMsgContent = function renderMsgContent() {
|
|
453
|
+
try {
|
|
454
|
+
switch (attach.type) {
|
|
455
|
+
case imMsgTypes.text:
|
|
456
|
+
return renderText();
|
|
457
|
+
case imMsgTypes.image:
|
|
458
|
+
return renderImage();
|
|
459
|
+
case imMsgTypes.video:
|
|
460
|
+
return renderVideo();
|
|
461
|
+
case imMsgTypes.audio:
|
|
462
|
+
return renderAudio();
|
|
463
|
+
case imMsgTypes.link:
|
|
464
|
+
return renderText();
|
|
465
|
+
case imMsgTypes.file:
|
|
466
|
+
return renderFile();
|
|
467
|
+
case imMsgTypes.faq:
|
|
468
|
+
return renderFaq();
|
|
469
|
+
case imMsgTypes.faqLink:
|
|
470
|
+
return renderFaqLink();
|
|
471
|
+
case imMsgTypes.formCustomer:
|
|
472
|
+
return renderFormCustomer();
|
|
473
|
+
case imMsgTypes.tip:
|
|
474
|
+
return renderNotification();
|
|
475
|
+
case imMsgTypes.order:
|
|
476
|
+
return renderOrderCard();
|
|
477
|
+
case imMsgTypes.product:
|
|
478
|
+
return renderGoodsCard();
|
|
479
|
+
case imMsgTypes.chatrecord:
|
|
480
|
+
return renderChartRecord();
|
|
481
|
+
case imMsgTypes.offlineSupport:
|
|
482
|
+
return renderOfflineSupport();
|
|
483
|
+
default:
|
|
484
|
+
return '';
|
|
485
|
+
}
|
|
486
|
+
} catch (error) {
|
|
487
|
+
return '';
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderMsgContent());
|
|
491
|
+
};
|
|
492
|
+
export default ParseSession;
|