whyuzeim 1.1.39 → 1.1.41
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/cjs/HighlyCustomChat/index.js +50 -36
- package/es/HighlyCustomChat/index.js +50 -36
- package/package.json +1 -1
|
@@ -18,10 +18,12 @@ var _setInterval = require('@babel/runtime-corejs3/core-js-stable/set-interval')
|
|
|
18
18
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
19
19
|
var React = require('react');
|
|
20
20
|
var agoraChatUikit = require('agora-chat-uikit');
|
|
21
|
+
var jsrsasign = require('jsrsasign');
|
|
21
22
|
var context = require('../IM/context.js');
|
|
22
23
|
var type = require('../type.js');
|
|
23
24
|
var tools = require('../tools.js');
|
|
24
25
|
var avatar_default = require('../Icon/avatar_default.svg.js');
|
|
26
|
+
var encryption = require('../IM/encryption.js');
|
|
25
27
|
require('./style/index.scss');
|
|
26
28
|
|
|
27
29
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -62,9 +64,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
62
64
|
currentConversation = _useState6[0],
|
|
63
65
|
setCurrentConversation = _useState6[1];
|
|
64
66
|
var _useState7 = React.useState(true),
|
|
65
|
-
_useState8 = _slicedToArray(_useState7, 2)
|
|
66
|
-
_useState8[0]
|
|
67
|
-
|
|
67
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
68
|
+
isAgent = _useState8[0],
|
|
69
|
+
setIsAgent = _useState8[1];
|
|
68
70
|
var renderTxtMsg = function renderTxtMsg(msg) {
|
|
69
71
|
var _userInfo$uid;
|
|
70
72
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
|
|
@@ -313,34 +315,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
313
315
|
// 初始检查登录状态
|
|
314
316
|
var currentLoginState = agoraChatUikit.rootStore.loginState;
|
|
315
317
|
setLoading(!currentLoginState);
|
|
316
|
-
if (!agoraChatUikit.rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
|
|
317
|
-
manulLoginRef.current = true;
|
|
318
|
-
// http.get("/capi/account/imuser/getkeypair", {
|
|
319
|
-
// params: { type: 2 },
|
|
320
|
-
// }).then((result1)=>{
|
|
321
|
-
// const publickey = result1.data.data.publickey;
|
|
322
|
-
// // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
|
|
323
|
-
// const publicPemKey =
|
|
324
|
-
// "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
|
|
325
|
-
// const pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
|
|
326
|
-
// const enc = jsrsasign.KJUR.crypto.Cipher.encrypt(
|
|
327
|
-
// aesKey,
|
|
328
|
-
// pub as jsrsasign.RSAKey,
|
|
329
|
-
// "RSAOAEP"
|
|
330
|
-
// );
|
|
331
|
-
// http.get("/capi/account/imuser/getutoken", {
|
|
332
|
-
// params: { type: 2, token: jsrsasign.hextob64(enc) },
|
|
333
|
-
// }).then((result2)=>{
|
|
334
|
-
// const token = aesDecrypt(result2.data.data.utoken, aesKey);
|
|
335
|
-
// client.open({
|
|
336
|
-
// user: userInfo.uid,
|
|
337
|
-
// accessToken:token,
|
|
338
|
-
// })
|
|
339
|
-
// }).catch(error=>{
|
|
340
|
-
// console.log(error,'rewrew')
|
|
341
|
-
// })
|
|
342
|
-
// })
|
|
343
|
-
}
|
|
344
318
|
if (currentLoginState && props.conversationId) {
|
|
345
319
|
initConversation();
|
|
346
320
|
getHeaderInfo();
|
|
@@ -348,6 +322,34 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
348
322
|
var intervalId = _setInterval(function () {
|
|
349
323
|
// 如果登录状态发生变化
|
|
350
324
|
console.log("Agora login state:", agoraChatUikit.rootStore.loginState);
|
|
325
|
+
if (!agoraChatUikit.rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
|
|
326
|
+
manulLoginRef.current = true;
|
|
327
|
+
http.get("/capi/account/imuser/getkeypair", {
|
|
328
|
+
params: {
|
|
329
|
+
type: 2
|
|
330
|
+
}
|
|
331
|
+
}).then(function (result1) {
|
|
332
|
+
var publickey = result1.data.data.publickey;
|
|
333
|
+
// const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
|
|
334
|
+
var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
|
|
335
|
+
var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
|
|
336
|
+
var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(encryption.aesKey, pub, "RSAOAEP");
|
|
337
|
+
http.get("/capi/account/imuser/getutoken", {
|
|
338
|
+
params: {
|
|
339
|
+
type: 2,
|
|
340
|
+
token: jsrsasign.hextob64(enc)
|
|
341
|
+
}
|
|
342
|
+
}).then(function (result2) {
|
|
343
|
+
var token = encryption.aesDecrypt(result2.data.data.utoken, encryption.aesKey);
|
|
344
|
+
client.open({
|
|
345
|
+
user: userInfo.uid,
|
|
346
|
+
accessToken: token
|
|
347
|
+
});
|
|
348
|
+
})["catch"](function (error) {
|
|
349
|
+
console.log(error, 'rewrew');
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
351
353
|
if (agoraChatUikit.rootStore.loginState) {
|
|
352
354
|
if (onLoginSuccess) {
|
|
353
355
|
onLoginSuccess();
|
|
@@ -376,7 +378,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
376
378
|
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
377
379
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
378
380
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
|
|
379
|
-
var txtMessage;
|
|
381
|
+
var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
|
|
380
382
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
381
383
|
while (1) switch (_context2.prev = _context2.next) {
|
|
382
384
|
case 0:
|
|
@@ -397,6 +399,22 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
397
399
|
_context2.next = 6;
|
|
398
400
|
return agoraChatUikit.rootStore.messageStore.sendMessage(txtMessage);
|
|
399
401
|
case 6:
|
|
402
|
+
if (isAgent) {
|
|
403
|
+
cuiScrollList = document.querySelector(".cui-scrollList div");
|
|
404
|
+
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
405
|
+
if (cuiScrollList) {
|
|
406
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\">Mar</span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
407
|
+
template = document.createElement('template');
|
|
408
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
409
|
+
node = template.content.firstChild;
|
|
410
|
+
if (node) {
|
|
411
|
+
cuiScrollList.appendChild(node);
|
|
412
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
413
|
+
top: 1000000000
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
400
418
|
afterSendMsg(txtMessage);
|
|
401
419
|
_context2.next = 13;
|
|
402
420
|
break;
|
|
@@ -437,11 +455,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
437
455
|
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
438
456
|
return item.conversationId === props.conversationId;
|
|
439
457
|
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
440
|
-
var _conversationList$fin2;
|
|
441
458
|
cuiScrollList.removeChild(generatingLoader);
|
|
442
|
-
console.log((_conversationList$fin2 = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
443
|
-
return item.conversationId === props.conversationId;
|
|
444
|
-
})) === null || _conversationList$fin2 === void 0 || (_conversationList$fin2 = _conversationList$fin2.lastMessage) === null || _conversationList$fin2 === void 0 ? void 0 : _conversationList$fin2.to, props.conversationId, 'fdsfsd');
|
|
445
459
|
}
|
|
446
460
|
}, [conversationList, props.conversationId]);
|
|
447
461
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -16,10 +16,12 @@ import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
|
|
|
16
16
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
17
17
|
import React, { useRef, useContext, useState, useCallback, useEffect } from 'react';
|
|
18
18
|
import { useClient, useSDK, useConversationContext, rootStore, MessageList, MessageInput, ImageMessage, FileMessage, VideoMessage, BaseMessage } from 'agora-chat-uikit';
|
|
19
|
+
import jsrsasign from 'jsrsasign';
|
|
19
20
|
import { Context } from '../IM/context.js';
|
|
20
21
|
import { commonMessageInputConfig, commonMessageProps } from '../type.js';
|
|
21
22
|
import { reportAgentInUse } from '../tools.js';
|
|
22
23
|
import img from '../Icon/avatar_default.svg.js';
|
|
24
|
+
import { aesKey, aesDecrypt } from '../IM/encryption.js';
|
|
23
25
|
import './style/index.scss';
|
|
24
26
|
|
|
25
27
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -60,9 +62,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
60
62
|
currentConversation = _useState6[0],
|
|
61
63
|
setCurrentConversation = _useState6[1];
|
|
62
64
|
var _useState7 = useState(true),
|
|
63
|
-
_useState8 = _slicedToArray(_useState7, 2)
|
|
64
|
-
_useState8[0]
|
|
65
|
-
|
|
65
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
66
|
+
isAgent = _useState8[0],
|
|
67
|
+
setIsAgent = _useState8[1];
|
|
66
68
|
var renderTxtMsg = function renderTxtMsg(msg) {
|
|
67
69
|
var _userInfo$uid;
|
|
68
70
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
|
|
@@ -311,34 +313,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
311
313
|
// 初始检查登录状态
|
|
312
314
|
var currentLoginState = rootStore.loginState;
|
|
313
315
|
setLoading(!currentLoginState);
|
|
314
|
-
if (!rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
|
|
315
|
-
manulLoginRef.current = true;
|
|
316
|
-
// http.get("/capi/account/imuser/getkeypair", {
|
|
317
|
-
// params: { type: 2 },
|
|
318
|
-
// }).then((result1)=>{
|
|
319
|
-
// const publickey = result1.data.data.publickey;
|
|
320
|
-
// // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
|
|
321
|
-
// const publicPemKey =
|
|
322
|
-
// "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
|
|
323
|
-
// const pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
|
|
324
|
-
// const enc = jsrsasign.KJUR.crypto.Cipher.encrypt(
|
|
325
|
-
// aesKey,
|
|
326
|
-
// pub as jsrsasign.RSAKey,
|
|
327
|
-
// "RSAOAEP"
|
|
328
|
-
// );
|
|
329
|
-
// http.get("/capi/account/imuser/getutoken", {
|
|
330
|
-
// params: { type: 2, token: jsrsasign.hextob64(enc) },
|
|
331
|
-
// }).then((result2)=>{
|
|
332
|
-
// const token = aesDecrypt(result2.data.data.utoken, aesKey);
|
|
333
|
-
// client.open({
|
|
334
|
-
// user: userInfo.uid,
|
|
335
|
-
// accessToken:token,
|
|
336
|
-
// })
|
|
337
|
-
// }).catch(error=>{
|
|
338
|
-
// console.log(error,'rewrew')
|
|
339
|
-
// })
|
|
340
|
-
// })
|
|
341
|
-
}
|
|
342
316
|
if (currentLoginState && props.conversationId) {
|
|
343
317
|
initConversation();
|
|
344
318
|
getHeaderInfo();
|
|
@@ -346,6 +320,34 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
346
320
|
var intervalId = _setInterval(function () {
|
|
347
321
|
// 如果登录状态发生变化
|
|
348
322
|
console.log("Agora login state:", rootStore.loginState);
|
|
323
|
+
if (!rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
|
|
324
|
+
manulLoginRef.current = true;
|
|
325
|
+
http.get("/capi/account/imuser/getkeypair", {
|
|
326
|
+
params: {
|
|
327
|
+
type: 2
|
|
328
|
+
}
|
|
329
|
+
}).then(function (result1) {
|
|
330
|
+
var publickey = result1.data.data.publickey;
|
|
331
|
+
// const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
|
|
332
|
+
var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
|
|
333
|
+
var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
|
|
334
|
+
var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(aesKey, pub, "RSAOAEP");
|
|
335
|
+
http.get("/capi/account/imuser/getutoken", {
|
|
336
|
+
params: {
|
|
337
|
+
type: 2,
|
|
338
|
+
token: jsrsasign.hextob64(enc)
|
|
339
|
+
}
|
|
340
|
+
}).then(function (result2) {
|
|
341
|
+
var token = aesDecrypt(result2.data.data.utoken, aesKey);
|
|
342
|
+
client.open({
|
|
343
|
+
user: userInfo.uid,
|
|
344
|
+
accessToken: token
|
|
345
|
+
});
|
|
346
|
+
})["catch"](function (error) {
|
|
347
|
+
console.log(error, 'rewrew');
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
}
|
|
349
351
|
if (rootStore.loginState) {
|
|
350
352
|
if (onLoginSuccess) {
|
|
351
353
|
onLoginSuccess();
|
|
@@ -374,7 +376,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
374
376
|
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
375
377
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
376
378
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
|
|
377
|
-
var txtMessage;
|
|
379
|
+
var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
|
|
378
380
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
379
381
|
while (1) switch (_context2.prev = _context2.next) {
|
|
380
382
|
case 0:
|
|
@@ -395,6 +397,22 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
395
397
|
_context2.next = 6;
|
|
396
398
|
return rootStore.messageStore.sendMessage(txtMessage);
|
|
397
399
|
case 6:
|
|
400
|
+
if (isAgent) {
|
|
401
|
+
cuiScrollList = document.querySelector(".cui-scrollList div");
|
|
402
|
+
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
403
|
+
if (cuiScrollList) {
|
|
404
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\">Mar</span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
405
|
+
template = document.createElement('template');
|
|
406
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
407
|
+
node = template.content.firstChild;
|
|
408
|
+
if (node) {
|
|
409
|
+
cuiScrollList.appendChild(node);
|
|
410
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
411
|
+
top: 1000000000
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
398
416
|
afterSendMsg(txtMessage);
|
|
399
417
|
_context2.next = 13;
|
|
400
418
|
break;
|
|
@@ -435,11 +453,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
435
453
|
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
436
454
|
return item.conversationId === props.conversationId;
|
|
437
455
|
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
438
|
-
var _conversationList$fin2;
|
|
439
456
|
cuiScrollList.removeChild(generatingLoader);
|
|
440
|
-
console.log((_conversationList$fin2 = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
441
|
-
return item.conversationId === props.conversationId;
|
|
442
|
-
})) === null || _conversationList$fin2 === void 0 || (_conversationList$fin2 = _conversationList$fin2.lastMessage) === null || _conversationList$fin2 === void 0 ? void 0 : _conversationList$fin2.to, props.conversationId, 'fdsfsd');
|
|
443
457
|
}
|
|
444
458
|
}, [conversationList, props.conversationId]);
|
|
445
459
|
return /*#__PURE__*/React.createElement("div", {
|