isdata-customer-sdk 0.1.64 → 0.1.66
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/dist/index.common.js +79 -22
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +79 -22
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +3 -3
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -29587,6 +29587,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29587
29587
|
getPortalUserInfo: function() { return /* reexport */ getPortalUserInfo; },
|
|
29588
29588
|
getPortalUserMappingInfos: function() { return /* reexport */ getPortalUserMappingInfos; },
|
|
29589
29589
|
getPortalUserSig: function() { return /* reexport */ getPortalUserSig; },
|
|
29590
|
+
getRobotInfoByID: function() { return /* reexport */ getRobotInfoByID; },
|
|
29590
29591
|
getRoleIDsByUserAndGroupID: function() { return /* reexport */ getRoleIDsByUserAndGroupID; },
|
|
29591
29592
|
getThirdAppPathByKey: function() { return /* reexport */ getThirdAppPathByKey; },
|
|
29592
29593
|
getUrlParamValue: function() { return /* reexport */ getUrlParamValue; },
|
|
@@ -30835,6 +30836,7 @@ class ChatClientMgr {
|
|
|
30835
30836
|
this.userID = params.userID;
|
|
30836
30837
|
this.chatType = params.chatType || 0;
|
|
30837
30838
|
this.singleChatID = params.singleChatID || "";
|
|
30839
|
+
this.customParams = params.customParams || {};
|
|
30838
30840
|
this.chartOrigin = params.chartOrigin;
|
|
30839
30841
|
console.log("ChatClientMgr init:", this.actionKey);
|
|
30840
30842
|
// this.charAIs = {};
|
|
@@ -30906,7 +30908,8 @@ class ChatClientMgr {
|
|
|
30906
30908
|
await this.initChatAIs();
|
|
30907
30909
|
let charParams = {
|
|
30908
30910
|
type: this.getChatTypeKey(this.chatType),
|
|
30909
|
-
singleChatID: this.singleChatID
|
|
30911
|
+
singleChatID: this.singleChatID,
|
|
30912
|
+
customParams: this.customParams
|
|
30910
30913
|
};
|
|
30911
30914
|
console.log("charParams", charParams);
|
|
30912
30915
|
this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
|
|
@@ -30929,10 +30932,28 @@ class ChatClientMgr {
|
|
|
30929
30932
|
}
|
|
30930
30933
|
}
|
|
30931
30934
|
async initChatAIs() {
|
|
30932
|
-
|
|
30933
|
-
|
|
30934
|
-
|
|
30935
|
-
|
|
30935
|
+
if (window.imClient) {
|
|
30936
|
+
this.chatAIClient = window.imClient;
|
|
30937
|
+
} else {
|
|
30938
|
+
let classDatas = await this.handler.getChatClientClasses();
|
|
30939
|
+
const {
|
|
30940
|
+
TencentCloudChat,
|
|
30941
|
+
TIMUploadPlugin
|
|
30942
|
+
} = classDatas;
|
|
30943
|
+
window.imClient = TencentCloudChat.create({
|
|
30944
|
+
SDKAppID: this.appSKID,
|
|
30945
|
+
// 替换为你的 SDKAppID
|
|
30946
|
+
storage: {
|
|
30947
|
+
enable: true // 启用存储(可选,根据需求)
|
|
30948
|
+
}
|
|
30949
|
+
});
|
|
30950
|
+
window.imClient.registerPlugin({
|
|
30951
|
+
"tim-upload-plugin": TIMUploadPlugin
|
|
30952
|
+
});
|
|
30953
|
+
window.imClient.on(TencentCloudChat.EVENT.SDK_READY, this.onChatAIReady.bind(this));
|
|
30954
|
+
window.imClient.charAIs = {};
|
|
30955
|
+
this.chatAIClient = window.imClient;
|
|
30956
|
+
}
|
|
30936
30957
|
if (!this.chatAIClient.charAIs) {
|
|
30937
30958
|
this.chatAIClient.charAIs = {};
|
|
30938
30959
|
}
|
|
@@ -30944,19 +30965,7 @@ class ChatClientMgr {
|
|
|
30944
30965
|
robot.chatID = robotKey;
|
|
30945
30966
|
let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
|
|
30946
30967
|
if (!userSig) {
|
|
30947
|
-
|
|
30948
|
-
SDKAppID: this.appSKID,
|
|
30949
|
-
userID: robotKey
|
|
30950
|
-
});
|
|
30951
|
-
userSig = sigIDObject.userSig;
|
|
30952
|
-
if (userSig) {
|
|
30953
|
-
await this.chatAIClient.login({
|
|
30954
|
-
userID: robotKey,
|
|
30955
|
-
userSig: userSig
|
|
30956
|
-
});
|
|
30957
|
-
await this.chatAIClient.logout();
|
|
30958
|
-
await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
|
|
30959
|
-
}
|
|
30968
|
+
userSig = await this.generateUserSigAndUpdate(robotKey);
|
|
30960
30969
|
}
|
|
30961
30970
|
robot.userSig = userSig;
|
|
30962
30971
|
this.chatAIClient.charAIs[robotKey] = {
|
|
@@ -30967,6 +30976,22 @@ class ChatClientMgr {
|
|
|
30967
30976
|
});
|
|
30968
30977
|
}
|
|
30969
30978
|
}
|
|
30979
|
+
async generateUserSigAndUpdate(robotKey) {
|
|
30980
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
30981
|
+
SDKAppID: this.appSKID,
|
|
30982
|
+
userID: robotKey
|
|
30983
|
+
});
|
|
30984
|
+
let userSig = sigIDObject.userSig;
|
|
30985
|
+
if (userSig) {
|
|
30986
|
+
await this.chatAIClient.login({
|
|
30987
|
+
userID: robotKey,
|
|
30988
|
+
userSig: userSig
|
|
30989
|
+
});
|
|
30990
|
+
await this.chatAIClient.logout();
|
|
30991
|
+
await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
|
|
30992
|
+
}
|
|
30993
|
+
return userSig;
|
|
30994
|
+
}
|
|
30970
30995
|
onChatAIReady(event) {
|
|
30971
30996
|
let robotID = this.chatAIClient.lastRobotID;
|
|
30972
30997
|
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
@@ -31005,10 +31030,30 @@ class ChatClientMgr {
|
|
|
31005
31030
|
if (this.chatAIClient.lastRobotID) {
|
|
31006
31031
|
await this.chatAIClient.logout();
|
|
31007
31032
|
}
|
|
31008
|
-
|
|
31009
|
-
|
|
31010
|
-
|
|
31011
|
-
|
|
31033
|
+
try {
|
|
31034
|
+
await this.chatAIClient.login({
|
|
31035
|
+
userID: robotID,
|
|
31036
|
+
userSig: robotInfo.userSig
|
|
31037
|
+
});
|
|
31038
|
+
} catch (err) {
|
|
31039
|
+
console.log(`[AI chat]${robotInfo.name}登录失败`, err);
|
|
31040
|
+
let code = err.code;
|
|
31041
|
+
if (code == 70001) {
|
|
31042
|
+
console.log(`[AI chat]${robotInfo.name}UserSig过期,重新生成userSig`);
|
|
31043
|
+
let newUserSig = await this.generateUserSigAndUpdate(robotID);
|
|
31044
|
+
try {
|
|
31045
|
+
await this.chatAIClient.login({
|
|
31046
|
+
userID: robotID,
|
|
31047
|
+
userSig: newUserSig
|
|
31048
|
+
});
|
|
31049
|
+
this.sendMessageToChatServer(robotID, messageOption);
|
|
31050
|
+
return;
|
|
31051
|
+
} catch (err) {
|
|
31052
|
+
console.log(`[AI chat]${robotInfo.name}重新登录失败`, err);
|
|
31053
|
+
return;
|
|
31054
|
+
}
|
|
31055
|
+
}
|
|
31056
|
+
}
|
|
31012
31057
|
}
|
|
31013
31058
|
this.chatAIClient.lastRobotID = robotID;
|
|
31014
31059
|
if (this.chatAIClient && this.chatAIClient.isReady()) {
|
|
@@ -31061,6 +31106,18 @@ class ChatClientMgr {
|
|
|
31061
31106
|
|
|
31062
31107
|
|
|
31063
31108
|
|
|
31109
|
+
|
|
31110
|
+
const getRobotInfoByID = async (robotID, groupID) => {
|
|
31111
|
+
let queryData = {
|
|
31112
|
+
"param": {
|
|
31113
|
+
"id": robotID,
|
|
31114
|
+
"groupID": groupID
|
|
31115
|
+
}
|
|
31116
|
+
};
|
|
31117
|
+
let result = await request.post(`/dataservice/rest/orchestration/getRobotInfoByID`, queryData);
|
|
31118
|
+
let robotInfo = result.data.robotInfo;
|
|
31119
|
+
return robotInfo;
|
|
31120
|
+
};
|
|
31064
31121
|
const getIMHanlder = customerHanlder => {
|
|
31065
31122
|
let handler = {
|
|
31066
31123
|
genTestUserSig: async data => {
|