isdata-customer-sdk 0.2.74 → 0.2.76
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/cjs/dify.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/portal.js +1 -1
- package/dist/esm/dify.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/portal.js +1 -1
- package/dist/index.common.js +1779 -2301
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +1779 -2301
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +4 -4
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +10 -10
- package/dist/cjs/chat.js.map +0 -1
- package/dist/cjs/dify.js.map +0 -1
- package/dist/cjs/event.js.map +0 -1
- package/dist/cjs/i18n.js.map +0 -1
- package/dist/cjs/iframe.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/portal.js.map +0 -1
- package/dist/cjs/security.js.map +0 -1
- package/dist/cjs/sms.js.map +0 -1
- package/dist/cjs/utils.js.map +0 -1
- package/dist/esm/chat.js.map +0 -1
- package/dist/esm/dify.js.map +0 -1
- package/dist/esm/event.js.map +0 -1
- package/dist/esm/i18n.js.map +0 -1
- package/dist/esm/iframe.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/portal.js.map +0 -1
- package/dist/esm/security.js.map +0 -1
- package/dist/esm/sms.js.map +0 -1
- package/dist/esm/utils.js.map +0 -1
package/dist/index.common.js
CHANGED
|
@@ -29558,42 +29558,38 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29558
29558
|
addWindowTrustedOrigin: function() { return /* reexport */ addWindowTrustedOrigin; },
|
|
29559
29559
|
checkTextFormat: function() { return /* reexport */ checkTextFormat; },
|
|
29560
29560
|
createFileFromUrl: function() { return /* reexport */ createFileFromUrl; },
|
|
29561
|
-
|
|
29561
|
+
decrypt: function() { return /* reexport */ decrypt; },
|
|
29562
29562
|
destroyEventCenter: function() { return /* reexport */ destroyEventCenter; },
|
|
29563
|
-
|
|
29563
|
+
encrypt: function() { return /* reexport */ encrypt; },
|
|
29564
29564
|
extractFilenameFromUrl: function() { return /* reexport */ extractFilenameFromUrl; },
|
|
29565
29565
|
extractNewItems: function() { return /* reexport */ extractNewItems; },
|
|
29566
|
-
findClosestAncestorByClass: function() { return /* reexport */ findClosestAncestorByClass; },
|
|
29567
29566
|
fireEvent: function() { return /* reexport */ fireEvent; },
|
|
29568
29567
|
getAIRobotInfos: function() { return /* reexport */ getAIRobotInfos; },
|
|
29569
29568
|
getAPPInfosByID: function() { return /* reexport */ getAPPInfosByID; },
|
|
29570
|
-
getAccountCountByName: function() { return /* reexport */ getAccountCountByName; },
|
|
29571
|
-
getAllI18nTypes: function() { return /* reexport */ getAllI18nTypes; },
|
|
29572
29569
|
getAllUserInfosByGroupID: function() { return /* reexport */ getAllUserInfosByGroupID; },
|
|
29573
29570
|
getAppCustomData: function() { return /* reexport */ getAppCustomData; },
|
|
29574
29571
|
getAppPortalMenuDatas: function() { return /* reexport */ getAppPortalMenuDatas; },
|
|
29575
29572
|
getAuthPic: function() { return /* reexport */ getAuthPic; },
|
|
29576
29573
|
getChildrenOfficeInfosByID: function() { return /* reexport */ getChildrenOfficeInfosByID; },
|
|
29577
|
-
getClientIp: function() { return /* reexport */ getClientIp; },
|
|
29578
29574
|
getCurrentAppID: function() { return /* reexport */ getCurrentAppID; },
|
|
29579
29575
|
getCurrentUserPortalMapping: function() { return /* reexport */ getCurrentUserPortalMapping; },
|
|
29580
29576
|
getCurrentUserPortalPageID: function() { return /* reexport */ getCurrentUserPortalPageID; },
|
|
29581
29577
|
getDifyFileType: function() { return /* reexport */ getDifyFileType; },
|
|
29582
29578
|
getFileSize: function() { return /* reexport */ getFileSize; },
|
|
29583
|
-
getGourpMappingsByPhoneNumber: function() { return /* reexport */ getGourpMappingsByPhoneNumber; },
|
|
29584
29579
|
getGroupMappingsByAccount: function() { return /* reexport */ getGroupMappingsByAccount; },
|
|
29585
29580
|
getI18nKey: function() { return /* reexport */ getI18nKey; },
|
|
29586
29581
|
getIMHanlder: function() { return /* reexport */ getIMHanlder; },
|
|
29587
29582
|
getIntegrateAppInfoByID: function() { return /* reexport */ getIntegrateAppInfoByID; },
|
|
29583
|
+
getKey: function() { return /* reexport */ getKey; },
|
|
29588
29584
|
getLanguages: function() { return /* reexport */ getLanguages; },
|
|
29589
29585
|
getLoginPageNotices: function() { return /* reexport */ getLoginPageNotices; },
|
|
29586
|
+
getLoginPortalAccountKey: function() { return /* reexport */ getLoginPortalAccountKey; },
|
|
29590
29587
|
getMappingAppInfoByID: function() { return /* reexport */ getMappingAppInfoByID; },
|
|
29591
29588
|
getMenuDatasByGroupID: function() { return /* reexport */ getMenuDatasByGroupID; },
|
|
29592
29589
|
getMenuMappingDatasByRoleIDs: function() { return /* reexport */ getMenuMappingDatasByRoleIDs; },
|
|
29593
29590
|
getObjectUseTimes: function() { return /* reexport */ getObjectUseTimes; },
|
|
29594
29591
|
getOfficeInfosByIDs: function() { return /* reexport */ getOfficeInfosByIDs; },
|
|
29595
29592
|
getPageIDByComponentID: function() { return /* reexport */ getPageIDByComponentID; },
|
|
29596
|
-
getPhoneNumberByAccountName: function() { return /* reexport */ getPhoneNumberByAccountName; },
|
|
29597
29593
|
getPlatformBortherMenusByMenuID: function() { return /* reexport */ getPlatformBortherMenusByMenuID; },
|
|
29598
29594
|
getPlatformMenuMappingsByRoleIDs: function() { return /* reexport */ getPlatformMenuMappingsByRoleIDs; },
|
|
29599
29595
|
getPojectDptsByUserAndGroupID: function() { return /* reexport */ getPojectDptsByUserAndGroupID; },
|
|
@@ -29601,7 +29597,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29601
29597
|
getPortalAccessToken: function() { return /* reexport */ getPortalAccessToken; },
|
|
29602
29598
|
getPortalAppCustomConfig: function() { return /* reexport */ getPortalAppCustomConfig; },
|
|
29603
29599
|
getPortalDocmentInfo: function() { return /* reexport */ getPortalDocmentInfo; },
|
|
29604
|
-
getPortalInfosByID: function() { return /* reexport */ getPortalInfosByID; },
|
|
29605
29600
|
getPortalNotices: function() { return /* reexport */ getPortalNotices; },
|
|
29606
29601
|
getPortalPageConfig: function() { return /* reexport */ getPortalPageConfig; },
|
|
29607
29602
|
getPortalPageMenuID: function() { return /* reexport */ getPortalPageMenuID; },
|
|
@@ -29610,26 +29605,19 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29610
29605
|
getPortalUserSig: function() { return /* reexport */ getPortalUserSig; },
|
|
29611
29606
|
getRobotInfoByID: function() { return /* reexport */ getRobotInfoByID; },
|
|
29612
29607
|
getRoleIDsByUserAndGroupID: function() { return /* reexport */ getRoleIDsByUserAndGroupID; },
|
|
29613
|
-
getTenetInfoByName: function() { return /* reexport */ getTenetInfoByName; },
|
|
29614
29608
|
getThirdAppPathByKey: function() { return /* reexport */ getThirdAppPathByKey; },
|
|
29615
29609
|
getUrlParamValue: function() { return /* reexport */ getUrlParamValue; },
|
|
29616
29610
|
getUserAllMappngPortal: function() { return /* reexport */ getUserAllMappngPortal; },
|
|
29617
|
-
|
|
29611
|
+
getUserID: function() { return /* reexport */ getUserID; },
|
|
29618
29612
|
hasListener: function() { return /* reexport */ hasListener; },
|
|
29619
|
-
hasUrlParams: function() { return /* reexport */ hasUrlParams; },
|
|
29620
29613
|
i18n: function() { return /* reexport */ i18n; },
|
|
29621
|
-
i18nText: function() { return /* reexport */ i18nText; },
|
|
29622
29614
|
initDomNodeI18NObserver: function() { return /* reexport */ initDomNodeI18NObserver; },
|
|
29623
|
-
initDomNodeViewObserver: function() { return /* reexport */ initDomNodeViewObserver; },
|
|
29624
29615
|
initEventCenter: function() { return /* reexport */ initEventCenter; },
|
|
29625
29616
|
initFrameWindowListener: function() { return /* reexport */ initFrameWindowListener; },
|
|
29626
|
-
isSMSCodeValidate: function() { return /* reexport */ isSMSCodeValidate; },
|
|
29627
|
-
isSecurityAccount: function() { return /* reexport */ isSecurityAccount; },
|
|
29628
29617
|
loadi18nTexts: function() { return /* reexport */ loadi18nTexts; },
|
|
29629
29618
|
loginAccount: function() { return /* reexport */ loginAccount; },
|
|
29630
29619
|
logoutAccount: function() { return /* reexport */ logoutAccount; },
|
|
29631
29620
|
processElement: function() { return /* reexport */ processElement; },
|
|
29632
|
-
processViewElement: function() { return /* reexport */ processViewElement; },
|
|
29633
29621
|
queryAndStoreAppVariable: function() { return /* reexport */ queryAndStoreAppVariable; },
|
|
29634
29622
|
queryAppVariable: function() { return /* reexport */ queryAppVariable; },
|
|
29635
29623
|
queryAssetById: function() { return /* reexport */ queryAssetById; },
|
|
@@ -29640,22 +29628,15 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29640
29628
|
removeEventAction: function() { return /* reexport */ removeEventAction; },
|
|
29641
29629
|
removeEventListener: function() { return /* reexport */ removeEventListener; },
|
|
29642
29630
|
removeWindowTrustedOrigin: function() { return /* reexport */ removeWindowTrustedOrigin; },
|
|
29643
|
-
savePortalI18nText: function() { return /* reexport */ savePortalI18nText; },
|
|
29644
29631
|
sendPostToAIAgent: function() { return /* reexport */ sendPostToAIAgent; },
|
|
29645
|
-
sendSms: function() { return /* reexport */ sendSms; },
|
|
29646
29632
|
sendWindowMessage: function() { return /* reexport */ sendWindowMessage; },
|
|
29647
|
-
serverDecrypt: function() { return /* reexport */ serverDecrypt; },
|
|
29648
|
-
serverEncrypt: function() { return /* reexport */ serverEncrypt; },
|
|
29649
29633
|
setPortalPageConfig: function() { return /* reexport */ setPortalPageConfig; },
|
|
29650
29634
|
switchPortalLogin: function() { return /* reexport */ switchPortalLogin; },
|
|
29651
29635
|
transformPortalQuickMenuDatas: function() { return /* reexport */ transformPortalQuickMenuDatas; },
|
|
29652
29636
|
transformPortalSystemMenuDatas: function() { return /* reexport */ transformPortalSystemMenuDatas; },
|
|
29653
|
-
updateI18nValue: function() { return /* reexport */ updateI18nValue; },
|
|
29654
29637
|
updateIMMapping: function() { return /* reexport */ updateIMMapping; },
|
|
29655
29638
|
updateUserSelectPortal: function() { return /* reexport */ updateUserSelectPortal; },
|
|
29656
|
-
validateSSOPageLoaded: function() { return /* reexport */ validateSSOPageLoaded; }
|
|
29657
|
-
viewDecrypt: function() { return /* reexport */ viewDecrypt; },
|
|
29658
|
-
viewEncrypt: function() { return /* reexport */ viewEncrypt; }
|
|
29639
|
+
validateSSOPageLoaded: function() { return /* reexport */ validateSSOPageLoaded; }
|
|
29659
29640
|
});
|
|
29660
29641
|
|
|
29661
29642
|
;// ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
|
@@ -29930,9 +29911,7 @@ const getMenuDatasByGroupID = async (group_id, role_ids) => {
|
|
|
29930
29911
|
//缓存所有快捷访问菜单信息
|
|
29931
29912
|
for (const tempData of tempMenuDatas) {
|
|
29932
29913
|
let id = tempData.id;
|
|
29933
|
-
|
|
29934
|
-
// 只缓存启用状态的菜单
|
|
29935
|
-
if (!tempMap[id] && isList) {
|
|
29914
|
+
if (!tempMap[id]) {
|
|
29936
29915
|
finalMenuDatas.push(tempData);
|
|
29937
29916
|
tempMap[id] = tempData;
|
|
29938
29917
|
}
|
|
@@ -30038,118 +30017,32 @@ const getPortalDocmentInfo = async kb_doc_id => {
|
|
|
30038
30017
|
let docInfo = result.data.docInfo;
|
|
30039
30018
|
return docInfo;
|
|
30040
30019
|
};
|
|
30041
|
-
|
|
30042
|
-
|
|
30043
|
-
|
|
30044
|
-
|
|
30045
|
-
|
|
30046
|
-
|
|
30047
|
-
|
|
30048
|
-
|
|
30049
|
-
|
|
30050
|
-
|
|
30051
|
-
|
|
30052
|
-
|
|
30053
|
-
// queryData
|
|
30054
|
-
// );
|
|
30055
|
-
// return result;
|
|
30056
|
-
// };
|
|
30020
|
+
const getLoginPortalAccountKey = async (loginName, groupID) => {
|
|
30021
|
+
let queryData = {
|
|
30022
|
+
param: {
|
|
30023
|
+
loginData: {
|
|
30024
|
+
account: loginName,
|
|
30025
|
+
group_id: groupID
|
|
30026
|
+
}
|
|
30027
|
+
}
|
|
30028
|
+
};
|
|
30029
|
+
let result = await request.post(`/dataservice/rest/orchestration/getLoginPortalAccountKey`, queryData);
|
|
30030
|
+
return result;
|
|
30031
|
+
};
|
|
30057
30032
|
|
|
30058
30033
|
/**
|
|
30059
|
-
*
|
|
30034
|
+
* 获取该平台菜单同级得其他兄弟菜单
|
|
30060
30035
|
* @param {*} menu_id
|
|
30061
30036
|
* @returns
|
|
30062
30037
|
*/
|
|
30063
|
-
const getPlatformBortherMenusByMenuID = async
|
|
30038
|
+
const getPlatformBortherMenusByMenuID = async menu_id => {
|
|
30064
30039
|
let queryData_groupData = {
|
|
30065
30040
|
"param": {
|
|
30066
30041
|
"menu_id": menu_id
|
|
30067
30042
|
}
|
|
30068
30043
|
};
|
|
30069
30044
|
let result = await request.post(`/dataservice/rest/orchestration/getPlatformBortherMenusByMenuID`, queryData_groupData);
|
|
30070
|
-
let
|
|
30071
|
-
|
|
30072
|
-
//获取当前角色下对应的角色菜单权限的映射信息
|
|
30073
|
-
let roleMenuMappingDatas = await getPlatformMenuMappingsByRoleIDs(role_ids, group_id);
|
|
30074
|
-
let roleMenuMappingMap = {};
|
|
30075
|
-
for (const mappingData of roleMenuMappingDatas) {
|
|
30076
|
-
let menu_mapping_id = mappingData.menu_id;
|
|
30077
|
-
roleMenuMappingMap[menu_mapping_id] = mappingData;
|
|
30078
|
-
}
|
|
30079
|
-
let menuMaps = {};
|
|
30080
|
-
//缓存所有菜单信息
|
|
30081
|
-
for (const item of sysMenuDatas) {
|
|
30082
|
-
let id = item.id;
|
|
30083
|
-
let leaf_flag = item.leaf_flag;
|
|
30084
|
-
//如果是叶子节点 并且当前菜单ID在角色菜单映射信息中不存在,则跳过
|
|
30085
|
-
if (leaf_flag === 1 && !roleMenuMappingMap[id]) {
|
|
30086
|
-
continue;
|
|
30087
|
-
}
|
|
30088
|
-
// 如果当前菜单ID在角色菜单映射信息中存在,则表示该角色有权限访问该菜单
|
|
30089
|
-
if (!menuMaps[id]) {
|
|
30090
|
-
// let icon =item.icon;
|
|
30091
|
-
let iconClass = "el-icon-menu";
|
|
30092
|
-
// if(icon){
|
|
30093
|
-
// let obj = JSON.parse(icon);
|
|
30094
|
-
// iconClass =obj?.url?`#${obj.url}`:"el-icon-menu";
|
|
30095
|
-
// }
|
|
30096
|
-
let tempItem = {
|
|
30097
|
-
id: item.id,
|
|
30098
|
-
index: item.id,
|
|
30099
|
-
name: item.name,
|
|
30100
|
-
isSys: true,
|
|
30101
|
-
iconClass: iconClass,
|
|
30102
|
-
actionType: item.action_type || "1",
|
|
30103
|
-
// 默认值为1
|
|
30104
|
-
app_id: item.datapp_id,
|
|
30105
|
-
menu_id: item.id,
|
|
30106
|
-
url: item.url || "",
|
|
30107
|
-
children: item.children || [],
|
|
30108
|
-
sort: item.sort || 0
|
|
30109
|
-
};
|
|
30110
|
-
menuMaps[id] = tempItem;
|
|
30111
|
-
}
|
|
30112
|
-
}
|
|
30113
|
-
for (const item of sysMenuDatas) {
|
|
30114
|
-
let parent_id = item.parent_id;
|
|
30115
|
-
if (!parent_id) continue;
|
|
30116
|
-
let parentItem = menuMaps[parent_id];
|
|
30117
|
-
if (parentItem) {
|
|
30118
|
-
let menuItem = menuMaps[item.id];
|
|
30119
|
-
if (!menuItem) {
|
|
30120
|
-
continue;
|
|
30121
|
-
}
|
|
30122
|
-
parentItem.children.push(menuItem);
|
|
30123
|
-
}
|
|
30124
|
-
}
|
|
30125
|
-
let menuDatas = [];
|
|
30126
|
-
for (const key in menuMaps) {
|
|
30127
|
-
let item = menuMaps[key];
|
|
30128
|
-
if (item.children && item.children.length > 0) {
|
|
30129
|
-
menuDatas.push(item);
|
|
30130
|
-
let children = item.children;
|
|
30131
|
-
children.sort((data1, data2) => {
|
|
30132
|
-
if (Number.isNaN(data1.sort)) return 1;
|
|
30133
|
-
if (Number.isNaN(data2.sort)) return -1;
|
|
30134
|
-
return data1.sort - data2.sort;
|
|
30135
|
-
});
|
|
30136
|
-
}
|
|
30137
|
-
}
|
|
30138
|
-
//如果没有数据,说明只有一级节点父亲
|
|
30139
|
-
if (menuDatas.length == 0) {
|
|
30140
|
-
for (const key in menuMaps) {
|
|
30141
|
-
let item = menuMaps[key];
|
|
30142
|
-
if (item) {
|
|
30143
|
-
menuDatas.push(item);
|
|
30144
|
-
}
|
|
30145
|
-
}
|
|
30146
|
-
}
|
|
30147
|
-
menuDatas.sort((data1, data2) => {
|
|
30148
|
-
if (Number.isNaN(data1.sort)) return 1;
|
|
30149
|
-
if (Number.isNaN(data2.sort)) return -1;
|
|
30150
|
-
return data1.sort - data2.sort;
|
|
30151
|
-
});
|
|
30152
|
-
// console.log("getPlatformBortherMenusByMenuID",menuDatas);
|
|
30045
|
+
let menuDatas = result.data.menuDatas;
|
|
30153
30046
|
//获取菜单数据
|
|
30154
30047
|
return menuDatas;
|
|
30155
30048
|
};
|
|
@@ -30186,7 +30079,6 @@ const transformPortalData = (datas, menuTypes, filterObjectMap) => {
|
|
|
30186
30079
|
//缓存所有父亲菜单信息
|
|
30187
30080
|
for (let key in filterObjectMap) {
|
|
30188
30081
|
let item = filterObjectMap[key];
|
|
30189
|
-
if (!item) continue;
|
|
30190
30082
|
let parent_id = item.parent_id;
|
|
30191
30083
|
if (parent_id) {
|
|
30192
30084
|
parentMaps[parent_id] = true;
|
|
@@ -30202,15 +30094,12 @@ const transformPortalData = (datas, menuTypes, filterObjectMap) => {
|
|
|
30202
30094
|
sort: data.sort,
|
|
30203
30095
|
actionType: data.actionType,
|
|
30204
30096
|
url: data.url,
|
|
30205
|
-
iconClass: data.image
|
|
30206
|
-
parent_id: data.parent_id,
|
|
30097
|
+
iconClass: data.image,
|
|
30207
30098
|
children: [],
|
|
30208
30099
|
app_id: data.app_id,
|
|
30209
30100
|
menu_id: data.menu_id,
|
|
30210
30101
|
beyond_type: data.menu_type ? data.menu_type : "RJVIEW-OTHERS",
|
|
30211
|
-
beyond_type_sort: data.menu_type_sort ? data.menu_type_sort : 999
|
|
30212
|
-
type: "MenuItem",
|
|
30213
|
-
typeID: data.type
|
|
30102
|
+
beyond_type_sort: data.menu_type_sort ? data.menu_type_sort : 999
|
|
30214
30103
|
};
|
|
30215
30104
|
//如果存在快捷菜单映射数据或者是主菜单入口
|
|
30216
30105
|
//如果是主菜单或者存在快捷访问映射或者孩子存在快捷访问映射或者是应用默认的菜单,则纳入到菜单中
|
|
@@ -30251,15 +30140,13 @@ const transformPortalData = (datas, menuTypes, filterObjectMap) => {
|
|
|
30251
30140
|
index: tempType,
|
|
30252
30141
|
name: menuTypeObj.title,
|
|
30253
30142
|
children: [],
|
|
30254
|
-
sort: menuTypeObj.value
|
|
30255
|
-
type: "MenuType"
|
|
30143
|
+
sort: menuTypeObj.value
|
|
30256
30144
|
} : {
|
|
30257
30145
|
id: tempType,
|
|
30258
30146
|
index: tempType,
|
|
30259
30147
|
name: "其他",
|
|
30260
30148
|
children: [],
|
|
30261
|
-
sort: 999
|
|
30262
|
-
type: "MenuType"
|
|
30149
|
+
sort: 999
|
|
30263
30150
|
};
|
|
30264
30151
|
let type_childens = parentType.children;
|
|
30265
30152
|
type_childens.push(tempMenuData);
|
|
@@ -30286,12 +30173,9 @@ const transformPortalData = (datas, menuTypes, filterObjectMap) => {
|
|
|
30286
30173
|
break;
|
|
30287
30174
|
}
|
|
30288
30175
|
}
|
|
30289
|
-
|
|
30290
|
-
if (
|
|
30291
|
-
|
|
30292
|
-
if (filterObjectMap && !filterObjectMap[data.id] && count == 0) {
|
|
30293
|
-
continue;
|
|
30294
|
-
}
|
|
30176
|
+
//如果没有子菜单,则跳过
|
|
30177
|
+
if (count == 0) {
|
|
30178
|
+
continue;
|
|
30295
30179
|
}
|
|
30296
30180
|
menuList.push(tempMenuData);
|
|
30297
30181
|
let types = tempMenuData.children;
|
|
@@ -30471,41 +30355,6 @@ const getCurrentUserPortalMapping = async userData => {
|
|
|
30471
30355
|
return portal_id;
|
|
30472
30356
|
};
|
|
30473
30357
|
|
|
30474
|
-
/**
|
|
30475
|
-
* 获取当前用户默认的门户页面ID
|
|
30476
|
-
*
|
|
30477
|
-
* 该方法用于获取当前用户在门户中的默认页面ID
|
|
30478
|
-
* @param {信息} userData
|
|
30479
|
-
* @returns
|
|
30480
|
-
*/
|
|
30481
|
-
const getPortalInfosByID = async id => {
|
|
30482
|
-
let queryData = {
|
|
30483
|
-
param: {
|
|
30484
|
-
id: id
|
|
30485
|
-
}
|
|
30486
|
-
};
|
|
30487
|
-
let response = await request.post(`/dataservice/rest/orchestration/getPortalInfosByID`, queryData);
|
|
30488
|
-
let portalInfo = response.data.portalInfo;
|
|
30489
|
-
return portalInfo;
|
|
30490
|
-
};
|
|
30491
|
-
|
|
30492
|
-
/**
|
|
30493
|
-
* 通过租户名称模糊匹配获取租户信息
|
|
30494
|
-
*
|
|
30495
|
-
* @param {名称信息} name
|
|
30496
|
-
* @returns
|
|
30497
|
-
*/
|
|
30498
|
-
const getTenetInfoByName = async name => {
|
|
30499
|
-
let queryData = {
|
|
30500
|
-
param: {
|
|
30501
|
-
name: name
|
|
30502
|
-
}
|
|
30503
|
-
};
|
|
30504
|
-
let response = await request.post(`/dataservice/rest/orchestration/getTenetInfoByName`, queryData);
|
|
30505
|
-
let resultDatas = response.data.resultDatas;
|
|
30506
|
-
return resultDatas;
|
|
30507
|
-
};
|
|
30508
|
-
|
|
30509
30358
|
/**
|
|
30510
30359
|
* 获取当前用户在门户中的所有映射数据
|
|
30511
30360
|
* @param {信息} data
|
|
@@ -30616,11 +30465,10 @@ const getMappingAppInfoByID = async (appID, groupID) => {
|
|
|
30616
30465
|
*
|
|
30617
30466
|
* @returns 获取门户登录页面的公告信息
|
|
30618
30467
|
*/
|
|
30619
|
-
const getLoginPageNotices = async
|
|
30468
|
+
const getLoginPageNotices = async () => {
|
|
30620
30469
|
let queryData = {
|
|
30621
30470
|
param: {
|
|
30622
|
-
id: "1005"
|
|
30623
|
-
groupID: groupID // 集团ID
|
|
30471
|
+
id: "1005"
|
|
30624
30472
|
}
|
|
30625
30473
|
};
|
|
30626
30474
|
let resultData = await request.post(`/dataservice/rest/orchestration/getNoticeInfosByAppTypeID`, queryData);
|
|
@@ -30818,22 +30666,6 @@ const getGroupMappingsByAccount = async account => {
|
|
|
30818
30666
|
return tenetGroupDatas;
|
|
30819
30667
|
};
|
|
30820
30668
|
|
|
30821
|
-
/**
|
|
30822
|
-
* 通过手机号获取集团组织映射数据
|
|
30823
|
-
* @param {*} phone
|
|
30824
|
-
* @returns
|
|
30825
|
-
*/
|
|
30826
|
-
const getGourpMappingsByPhoneNumber = async phone => {
|
|
30827
|
-
let queryData = {
|
|
30828
|
-
param: {
|
|
30829
|
-
phone: phone
|
|
30830
|
-
}
|
|
30831
|
-
};
|
|
30832
|
-
let resultData = await request.post(`/dataservice/rest/orchestration/getGourpMappingsByPhoneNumber`, queryData);
|
|
30833
|
-
let tenetGroupDatas = resultData.data.resultGroups;
|
|
30834
|
-
return tenetGroupDatas;
|
|
30835
|
-
};
|
|
30836
|
-
|
|
30837
30669
|
/**
|
|
30838
30670
|
* 查询当前企业组织的集团组织ID
|
|
30839
30671
|
* @param id 组织ID
|
|
@@ -31011,37 +30843,6 @@ const getIntegrateAppInfoByID = async appID => {
|
|
|
31011
30843
|
let appInfo = result.data.appInfo;
|
|
31012
30844
|
return appInfo;
|
|
31013
30845
|
};
|
|
31014
|
-
|
|
31015
|
-
// 更新服务器i18n文本
|
|
31016
|
-
const savePortalI18nText = async (key, value, lang, beyondID, i18nType) => {
|
|
31017
|
-
let app_id = getPoratlAppID();
|
|
31018
|
-
let requestData = {
|
|
31019
|
-
param: {
|
|
31020
|
-
key: key,
|
|
31021
|
-
value: value,
|
|
31022
|
-
appID: app_id,
|
|
31023
|
-
lang: lang,
|
|
31024
|
-
beyondID: beyondID,
|
|
31025
|
-
i18nType: i18nType
|
|
31026
|
-
}
|
|
31027
|
-
};
|
|
31028
|
-
let result = await request.post(`/dataservice/rest/orchestration/savePortalI18nText`, requestData);
|
|
31029
|
-
let resultData = result.data.resultData;
|
|
31030
|
-
return resultData;
|
|
31031
|
-
};
|
|
31032
|
-
|
|
31033
|
-
// 通过账户名和租户获取手机号
|
|
31034
|
-
const getPhoneNumberByAccountName = async (accountName, groupID) => {
|
|
31035
|
-
let requestData = {
|
|
31036
|
-
param: {
|
|
31037
|
-
accountName: accountName,
|
|
31038
|
-
groupID: groupID
|
|
31039
|
-
}
|
|
31040
|
-
};
|
|
31041
|
-
let result = await request.post(`/dataservice/rest/orchestration/getPhoneNumberByAccountName`, requestData);
|
|
31042
|
-
let phone = result.data.phone;
|
|
31043
|
-
return phone;
|
|
31044
|
-
};
|
|
31045
30846
|
;// ./node_modules/ua-parser-js/src/main/ua-parser.mjs
|
|
31046
30847
|
// Generated ESM version of ua-parser-js
|
|
31047
30848
|
// DO NOT EDIT THIS FILE!
|
|
@@ -32533,2212 +32334,1890 @@ const getPhoneNumberByAccountName = async (accountName, groupID) => {
|
|
|
32533
32334
|
// EXTERNAL MODULE: ./node_modules/crypto-js/index.js
|
|
32534
32335
|
var crypto_js = __webpack_require__(1396);
|
|
32535
32336
|
var crypto_js_default = /*#__PURE__*/__webpack_require__.n(crypto_js);
|
|
32536
|
-
;//
|
|
32537
|
-
var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
|
|
32538
|
-
;// ./src/api/i18n/smardaten_i18n/table_i18n.js
|
|
32337
|
+
;// ./src/api/security.js
|
|
32539
32338
|
|
|
32540
|
-
|
|
32541
|
-
|
|
32542
|
-
|
|
32543
|
-
|
|
32544
|
-
|
|
32545
|
-
|
|
32546
|
-
|
|
32547
|
-
|
|
32339
|
+
|
|
32340
|
+
|
|
32341
|
+
|
|
32342
|
+
|
|
32343
|
+
/**
|
|
32344
|
+
*
|
|
32345
|
+
* @returns 获取登录验证码图片
|
|
32346
|
+
*/
|
|
32347
|
+
const getAuthPic = () => request.get(`/system/authority/getAuthPic?module=loginPassword`, {
|
|
32348
|
+
responseType: "arraybuffer"
|
|
32349
|
+
});
|
|
32350
|
+
|
|
32351
|
+
/**
|
|
32352
|
+
* 登出账号
|
|
32353
|
+
* @param endside_type 0: web 1:手机
|
|
32354
|
+
* @returns {Promise<*>}
|
|
32355
|
+
* @param endside_type 0: web 1:手机
|
|
32356
|
+
*
|
|
32357
|
+
*/
|
|
32358
|
+
const logoutAccount = async endside_type => {
|
|
32359
|
+
let resultData = await request.get(`/system/authority/logout?isMobileLogout=${endside_type}`);
|
|
32360
|
+
let response = JSON.parse(resultData.request.response);
|
|
32361
|
+
let resultCode = response.code;
|
|
32362
|
+
if (resultCode == "10110020") {
|
|
32363
|
+
window.sessionStorage.clear();
|
|
32364
|
+
return {
|
|
32365
|
+
code: resultCode,
|
|
32366
|
+
message: response.message
|
|
32367
|
+
};
|
|
32368
|
+
} else {
|
|
32369
|
+
return {
|
|
32370
|
+
code: resultCode,
|
|
32371
|
+
message: response.message
|
|
32372
|
+
};
|
|
32548
32373
|
}
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
|
|
32552
|
-
|
|
32553
|
-
|
|
32554
|
-
|
|
32555
|
-
|
|
32556
|
-
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
|
|
32560
|
-
|
|
32561
|
-
|
|
32562
|
-
|
|
32563
|
-
|
|
32564
|
-
|
|
32565
|
-
|
|
32566
|
-
|
|
32567
|
-
|
|
32568
|
-
|
|
32569
|
-
|
|
32374
|
+
};
|
|
32375
|
+
|
|
32376
|
+
/**
|
|
32377
|
+
* 解密
|
|
32378
|
+
*/
|
|
32379
|
+
const decrypt = async decryptStr => {
|
|
32380
|
+
let secretKey = await getKey();
|
|
32381
|
+
const decrypted = crypto_js_default().AES.decrypt(decryptStr, secretKey).toString((crypto_js_default()).enc.Utf8);
|
|
32382
|
+
return decrypted;
|
|
32383
|
+
};
|
|
32384
|
+
|
|
32385
|
+
/**
|
|
32386
|
+
* 解密
|
|
32387
|
+
*/
|
|
32388
|
+
const encrypt = async decryptStr => {
|
|
32389
|
+
let secretKey = await getKey();
|
|
32390
|
+
const encrypted = crypto_js_default().AES.encrypt(decryptStr, secretKey).toString();
|
|
32391
|
+
return encrypted;
|
|
32392
|
+
};
|
|
32393
|
+
|
|
32394
|
+
/**
|
|
32395
|
+
* 切换门户登录
|
|
32396
|
+
*/
|
|
32397
|
+
const switchPortalLogin = async (data, appid, endside_type) => {
|
|
32398
|
+
let old_key = window.sessionStorage.getItem("iportal_login_user_key");
|
|
32399
|
+
old_key = await decrypt(old_key);
|
|
32400
|
+
data.password = old_key;
|
|
32401
|
+
let resultData = await logoutAccount(endside_type);
|
|
32402
|
+
let resultCode = resultData.code;
|
|
32403
|
+
let message = resultData.message;
|
|
32404
|
+
//退出登录成功
|
|
32405
|
+
if (resultCode == "10110020") {
|
|
32406
|
+
let loginResult = await loginAccount(data, appid);
|
|
32407
|
+
return loginResult;
|
|
32408
|
+
} else {
|
|
32409
|
+
return {
|
|
32410
|
+
code: resultCode,
|
|
32411
|
+
message: message
|
|
32412
|
+
};
|
|
32570
32413
|
}
|
|
32571
|
-
|
|
32572
|
-
|
|
32573
|
-
|
|
32574
|
-
|
|
32575
|
-
|
|
32576
|
-
|
|
32577
|
-
|
|
32414
|
+
};
|
|
32415
|
+
const getUserID = async (acccountName, old_key, group_id) => {
|
|
32416
|
+
let queryData = {
|
|
32417
|
+
param: {
|
|
32418
|
+
accountName: acccountName,
|
|
32419
|
+
group_id: group_id,
|
|
32420
|
+
account_key: old_key
|
|
32421
|
+
}
|
|
32422
|
+
};
|
|
32423
|
+
let result = await request.post(`/dataservice/rest/orchestration/getUserID`, queryData);
|
|
32424
|
+
let persion_id = result.data.persion_id;
|
|
32425
|
+
return persion_id;
|
|
32426
|
+
};
|
|
32427
|
+
|
|
32428
|
+
/**
|
|
32429
|
+
* 登录账号
|
|
32430
|
+
* @param data 登录数据
|
|
32431
|
+
* @param appid 应用ID
|
|
32432
|
+
*
|
|
32433
|
+
* @description
|
|
32434
|
+
* 登录时需要传入验证码(authPicCode)和应用ID(dataappId),
|
|
32435
|
+
* mobileOrWeb参数用于区分是移动端还是网页端登录。
|
|
32436
|
+
*
|
|
32437
|
+
* @returns
|
|
32438
|
+
*/
|
|
32439
|
+
const loginAccount = async (data, appid) => {
|
|
32440
|
+
let result = await getLoginPortalAccountKey(data.account_view, data.groupid);
|
|
32441
|
+
let code = result.data.code;
|
|
32442
|
+
//获取key成功
|
|
32443
|
+
if (code == 10001) {
|
|
32444
|
+
//保存的真正一级密码
|
|
32445
|
+
let pwd_code = result.data.codeData.key;
|
|
32446
|
+
//缓存一级密码
|
|
32447
|
+
let old_key = pwd_code;
|
|
32448
|
+
//保存的正则2级密码
|
|
32449
|
+
let key_code = result.data.codeData.code;
|
|
32450
|
+
//反向解析一级密码
|
|
32451
|
+
pwd_code = await decrypt(pwd_code);
|
|
32452
|
+
//反向解析2级密码
|
|
32453
|
+
key_code = await decrypt(key_code);
|
|
32454
|
+
//密码匹配
|
|
32455
|
+
if (pwd_code == data.password) {
|
|
32456
|
+
//平台正向加密2级密码
|
|
32457
|
+
pwd_code = window.appSdk.Encrypt(key_code);
|
|
32458
|
+
data.password = pwd_code;
|
|
32459
|
+
result = await request.post(`/system/authority/loginAccount4Application?authPicCode=${data.imageCode}&dataappId=${appid}&mobileOrWeb=web`, data);
|
|
32460
|
+
let response = JSON.parse(result.request.response);
|
|
32461
|
+
code = response.code;
|
|
32462
|
+
//登录平台成功
|
|
32463
|
+
if (code == 10110004) {
|
|
32464
|
+
let id = await getUserID(data.account_view, old_key, data.groupid);
|
|
32465
|
+
// 初始化解析器
|
|
32466
|
+
const parser = new UAParser();
|
|
32467
|
+
// 获取浏览器信息
|
|
32468
|
+
const browser = parser.getBrowser();
|
|
32469
|
+
let timestamp = new Date().getTime();
|
|
32470
|
+
let clientID = browser.name + "_" + browser.version + "_" + timestamp;
|
|
32471
|
+
window.sessionStorage.setItem("iportal_login_user_id", id);
|
|
32472
|
+
window.sessionStorage.setItem("iportal_group_id", data.groupid);
|
|
32473
|
+
window.sessionStorage.setItem("iportal_login_user_key", old_key);
|
|
32474
|
+
window.sessionStorage.setItem("iportal_client_id", clientID);
|
|
32475
|
+
window.sessionStorage.setItem("iportal_app_id", appid);
|
|
32476
|
+
return {
|
|
32477
|
+
code: code
|
|
32478
|
+
};
|
|
32479
|
+
} else {
|
|
32480
|
+
return {
|
|
32481
|
+
code: code,
|
|
32482
|
+
message: response.message
|
|
32483
|
+
};
|
|
32484
|
+
}
|
|
32485
|
+
} else {
|
|
32486
|
+
return {
|
|
32487
|
+
code: code,
|
|
32488
|
+
message: "$L{账户密码错误}!"
|
|
32578
32489
|
};
|
|
32579
|
-
checkResult.result = true;
|
|
32580
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32581
|
-
return checkResult;
|
|
32582
32490
|
}
|
|
32583
32491
|
}
|
|
32584
|
-
|
|
32585
|
-
|
|
32586
|
-
|
|
32587
|
-
|
|
32588
|
-
|
|
32589
|
-
|
|
32590
|
-
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
|
|
32594
|
-
|
|
32595
|
-
|
|
32596
|
-
|
|
32597
|
-
|
|
32598
|
-
|
|
32599
|
-
|
|
32600
|
-
|
|
32601
|
-
|
|
32602
|
-
|
|
32603
|
-
|
|
32604
|
-
|
|
32605
|
-
|
|
32606
|
-
|
|
32607
|
-
|
|
32608
|
-
|
|
32609
|
-
|
|
32610
|
-
|
|
32611
|
-
|
|
32612
|
-
|
|
32613
|
-
|
|
32614
|
-
|
|
32615
|
-
|
|
32616
|
-
|
|
32617
|
-
|
|
32618
|
-
|
|
32619
|
-
|
|
32620
|
-
|
|
32621
|
-
|
|
32622
|
-
|
|
32623
|
-
|
|
32624
|
-
|
|
32625
|
-
|
|
32626
|
-
|
|
32627
|
-
|
|
32628
|
-
checkResult.result = true;
|
|
32629
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32630
|
-
return checkResult;
|
|
32631
|
-
}
|
|
32632
|
-
}
|
|
32633
|
-
// 检查分页组件 跳至xx页
|
|
32634
|
-
if (classes.contains("ant-pagination-options-quick-jumper")) {
|
|
32635
|
-
let innerHTML = element.innerHTML;
|
|
32636
|
-
if (innerHTML.includes("跳至") && innerHTML.includes("页") || innerHTML.includes("Go to") && innerHTML.includes("Page")) {
|
|
32637
|
-
// console.log("检查smardaten平台分页 跳至xx页 元素:",innerHTML);
|
|
32638
|
-
let scriptFunction = (appID, lang) => {
|
|
32639
|
-
let scriptNode = null;
|
|
32640
|
-
for (let node of element.childNodes) {
|
|
32641
|
-
// 检查是否为文本节点且包含"Total"
|
|
32642
|
-
if (node.tagName === "INPUT") {
|
|
32643
|
-
scriptNode = node;
|
|
32644
|
-
}
|
|
32645
|
-
}
|
|
32646
|
-
let scriptNodes = [{
|
|
32647
|
-
nodeType: Node.TEXT_NODE,
|
|
32648
|
-
key: '跳至'
|
|
32649
|
-
}, {
|
|
32650
|
-
nodeType: "SCRIPTNODE",
|
|
32651
|
-
node: scriptNode
|
|
32652
|
-
}, {
|
|
32653
|
-
nodeType: Node.TEXT_NODE,
|
|
32654
|
-
key: '页'
|
|
32655
|
-
}];
|
|
32656
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32657
|
-
let childNode = element.childNodes[i];
|
|
32658
|
-
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
32659
|
-
element.removeChild(childNode);
|
|
32660
|
-
}
|
|
32661
|
-
}
|
|
32662
|
-
for (let i = 0; i < scriptNodes.length; i++) {
|
|
32663
|
-
let scriptNodeItem = scriptNodes[i];
|
|
32664
|
-
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32665
|
-
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
32666
|
-
element.appendChild(textNode);
|
|
32667
|
-
}
|
|
32668
|
-
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
32669
|
-
element.appendChild(scriptNodeItem.node);
|
|
32670
|
-
}
|
|
32671
|
-
}
|
|
32672
|
-
};
|
|
32673
|
-
let tempHTMLMatch = {
|
|
32674
|
-
isScriptAction: true,
|
|
32675
|
-
scriptFunction: scriptFunction
|
|
32676
|
-
};
|
|
32677
|
-
checkResult.result = true;
|
|
32678
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32679
|
-
return checkResult;
|
|
32680
|
-
}
|
|
32681
|
-
}
|
|
32682
|
-
// 检查每页xx条
|
|
32683
|
-
if (classes.contains("ant-select-selection-item") || classes.contains("ant-select-item-option-content")) {
|
|
32684
|
-
let innerHTML = element.innerHTML;
|
|
32685
|
-
// console.log("检查smardaten平台分页 每页xx条 元素:",innerHTML);
|
|
32686
|
-
if (innerHTML.includes("/") && innerHTML.includes("page") || innerHTML.includes("/") && innerHTML.includes("条") && innerHTML.includes("页")) {
|
|
32687
|
-
let oldValue = element.innerHTML;
|
|
32688
|
-
if (innerHTML.includes("page")) {
|
|
32689
|
-
oldValue = oldValue.replace('page', '$L{页}');
|
|
32690
|
-
}
|
|
32691
|
-
if (innerHTML.includes("页")) {
|
|
32692
|
-
oldValue = oldValue.replace('页', '$L{页}');
|
|
32693
|
-
}
|
|
32694
|
-
if (innerHTML.includes("条")) {
|
|
32695
|
-
oldValue = oldValue.replace('条', '$L{条}');
|
|
32696
|
-
}
|
|
32697
|
-
let tempHTMLMatch = {
|
|
32698
|
-
oldValue: oldValue
|
|
32699
|
-
};
|
|
32700
|
-
checkResult.result = true;
|
|
32701
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32702
|
-
return checkResult;
|
|
32703
|
-
}
|
|
32704
|
-
}
|
|
32705
|
-
// 检查删除确认对话框标题
|
|
32706
|
-
if (classes.contains("ant-popover-message-title")) {
|
|
32707
|
-
let innerHTML = element.innerHTML;
|
|
32708
|
-
if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
|
|
32709
|
-
// console.log("检查smardaten平台删除提问对话框:",innerHTML);
|
|
32710
|
-
let tempHTMLMatch = {
|
|
32711
|
-
oldValue: '$L{操作确认:删除?}'
|
|
32712
|
-
};
|
|
32713
|
-
checkResult.result = true;
|
|
32714
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32715
|
-
return checkResult;
|
|
32716
|
-
}
|
|
32717
|
-
}
|
|
32718
|
-
// 检查删除确认对话框按钮 取消 确认
|
|
32719
|
-
if (classes.contains("ant-btn") && !classes.contains("saveBtn")) {
|
|
32720
|
-
let innerHTML = element.innerHTML;
|
|
32721
|
-
if (innerHTML.includes("Cancel") || innerHTML.includes("取消")) {
|
|
32722
|
-
// console.log("检查smardaten平台 Tip提问取消删除按钮:",innerHTML);
|
|
32723
|
-
let tempHTMLMatch = {
|
|
32724
|
-
oldValue: '$L{取消}'
|
|
32725
|
-
};
|
|
32726
|
-
checkResult.result = true;
|
|
32727
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32728
|
-
return checkResult;
|
|
32729
|
-
}
|
|
32730
|
-
if (innerHTML.includes("确定") || innerHTML.includes("OK")) {
|
|
32731
|
-
// console.log("检查smardaten平台 Tip提问确认删除按钮:",innerHTML);
|
|
32732
|
-
let tempHTMLMatch = {
|
|
32733
|
-
oldValue: '$L{确定}'
|
|
32734
|
-
};
|
|
32735
|
-
checkResult.result = true;
|
|
32736
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32737
|
-
return checkResult;
|
|
32738
|
-
}
|
|
32739
|
-
}
|
|
32740
|
-
return checkResult;
|
|
32741
|
-
};
|
|
32742
|
-
;// ./src/api/i18n/smardaten_i18n/catalog_i18n.js
|
|
32743
|
-
|
|
32744
|
-
const catalog_i18n_check = element => {
|
|
32745
|
-
const checkResult = {
|
|
32746
|
-
result: false,
|
|
32747
|
-
innerHTMLMatch: null
|
|
32748
|
-
};
|
|
32749
|
-
const classes = element.classList;
|
|
32750
|
-
if (!classes) {
|
|
32751
|
-
return checkResult;
|
|
32752
|
-
}
|
|
32753
|
-
let innerHTML = element.innerHTML;
|
|
32754
|
-
let oldValue = element.getAttribute("oldValue");
|
|
32755
|
-
if (!oldValue) {
|
|
32756
|
-
oldValue = innerHTML;
|
|
32757
|
-
}
|
|
32758
|
-
// 检查目录列表 名称 列
|
|
32759
|
-
if (classes.contains("catalog_name_content")) {
|
|
32760
|
-
// console.log("检查smardaten平台目录列表 元素:",innerHTML);
|
|
32761
|
-
let scriptFunction = (appID, lang) => {
|
|
32762
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32763
|
-
let scriptNodeItem = element.childNodes[i];
|
|
32764
|
-
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32765
|
-
let text = element.getAttribute("oldValue");
|
|
32766
|
-
let isTextMatch = checkTextFormat(text);
|
|
32767
|
-
if (!isTextMatch) {
|
|
32768
|
-
element.appendChild(scriptNodeItem);
|
|
32769
|
-
} else {
|
|
32770
|
-
element.removeChild(scriptNodeItem);
|
|
32771
|
-
let key = isTextMatch.key;
|
|
32772
|
-
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
32773
|
-
element.appendChild(textNode);
|
|
32774
|
-
}
|
|
32775
|
-
} else {
|
|
32776
|
-
element.appendChild(scriptNodeItem);
|
|
32777
|
-
}
|
|
32778
|
-
}
|
|
32779
|
-
};
|
|
32780
|
-
let tempHTMLMatch = {
|
|
32781
|
-
oldValue: oldValue,
|
|
32782
|
-
isScriptAction: true,
|
|
32783
|
-
scriptFunction: scriptFunction
|
|
32784
|
-
};
|
|
32785
|
-
checkResult.result = true;
|
|
32786
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32787
|
-
return checkResult;
|
|
32788
|
-
}
|
|
32789
|
-
if (classes.contains("catalog-tree-search")) {
|
|
32790
|
-
let scriptFunction = (appID, lang) => {
|
|
32791
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32792
|
-
let scriptNodeItem = element.childNodes[i];
|
|
32793
|
-
if (scriptNodeItem.tagName === 'INPUT') {
|
|
32794
|
-
let oldValue = scriptNodeItem.getAttribute("oldplaceholderValue");
|
|
32795
|
-
if (!oldValue) {
|
|
32796
|
-
let text = scriptNodeItem.getAttribute("placeholder");
|
|
32797
|
-
if (text) {
|
|
32798
|
-
text = `$L{${text}}`;
|
|
32799
|
-
}
|
|
32800
|
-
scriptNodeItem.setAttribute("placeholder", text);
|
|
32801
|
-
processElement(scriptNodeItem, appID, lang);
|
|
32802
|
-
}
|
|
32803
|
-
}
|
|
32804
|
-
}
|
|
32805
|
-
};
|
|
32806
|
-
let tempHTMLMatch = {
|
|
32807
|
-
oldValue: oldValue,
|
|
32808
|
-
isScriptAction: true,
|
|
32809
|
-
scriptFunction: scriptFunction
|
|
32810
|
-
};
|
|
32811
|
-
checkResult.result = true;
|
|
32812
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32813
|
-
return checkResult;
|
|
32814
|
-
}
|
|
32815
|
-
return checkResult;
|
|
32816
|
-
};
|
|
32817
|
-
;// ./src/api/i18n/commom_i18n/common_i18n.js
|
|
32818
|
-
|
|
32819
|
-
|
|
32820
|
-
function getOldValueNodeText(innerHTML, index) {
|
|
32821
|
-
const container = document.createElement('div');
|
|
32822
|
-
container.innerHTML = innerHTML;
|
|
32823
|
-
const childNode = container.childNodes[index];
|
|
32824
|
-
return childNode.textContent;
|
|
32825
|
-
}
|
|
32826
|
-
const common_i18n_check = element => {
|
|
32827
|
-
const checkResult = {
|
|
32828
|
-
result: false,
|
|
32829
|
-
innerHTMLMatch: null
|
|
32830
|
-
};
|
|
32831
|
-
// 检查目录列表 名称 列
|
|
32832
|
-
if (element.tagName === 'BUTTON' || element.tagName === 'P') {
|
|
32833
|
-
//TODO:先检查新的是否需要解析,新的不需要有可能是解析后的再次判断,如果有历史解析值,则解析
|
|
32834
|
-
//如果新的需要解析,更新缓存的历史解析值
|
|
32835
|
-
let innerHTML = element.innerHTML;
|
|
32836
|
-
let oldValue = element.getAttribute("oldValue");
|
|
32837
|
-
if (!oldValue) {
|
|
32838
|
-
oldValue = innerHTML;
|
|
32839
|
-
}
|
|
32840
|
-
let firstCheck = checkTextFormat(oldValue);
|
|
32841
|
-
let firstCheckResult = firstCheck ? true : false;
|
|
32842
|
-
// console.log("检查 button 元素:",innerHTML);
|
|
32843
|
-
// console.log("检查结果:",firstCheckResult);
|
|
32844
|
-
let scriptFunction = (appID, lang) => {
|
|
32845
|
-
let elementsArray = [];
|
|
32846
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32847
|
-
let scriptNodeItem = element.childNodes[i];
|
|
32848
|
-
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32849
|
-
let oldValue = element.getAttribute("oldValue");
|
|
32850
|
-
// console.log("执行 button 文本节点翻译:", text);
|
|
32851
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
32852
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
32853
|
-
let isTextMatch = checkTextFormat(oldValue);
|
|
32854
|
-
if (!isTextMatch) {
|
|
32855
|
-
elementsArray.push(scriptNodeItem);
|
|
32856
|
-
} else {
|
|
32857
|
-
// console.log("执行 button 脚本节点翻译isTextMatch:", isTextMatch?true:false);
|
|
32858
|
-
// element.removeChild(scriptNodeItem);
|
|
32859
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
32860
|
-
let childNodeText = getOldValueNodeText(oldValue, i);
|
|
32861
|
-
let newValue = childNodeText;
|
|
32862
|
-
let match;
|
|
32863
|
-
while ((match = regex.exec(oldValue)) !== null) {
|
|
32864
|
-
const fullMatch = match[0];
|
|
32865
|
-
const placeholderKey = match[1];
|
|
32866
|
-
const translation = i18n(placeholderKey, appID, lang);
|
|
32867
|
-
newValue = newValue.replace(fullMatch, translation);
|
|
32868
|
-
}
|
|
32869
|
-
let textNode = document.createTextNode(newValue);
|
|
32870
|
-
elementsArray.push(textNode);
|
|
32871
|
-
}
|
|
32872
|
-
} else {
|
|
32873
|
-
elementsArray.push(scriptNodeItem);
|
|
32874
|
-
}
|
|
32875
|
-
}
|
|
32876
|
-
element.innerHTML = '';
|
|
32877
|
-
elementsArray.forEach(el => {
|
|
32878
|
-
element.appendChild(el);
|
|
32879
|
-
});
|
|
32880
|
-
};
|
|
32881
|
-
let tempHTMLMatch = {
|
|
32882
|
-
oldValue: oldValue,
|
|
32883
|
-
isScriptAction: true,
|
|
32884
|
-
scriptFunction: scriptFunction
|
|
32885
|
-
};
|
|
32886
|
-
checkResult.result = firstCheckResult;
|
|
32887
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32888
|
-
return checkResult;
|
|
32889
|
-
}
|
|
32890
|
-
return checkResult;
|
|
32891
|
-
};
|
|
32892
|
-
;// ./src/api/i18n/commom_i18n/attribute_i18n.js
|
|
32893
|
-
|
|
32894
|
-
const attribute_i18n_check = element => {
|
|
32895
|
-
const checkResult = {
|
|
32896
|
-
result: false,
|
|
32897
|
-
innerHTMLMatch: null
|
|
32898
|
-
};
|
|
32899
|
-
if (!element) {
|
|
32900
|
-
return checkResult;
|
|
32901
|
-
}
|
|
32902
|
-
const checkAttributes = ["placeholder", "title"];
|
|
32903
|
-
for (let i = 0; i < checkAttributes.length; i++) {
|
|
32904
|
-
let attr = checkAttributes[i];
|
|
32905
|
-
let attrValue = element.getAttribute(attr) || element[attr];
|
|
32906
|
-
const attrMatch = attrValue ? checkTextFormat(attrValue) : null;
|
|
32907
|
-
if (attrMatch) {
|
|
32908
|
-
// console.log("检查元素属性 i18n 元素:", attr, attrValue);
|
|
32909
|
-
element.setAttribute(`old${attr}Value`, attrValue);
|
|
32910
|
-
checkResult.result = true;
|
|
32911
|
-
}
|
|
32912
|
-
}
|
|
32913
|
-
let scriptFunction = (appID, lang) => {
|
|
32914
|
-
for (let i = 0; i < checkAttributes.length; i++) {
|
|
32915
|
-
let attr = checkAttributes[i];
|
|
32916
|
-
const oldAttrValue = element.getAttribute(`old${attr}Value`);
|
|
32917
|
-
if (oldAttrValue) {
|
|
32918
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
32919
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
32920
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
32921
|
-
let newAttrValue = oldAttrValue;
|
|
32922
|
-
let match;
|
|
32923
|
-
while ((match = regex.exec(oldAttrValue)) !== null) {
|
|
32924
|
-
const fullMatch = match[0];
|
|
32925
|
-
const attrKey = match[1];
|
|
32926
|
-
const translation = i18n(attrKey, appID, lang);
|
|
32927
|
-
newAttrValue = newAttrValue.replace(fullMatch, translation);
|
|
32928
|
-
}
|
|
32929
|
-
// 更新元素的placeholder属性
|
|
32930
|
-
element.setAttribute(attr, newAttrValue);
|
|
32931
|
-
}
|
|
32932
|
-
}
|
|
32933
|
-
};
|
|
32934
|
-
checkResult.scriptFunction = scriptFunction;
|
|
32935
|
-
return checkResult;
|
|
32936
|
-
};
|
|
32937
|
-
;// ./src/api/i18n/smardaten_i18n/calendar_i18n.js
|
|
32938
|
-
|
|
32939
|
-
|
|
32940
|
-
function convertToChineseWeekday(englishInput) {
|
|
32941
|
-
// 清理输入:去除首尾空格并转为小写
|
|
32942
|
-
const input = englishInput.trim().toLowerCase();
|
|
32943
|
-
|
|
32944
|
-
// 定义星期映射关系
|
|
32945
|
-
const weekdayMap = {
|
|
32946
|
-
'mon': '周一',
|
|
32947
|
-
'monday': '周一',
|
|
32948
|
-
'mondays': '周一',
|
|
32949
|
-
'tue': '周二',
|
|
32950
|
-
'tues': '周二',
|
|
32951
|
-
'tuesday': '周二',
|
|
32952
|
-
'tuesdays': '周二',
|
|
32953
|
-
'wed': '周三',
|
|
32954
|
-
'wednesday': '周三',
|
|
32955
|
-
'wednesdays': '周三',
|
|
32956
|
-
'thu': '周四',
|
|
32957
|
-
'thur': '周四',
|
|
32958
|
-
'thurs': '周四',
|
|
32959
|
-
'thursday': '周四',
|
|
32960
|
-
'thursdays': '周四',
|
|
32961
|
-
'fri': '周五',
|
|
32962
|
-
'friday': '周五',
|
|
32963
|
-
'fridays': '周五',
|
|
32964
|
-
'sat': '周六',
|
|
32965
|
-
'saturday': '周六',
|
|
32966
|
-
'saturdays': '周六',
|
|
32967
|
-
'sun': '周日',
|
|
32968
|
-
'sunday': '周日',
|
|
32969
|
-
'sundays': '周日'
|
|
32970
|
-
};
|
|
32971
|
-
|
|
32972
|
-
// 使用正则表达式匹配所有可能的星期格式
|
|
32973
|
-
const pattern = /^(mon(day)?s?\.?|tue(sday)?s?\.?|wed(nesday)?s?\.?|thu(r(sday)?)?s?\.?|fri(day)?s?\.?|sat(urday)?s?\.?|sun(day)?s?\.?)$/i;
|
|
32974
|
-
|
|
32975
|
-
// 测试输入是否匹配星期格式
|
|
32976
|
-
if (!pattern.test(input)) {
|
|
32977
|
-
return '未知日期';
|
|
32978
|
-
}
|
|
32979
|
-
|
|
32980
|
-
// 提取基础名称(去除复数形式和句点)
|
|
32981
|
-
const baseName = input.replace(/\./g, '') // 移除所有句点
|
|
32982
|
-
.replace(/s$/, ''); // 移除结尾的's'(复数形式)
|
|
32983
|
-
|
|
32984
|
-
// 特殊处理周四的多种缩写形式
|
|
32985
|
-
const normalized = baseName.startsWith('thu') ? 'thu' : baseName.slice(0, 3);
|
|
32986
|
-
|
|
32987
|
-
// 映射到中文名称
|
|
32988
|
-
return weekdayMap[normalized] || weekdayMap[baseName] || '未知日期';
|
|
32989
|
-
}
|
|
32990
|
-
function extractYearMonth(str) {
|
|
32991
|
-
const regex = /(\d{4})年(0?[1-9]|1[0-2])月/g;
|
|
32992
|
-
const matches = str.matchAll(regex);
|
|
32993
|
-
const result = [];
|
|
32994
|
-
for (const match of matches) {
|
|
32995
|
-
const year = parseInt(match[1], 10);
|
|
32996
|
-
const month = parseInt(match[2], 10);
|
|
32997
|
-
result.push({
|
|
32998
|
-
year,
|
|
32999
|
-
month
|
|
33000
|
-
});
|
|
33001
|
-
}
|
|
33002
|
-
return result;
|
|
33003
|
-
}
|
|
33004
|
-
function extractDayNumbers(text) {
|
|
33005
|
-
// 匹配两种情况:
|
|
33006
|
-
// 1. "数字+日"格式(如"5日"、"12日")
|
|
33007
|
-
// 2. 独立的1-31数字(前后有边界)
|
|
33008
|
-
const regex = /(?:(\b(0?[1-9]|[12]\d|3[01])\b)(?=日))|(\b(0?[1-9]|[12]\d|3[01])\b)/g;
|
|
33009
|
-
const results = [];
|
|
33010
|
-
let match;
|
|
33011
|
-
while ((match = regex.exec(text)) !== null) {
|
|
33012
|
-
// match[2] 对应第一种情况(带"日"字的数字)
|
|
33013
|
-
// match[4] 对应第二种情况(独立数字)
|
|
33014
|
-
const numStr = match[2] || match[4];
|
|
33015
|
-
if (numStr) {
|
|
33016
|
-
// 转换为整数并验证范围
|
|
33017
|
-
const day = parseInt(numStr, 10);
|
|
33018
|
-
if (day >= 1 && day <= 31) {
|
|
33019
|
-
results.push(day);
|
|
33020
|
-
}
|
|
33021
|
-
}
|
|
33022
|
-
}
|
|
33023
|
-
return results;
|
|
33024
|
-
}
|
|
33025
|
-
function extractNumbersFromScenarios(text) {
|
|
33026
|
-
// 定义两种场景的正则表达式
|
|
33027
|
-
const patterns = [
|
|
33028
|
-
// 场景1: "Other X pieces of data"
|
|
33029
|
-
/Other\s+(\d+)\s+pieces of data/gi,
|
|
33030
|
-
// 场景2: "其他 X 条记录"
|
|
33031
|
-
/其他\s+(\d+)\s+条记录/g];
|
|
33032
|
-
const results = [];
|
|
33033
|
-
|
|
33034
|
-
// 遍历所有模式进行匹配
|
|
33035
|
-
patterns.forEach(pattern => {
|
|
33036
|
-
let match;
|
|
33037
|
-
while ((match = pattern.exec(text)) !== null) {
|
|
33038
|
-
// 提取捕获组中的数字
|
|
33039
|
-
const number = parseInt(match[1], 10);
|
|
33040
|
-
results.push({
|
|
33041
|
-
scenario: match[0],
|
|
33042
|
-
// 完整匹配的字符串
|
|
33043
|
-
number: number,
|
|
33044
|
-
// 提取的数字
|
|
33045
|
-
type: pattern.source.includes('Other') ? 'English' : 'Chinese'
|
|
33046
|
-
});
|
|
33047
|
-
}
|
|
33048
|
-
});
|
|
33049
|
-
return results;
|
|
33050
|
-
}
|
|
33051
|
-
const calendar_i18n_check = element => {
|
|
33052
|
-
const checkResult = {
|
|
33053
|
-
result: false,
|
|
33054
|
-
innerHTMLMatch: null
|
|
33055
|
-
};
|
|
33056
|
-
const classes = element.classList;
|
|
33057
|
-
if (!classes) {
|
|
33058
|
-
return checkResult;
|
|
33059
|
-
}
|
|
33060
|
-
// 检查日历标题
|
|
33061
|
-
if (classes.contains("fc-toolbar-title")) {
|
|
33062
|
-
let scriptFunction = (appID, lang) => {
|
|
33063
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33064
|
-
let yearMonthList = extractYearMonth(oldValue);
|
|
33065
|
-
if (yearMonthList.length > 0) {
|
|
33066
|
-
let yearMonth = yearMonthList[0];
|
|
33067
|
-
let year = yearMonth.year;
|
|
33068
|
-
let month = yearMonth.month;
|
|
33069
|
-
let newInnerHTML = `${year}/${month}`;
|
|
33070
|
-
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33071
|
-
if (lang === "zh-CN") {
|
|
33072
|
-
newInnerHTML = `${year}年${month}月`;
|
|
33073
|
-
}
|
|
33074
|
-
element.innerHTML = newInnerHTML;
|
|
33075
|
-
}
|
|
33076
|
-
};
|
|
33077
|
-
let innerHTML = element.innerHTML;
|
|
33078
|
-
let testRule = /^\d{4}年(0?[1-9]|1[0-2])月$/;
|
|
33079
|
-
if (testRule.test(innerHTML)) {
|
|
33080
|
-
// console.log("检查smardaten平台日历标题 元素:",innerHTML);
|
|
33081
|
-
let tempHTMLMatch = {
|
|
33082
|
-
oldValue: innerHTML,
|
|
33083
|
-
isScriptAction: true,
|
|
33084
|
-
scriptFunction: scriptFunction
|
|
33085
|
-
};
|
|
33086
|
-
checkResult.result = true;
|
|
33087
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33088
|
-
return checkResult;
|
|
33089
|
-
}
|
|
33090
|
-
}
|
|
33091
|
-
// 检查日历今天按钮
|
|
33092
|
-
if (classes.contains("fc-today-button")) {
|
|
33093
|
-
let innerHTML = element.innerHTML;
|
|
33094
|
-
if (innerHTML.includes("今天") || innerHTML.includes("today")) {
|
|
33095
|
-
// console.log("检查smardaten平台日历 今天 元素:",innerHTML);
|
|
33096
|
-
let tempHTMLMatch = {
|
|
33097
|
-
oldValue: '$L{今天}'
|
|
33098
|
-
};
|
|
33099
|
-
checkResult.result = true;
|
|
33100
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33101
|
-
return checkResult;
|
|
33102
|
-
}
|
|
33103
|
-
}
|
|
33104
|
-
// 检查日历标题
|
|
33105
|
-
if (classes.contains("fullCalendar_title_value")) {
|
|
33106
|
-
let innerHTML = element.innerHTML;
|
|
33107
|
-
const regex = /周[一二三四五六日]/;
|
|
33108
|
-
const regex_en = /^(mon(day)?s?\.?|tue(sday)?s?\.?|wed(nesday)?s?\.?|thu(r(sday)?)?s?\.?|fri(day)?s?\.?|sat(urday)?s?\.?|sun(day)?s?\.?)$/i;
|
|
33109
|
-
let match = innerHTML.match(regex);
|
|
33110
|
-
if (match) {
|
|
33111
|
-
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33112
|
-
let day = match[0];
|
|
33113
|
-
let tempHTMLMatch = {
|
|
33114
|
-
oldValue: `$L{${day}}`
|
|
33115
|
-
};
|
|
33116
|
-
checkResult.result = true;
|
|
33117
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33118
|
-
return checkResult;
|
|
33119
|
-
}
|
|
33120
|
-
match = innerHTML.match(regex_en);
|
|
33121
|
-
if (match) {
|
|
33122
|
-
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33123
|
-
let day = match[0];
|
|
33124
|
-
let tempHTMLMatch = {
|
|
33125
|
-
oldValue: `$L{${convertToChineseWeekday(day)}}`
|
|
33126
|
-
};
|
|
33127
|
-
checkResult.result = true;
|
|
33128
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33129
|
-
return checkResult;
|
|
33130
|
-
}
|
|
33131
|
-
}
|
|
33132
|
-
//日期单元格
|
|
33133
|
-
if (classes.contains("fc-daygrid-day-number")) {
|
|
33134
|
-
let scriptFunction = (appID, lang) => {
|
|
33135
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33136
|
-
let result = extractDayNumbers(oldValue);
|
|
33137
|
-
if (result && result.length > 0) {
|
|
33138
|
-
let day = result[0];
|
|
33139
|
-
let newInnerHTML = `${day}`;
|
|
33140
|
-
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33141
|
-
if (lang === "zh-CN") {
|
|
33142
|
-
newInnerHTML = `${day}日`;
|
|
33143
|
-
}
|
|
33144
|
-
element.innerHTML = newInnerHTML;
|
|
33145
|
-
}
|
|
33146
|
-
};
|
|
33147
|
-
let innerHTML = element.innerHTML;
|
|
33148
|
-
let match = extractDayNumbers(innerHTML);
|
|
33149
|
-
if (match.length > 0) {
|
|
33150
|
-
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33151
|
-
let tempHTMLMatch = {
|
|
33152
|
-
oldValue: innerHTML,
|
|
33153
|
-
isScriptAction: true,
|
|
33154
|
-
scriptFunction: scriptFunction
|
|
33155
|
-
};
|
|
33156
|
-
checkResult.result = true;
|
|
33157
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33158
|
-
return checkResult;
|
|
33159
|
-
}
|
|
33160
|
-
}
|
|
33161
|
-
// 日历更多按钮
|
|
33162
|
-
if (classes.contains("fc-daygrid-more-link")) {
|
|
33163
|
-
let scriptFunction = (appID, lang) => {
|
|
33164
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33165
|
-
let result = extractNumbersFromScenarios(oldValue);
|
|
33166
|
-
if (result && result.length > 0) {
|
|
33167
|
-
let day = result[0]["number"];
|
|
33168
|
-
let newInnerHTML = "另外${X}条数据";
|
|
33169
|
-
newInnerHTML = i18n(newInnerHTML, appID, lang);
|
|
33170
|
-
newInnerHTML = newInnerHTML.replace("${X}", day);
|
|
33171
|
-
element.innerHTML = newInnerHTML;
|
|
33172
|
-
}
|
|
33173
|
-
};
|
|
33174
|
-
let innerHTML = element.innerHTML;
|
|
33175
|
-
let match = extractNumbersFromScenarios(innerHTML);
|
|
33176
|
-
if (match.length > 0) {
|
|
33177
|
-
// console.log("检查smardaten平台日历 更多 元素:",innerHTML);
|
|
33178
|
-
let tempHTMLMatch = {
|
|
33179
|
-
oldValue: innerHTML,
|
|
33180
|
-
isScriptAction: true,
|
|
33181
|
-
scriptFunction: scriptFunction
|
|
33182
|
-
};
|
|
33183
|
-
checkResult.result = true;
|
|
33184
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33185
|
-
return checkResult;
|
|
32492
|
+
return {
|
|
32493
|
+
code: code,
|
|
32494
|
+
message: result.data.message
|
|
32495
|
+
};
|
|
32496
|
+
};
|
|
32497
|
+
|
|
32498
|
+
/**
|
|
32499
|
+
* 获取密钥
|
|
32500
|
+
* @returns
|
|
32501
|
+
*/
|
|
32502
|
+
const getKey = async () => {
|
|
32503
|
+
let queryData = {
|
|
32504
|
+
param: {}
|
|
32505
|
+
};
|
|
32506
|
+
let resultData = await request.post(`/dataservice/rest/orchestration/getKey`, queryData);
|
|
32507
|
+
let key = resultData.data.key;
|
|
32508
|
+
return key;
|
|
32509
|
+
};
|
|
32510
|
+
;// ./src/api/utils.js
|
|
32511
|
+
|
|
32512
|
+
|
|
32513
|
+
|
|
32514
|
+
|
|
32515
|
+
/**
|
|
32516
|
+
* 查询资产
|
|
32517
|
+
* @param id 资产ID
|
|
32518
|
+
*
|
|
32519
|
+
*/
|
|
32520
|
+
const queryAssetById = (id, count = 200) => request.post(`/asset/getAssetData?asset_id=${id}&count=${count}`, {
|
|
32521
|
+
filters: []
|
|
32522
|
+
});
|
|
32523
|
+
|
|
32524
|
+
/**
|
|
32525
|
+
* 获取URL参数值
|
|
32526
|
+
* @param {} eventName
|
|
32527
|
+
* @param {*} actionFun
|
|
32528
|
+
*/
|
|
32529
|
+
const getUrlParamValue = (urlStr, paramName) => {
|
|
32530
|
+
try {
|
|
32531
|
+
const url = new URL(urlStr);
|
|
32532
|
+
const value = url.searchParams.get(paramName);
|
|
32533
|
+
// 如果参数值包含#,则只返回#之前的部分
|
|
32534
|
+
if (value && value.indexOf("#") !== -1) {
|
|
32535
|
+
return value.split("#")[0];
|
|
33186
32536
|
}
|
|
32537
|
+
return value;
|
|
32538
|
+
} catch (err) {
|
|
32539
|
+
console.error("URL 格式错误:", err);
|
|
32540
|
+
return "";
|
|
33187
32541
|
}
|
|
33188
|
-
|
|
33189
|
-
|
|
33190
|
-
|
|
33191
|
-
|
|
33192
|
-
|
|
33193
|
-
|
|
33194
|
-
|
|
33195
|
-
|
|
33196
|
-
|
|
33197
|
-
|
|
33198
|
-
|
|
33199
|
-
|
|
33200
|
-
|
|
33201
|
-
|
|
33202
|
-
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33203
|
-
if (lang === "zh-CN") {
|
|
33204
|
-
result = `${year}年${formattedMonth}月${formattedDay}日`;
|
|
33205
|
-
}
|
|
33206
|
-
// 返回新格式的日期
|
|
33207
|
-
return result;
|
|
33208
|
-
});
|
|
33209
|
-
element.innerHTML = convertedText;
|
|
33210
|
-
}
|
|
33211
|
-
};
|
|
33212
|
-
let innerHTML = element.innerHTML;
|
|
33213
|
-
let match = innerHTML.match(regex);
|
|
33214
|
-
if (match && match.length > 0) {
|
|
33215
|
-
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33216
|
-
let tempHTMLMatch = {
|
|
33217
|
-
oldValue: innerHTML,
|
|
33218
|
-
isScriptAction: true,
|
|
33219
|
-
scriptFunction: scriptFunction
|
|
33220
|
-
};
|
|
33221
|
-
checkResult.result = true;
|
|
33222
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33223
|
-
return checkResult;
|
|
32542
|
+
};
|
|
32543
|
+
|
|
32544
|
+
/**
|
|
32545
|
+
* 通过 URL 创建 File 对象
|
|
32546
|
+
* @param {string} url - 文件的网络 URL
|
|
32547
|
+
* @param {string} [filename] - 自定义文件名(可选,不传则从 URL 提取)
|
|
32548
|
+
* @returns {Promise<File>} - 返回 Promise 解析为 File 对象
|
|
32549
|
+
*/
|
|
32550
|
+
const createFileFromUrl = async (url, filename) => {
|
|
32551
|
+
try {
|
|
32552
|
+
// 1. 发起网络请求获取文件
|
|
32553
|
+
const response = await fetch(url);
|
|
32554
|
+
if (!response.ok) {
|
|
32555
|
+
throw new Error(`网络请求失败: ${response.status} ${response.statusText}`);
|
|
33224
32556
|
}
|
|
32557
|
+
|
|
32558
|
+
// 2. 将响应转换为 Blob(保留原始 MIME 类型)
|
|
32559
|
+
const blob = await response.blob();
|
|
32560
|
+
|
|
32561
|
+
// 3. 确定文件名(若未自定义则从 URL 提取)
|
|
32562
|
+
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
32563
|
+
|
|
32564
|
+
// 4. 构造 File 对象(Blob + 文件名 + 类型)
|
|
32565
|
+
return new File([blob], finalFilename, {
|
|
32566
|
+
type: blob.type,
|
|
32567
|
+
// 使用 Blob 的 MIME 类型(如 image/png)
|
|
32568
|
+
lastModified: Date.now() // 可选:设置最后修改时间
|
|
32569
|
+
});
|
|
32570
|
+
} catch (error) {
|
|
32571
|
+
console.error("创建 File 失败:", error);
|
|
32572
|
+
throw error;
|
|
33225
32573
|
}
|
|
33226
|
-
return checkResult;
|
|
33227
32574
|
};
|
|
33228
|
-
|
|
33229
|
-
|
|
33230
|
-
|
|
33231
|
-
|
|
33232
|
-
|
|
33233
|
-
|
|
33234
|
-
|
|
33235
|
-
|
|
33236
|
-
|
|
32575
|
+
|
|
32576
|
+
/**
|
|
32577
|
+
* 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
|
|
32578
|
+
* @param {string} url - 文件 URL
|
|
32579
|
+
* @returns {string} - 提取的文件名
|
|
32580
|
+
*/
|
|
32581
|
+
const extractFilenameFromUrl = url => {
|
|
32582
|
+
try {
|
|
32583
|
+
const urlObj = new URL(url);
|
|
32584
|
+
// 从路径中获取最后一个部分(文件名)
|
|
32585
|
+
return urlObj.pathname.split("/").pop() || "downloaded_file";
|
|
32586
|
+
} catch (e) {
|
|
32587
|
+
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
33237
32588
|
}
|
|
33238
|
-
|
|
33239
|
-
|
|
33240
|
-
|
|
33241
|
-
|
|
32589
|
+
};
|
|
32590
|
+
|
|
32591
|
+
/**
|
|
32592
|
+
* 提取数组中不在另一个数组中的元素
|
|
32593
|
+
* @param {*} oldItems 基础比较数组
|
|
32594
|
+
* @param {*} newItems 被提取检测的数组
|
|
32595
|
+
* @returns
|
|
32596
|
+
*/
|
|
32597
|
+
const extractNewItems = (oldItems, newItems) => {
|
|
32598
|
+
return oldItems.filter(item => !newItems.includes(item));
|
|
32599
|
+
};
|
|
32600
|
+
|
|
32601
|
+
/**
|
|
32602
|
+
* 获取远程文件大小(单位:字节)
|
|
32603
|
+
* @param {string} url - 文件的URL地址
|
|
32604
|
+
* @returns {Promise<number>} 文件大小(字节),失败时返回-1
|
|
32605
|
+
*/
|
|
32606
|
+
const getFileSize = async url => {
|
|
32607
|
+
try {
|
|
32608
|
+
// 发送HEAD请求(不下载文件内容)
|
|
32609
|
+
const response = await fetch(url, {
|
|
32610
|
+
method: 'GET',
|
|
32611
|
+
headers: {
|
|
32612
|
+
'Range': 'bytes=0-0'
|
|
32613
|
+
} // 仅请求第 1 个字节
|
|
32614
|
+
});
|
|
32615
|
+
if (response.status !== 206) throw new Error('不支持 Range 请求');
|
|
32616
|
+
const contentRange = response.headers.get('Content-Range');
|
|
32617
|
+
const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
|
|
32618
|
+
return totalSize ? parseInt(totalSize, 10) : -1;
|
|
32619
|
+
} catch (error) {
|
|
32620
|
+
console.error('获取文件大小失败:', error);
|
|
32621
|
+
return -1; // 返回-1表示失败
|
|
33242
32622
|
}
|
|
33243
|
-
|
|
33244
|
-
|
|
33245
|
-
|
|
33246
|
-
|
|
33247
|
-
|
|
33248
|
-
|
|
33249
|
-
|
|
33250
|
-
|
|
33251
|
-
|
|
33252
|
-
|
|
33253
|
-
|
|
33254
|
-
|
|
32623
|
+
};
|
|
32624
|
+
// 获取i18n key
|
|
32625
|
+
const getI18nKey = text => {
|
|
32626
|
+
// 正则表达式匹配 $L{...} 格式
|
|
32627
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
32628
|
+
let match = regex.exec(text);
|
|
32629
|
+
if (!match) return text;
|
|
32630
|
+
let key = match[1];
|
|
32631
|
+
return key;
|
|
32632
|
+
};
|
|
32633
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
|
|
32634
|
+
var es_iterator_some = __webpack_require__(3579);
|
|
32635
|
+
;// ./src/api/iframe.js
|
|
32636
|
+
|
|
32637
|
+
|
|
32638
|
+
|
|
32639
|
+
const addWindowTrustedOrigin = origin => {
|
|
32640
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32641
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32642
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS.includes(origin)) {
|
|
32643
|
+
SDATA_WINDOW_TRUSTED_ORIGINS.push(origin);
|
|
33255
32644
|
}
|
|
33256
|
-
return checkResult;
|
|
33257
32645
|
};
|
|
33258
|
-
|
|
33259
|
-
|
|
33260
|
-
|
|
33261
|
-
|
|
33262
|
-
|
|
33263
|
-
|
|
33264
|
-
if (!classes) {
|
|
33265
|
-
return checkResult;
|
|
32646
|
+
const removeWindowTrustedOrigin = origin => {
|
|
32647
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32648
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32649
|
+
let index = SDATA_WINDOW_TRUSTED_ORIGINS.indexOf(origin); // 查找元素在数组中的索引
|
|
32650
|
+
if (index > -1) {
|
|
32651
|
+
SDATA_WINDOW_TRUSTED_ORIGINS.splice(index, 1); // 删除元素
|
|
33266
32652
|
}
|
|
33267
|
-
|
|
33268
|
-
|
|
33269
|
-
|
|
33270
|
-
|
|
33271
|
-
|
|
33272
|
-
|
|
33273
|
-
|
|
33274
|
-
|
|
33275
|
-
|
|
33276
|
-
|
|
33277
|
-
|
|
33278
|
-
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33283
|
-
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
33293
|
-
|
|
33294
|
-
|
|
33295
|
-
|
|
33296
|
-
|
|
32653
|
+
};
|
|
32654
|
+
const addEventAction = (eventKey, eventAction) => {
|
|
32655
|
+
let sdataEventActions = window.sdataEventActions;
|
|
32656
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32657
|
+
window.sdataEventActions[eventKey] = eventAction;
|
|
32658
|
+
};
|
|
32659
|
+
const removeEventAction = eventKey => {
|
|
32660
|
+
let sdataEventActions = window.sdataEventActions;
|
|
32661
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32662
|
+
delete window.sdataEventActions[eventKey];
|
|
32663
|
+
};
|
|
32664
|
+
const initFrameWindowListener = () => {
|
|
32665
|
+
if (window.isFrameWindowInited) return;
|
|
32666
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32667
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32668
|
+
let sdataEventActions = window.sdataEventActions;
|
|
32669
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32670
|
+
// 监听主页面的消息
|
|
32671
|
+
window.addEventListener("message", async event => {
|
|
32672
|
+
// 步骤1:验证来源是否在白名单中
|
|
32673
|
+
const isTrusted = window.SDATA_WINDOW_TRUSTED_ORIGINS.some(origin => event.origin === origin || new RegExp(origin).test(event.origin));
|
|
32674
|
+
if (!isTrusted) {
|
|
32675
|
+
console.log("拒绝非可信源消息:", event.origin);
|
|
32676
|
+
return; // 直接终止处理
|
|
32677
|
+
}
|
|
32678
|
+
let eventKey = event.data?.eventKey;
|
|
32679
|
+
if (!eventKey) return;
|
|
32680
|
+
let eventSourceKey = event.origin;
|
|
32681
|
+
console.log(`收到${eventSourceKey}页面消息:`, event.data);
|
|
32682
|
+
if (eventKey === "sdata_alllife_event_response") {
|
|
32683
|
+
let eventOperateKey = event.data.eventOperateKey;
|
|
32684
|
+
let eventAction = window.sdataEventActions[eventOperateKey];
|
|
32685
|
+
//删除缓存方法
|
|
32686
|
+
delete window.sdataEventActions[eventOperateKey];
|
|
32687
|
+
if (eventAction) await eventAction(event.data.data, event);
|
|
32688
|
+
} else {
|
|
32689
|
+
let eventAction = window.sdataEventActions[eventKey];
|
|
32690
|
+
let responseData = {
|
|
32691
|
+
eventKey: "sdata_alllife_event_response",
|
|
32692
|
+
eventOperateKey: event.data.eventOperateKey,
|
|
32693
|
+
data: {}
|
|
32694
|
+
};
|
|
32695
|
+
if (eventAction) {
|
|
32696
|
+
let resultData = await eventAction(event.data.data, event);
|
|
32697
|
+
responseData.data = resultData;
|
|
33297
32698
|
}
|
|
33298
|
-
|
|
33299
|
-
checkResult.result = true;
|
|
33300
|
-
checkResult.scriptFunction = scriptFunction;
|
|
33301
|
-
return checkResult;
|
|
33302
|
-
}
|
|
33303
|
-
return checkResult;
|
|
33304
|
-
};
|
|
33305
|
-
function generateUniqueId() {
|
|
33306
|
-
return `rjview_${Date.now()}`;
|
|
33307
|
-
}
|
|
33308
|
-
;// ./src/api/i18n/i18n.js
|
|
33309
|
-
|
|
33310
|
-
|
|
33311
|
-
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
|
|
33316
|
-
|
|
33317
|
-
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
const getLanguages = async appID => {
|
|
33323
|
-
let queryData = {
|
|
33324
|
-
param: {
|
|
33325
|
-
appID: appID
|
|
32699
|
+
event.source.postMessage(responseData, eventSourceKey);
|
|
33326
32700
|
}
|
|
33327
|
-
};
|
|
33328
|
-
|
|
33329
|
-
let resultDatas = response.data.resultDatas || [];
|
|
33330
|
-
return resultDatas;
|
|
33331
|
-
};
|
|
33332
|
-
const updateI18nValue = (appID, key, localID, value) => {
|
|
33333
|
-
let realKey = `${appID}-${key}-${localID}`;
|
|
33334
|
-
window.customI18nObject.set(realKey, value);
|
|
33335
|
-
};
|
|
33336
|
-
const i18n = (key, appID, localID) => {
|
|
33337
|
-
let result = window.customI18nObject?.get(`${appID}-${key}-${localID}`) || key;
|
|
33338
|
-
return result;
|
|
32701
|
+
});
|
|
32702
|
+
window.isFrameWindowInited = true;
|
|
33339
32703
|
};
|
|
33340
|
-
|
|
33341
|
-
let
|
|
33342
|
-
let
|
|
33343
|
-
|
|
33344
|
-
|
|
33345
|
-
|
|
33346
|
-
|
|
33347
|
-
|
|
33348
|
-
|
|
33349
|
-
}
|
|
32704
|
+
const sendWindowMessage = async (targetWindow, originKey, eventKey, data, callback) => {
|
|
32705
|
+
let timestamp = new Date().getTime();
|
|
32706
|
+
let randomNum = Math.floor(Math.random() * 10000) + 1;
|
|
32707
|
+
let eventOperateKey = `${eventKey}_${timestamp}_${randomNum}`;
|
|
32708
|
+
addEventAction(eventOperateKey, callback);
|
|
32709
|
+
let postData = {
|
|
32710
|
+
eventOperateKey: eventOperateKey,
|
|
32711
|
+
eventKey: eventKey,
|
|
32712
|
+
data: data
|
|
33350
32713
|
};
|
|
33351
|
-
|
|
33352
|
-
let resultDatas = response.data.resultDatas || [];
|
|
33353
|
-
window.customI18nObject = new Map();
|
|
33354
|
-
for (let item of resultDatas) {
|
|
33355
|
-
window.customI18nObject.set(`${appID}-${item.key}-${item.lang}`, item.value);
|
|
33356
|
-
}
|
|
32714
|
+
targetWindow.postMessage(postData, originKey);
|
|
33357
32715
|
};
|
|
32716
|
+
;// ./src/api/chat/ChatClientMgr.js
|
|
33358
32717
|
|
|
33359
|
-
/**
|
|
33360
|
-
* 检查元素是否有子DOM元素
|
|
33361
|
-
* @param {HTMLElement} element - 要检查的DOM元素
|
|
33362
|
-
* @returns {boolean} - 是否有子元素
|
|
33363
|
-
*/
|
|
33364
|
-
function hasChildElements(element) {
|
|
33365
|
-
return element && element.children?.length > 0;
|
|
33366
|
-
}
|
|
33367
32718
|
|
|
33368
|
-
/**
|
|
33369
|
-
* 检查文本是否匹配$L{...}格式
|
|
33370
|
-
* @param {string} text - 要检查的文本
|
|
33371
|
-
* @returns {Object|null} - 匹配结果或null
|
|
33372
|
-
*/
|
|
33373
|
-
function checkTextFormat(text) {
|
|
33374
|
-
if (!text) return null;
|
|
33375
|
-
const regex = /\$L\{([^}]+)\}/;
|
|
33376
|
-
const match = text.match(regex);
|
|
33377
|
-
if (match) {
|
|
33378
|
-
return {
|
|
33379
|
-
fullMatch: match[0],
|
|
33380
|
-
key: match[1]
|
|
33381
|
-
};
|
|
33382
|
-
}
|
|
33383
|
-
return null;
|
|
33384
|
-
}
|
|
33385
|
-
function i18n_generateUniqueId() {
|
|
33386
|
-
window.idCounter = window.idCounter || 0;
|
|
33387
|
-
return `i18n_${Date.now()}_${window.idCounter++}`;
|
|
33388
|
-
}
|
|
33389
32719
|
|
|
33390
|
-
|
|
33391
|
-
|
|
33392
|
-
|
|
33393
|
-
|
|
33394
|
-
|
|
33395
|
-
|
|
33396
|
-
|
|
33397
|
-
|
|
33398
|
-
|
|
33399
|
-
|
|
33400
|
-
|
|
33401
|
-
|
|
33402
|
-
|
|
33403
|
-
let checkContentResult = checkFunc(element);
|
|
33404
|
-
if (checkContentResult.result) {
|
|
33405
|
-
return checkContentResult;
|
|
33406
|
-
}
|
|
33407
|
-
}
|
|
33408
|
-
return checkContentResult;
|
|
33409
|
-
}
|
|
33410
|
-
function processElement(element) {
|
|
33411
|
-
if (!element) {
|
|
33412
|
-
return false;
|
|
32720
|
+
class ChatClientMgr {
|
|
32721
|
+
constructor(params, handler) {
|
|
32722
|
+
this.handler = handler;
|
|
32723
|
+
this.actionKey = params.actionKey;
|
|
32724
|
+
this.appSKID = params.appSKID;
|
|
32725
|
+
this.imType = params.imType;
|
|
32726
|
+
this.groupID = params.groupID;
|
|
32727
|
+
this.userID = params.userID;
|
|
32728
|
+
this.chatType = params.chatType || 0;
|
|
32729
|
+
this.singleChatID = params.singleChatID || "";
|
|
32730
|
+
this.customParams = params.customParams || {};
|
|
32731
|
+
this.chartOrigin = params.chartOrigin;
|
|
32732
|
+
// console.log("ChatClientMgr init:", this.actionKey);
|
|
33413
32733
|
}
|
|
33414
|
-
|
|
33415
|
-
|
|
33416
|
-
if (element && element.nodeType !== Node.ELEMENT_NODE) {
|
|
33417
|
-
return false;
|
|
32734
|
+
makeKey(key) {
|
|
32735
|
+
return `${key}-${this.actionKey}`;
|
|
33418
32736
|
}
|
|
33419
|
-
|
|
33420
|
-
|
|
33421
|
-
|
|
33422
|
-
|
|
33423
|
-
|
|
33424
|
-
|
|
33425
|
-
|
|
33426
|
-
|
|
33427
|
-
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33431
|
-
|
|
32737
|
+
async init() {
|
|
32738
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_access_token`), async data => {
|
|
32739
|
+
return await this.handler.getPortalAccessToken(data);
|
|
32740
|
+
});
|
|
32741
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_user_info`), async data => {
|
|
32742
|
+
return await this.handler.getPortalUserInfo(data);
|
|
32743
|
+
});
|
|
32744
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_user_sig`), async data => {
|
|
32745
|
+
let userID = data.userID;
|
|
32746
|
+
let platType = data.im_type;
|
|
32747
|
+
let groupID = data.group_id;
|
|
32748
|
+
return await this.handler.getPortalUserSig(userID, platType, groupID);
|
|
32749
|
+
});
|
|
32750
|
+
this.handler.addChatListener(this.makeKey(`sdata_add_im_mapping`), async data => {
|
|
32751
|
+
let userID = data.userID;
|
|
32752
|
+
let platType = data.im_type;
|
|
32753
|
+
let userSig = data.userSig;
|
|
32754
|
+
return await this.handler.addIMMapping(userID, platType, userSig, this.groupID);
|
|
32755
|
+
});
|
|
32756
|
+
this.handler.addChatListener(this.makeKey(`sdata_update_im_mapping`), async data => {
|
|
32757
|
+
return await this.handler.updateIMMapping(data);
|
|
32758
|
+
});
|
|
32759
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_users_by_group_id`), async data => {
|
|
32760
|
+
return await this.handler.getAllUserInfosByGroupID(data);
|
|
32761
|
+
});
|
|
32762
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_dpts_by_group_id`), async data => {
|
|
32763
|
+
return await this.handler.getChildrenOfficeInfosByID(data);
|
|
32764
|
+
});
|
|
32765
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_project_dpts_by_user_group_id`), async data => {
|
|
32766
|
+
return await this.handler.getPojectDptsByUserAndGroupID(data);
|
|
32767
|
+
});
|
|
32768
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_ai_robot_infos`), async data => {
|
|
32769
|
+
let groupID = data.groupID;
|
|
32770
|
+
let userID = data.userID;
|
|
32771
|
+
if (this.userID == userID && this.groupID == groupID) {
|
|
32772
|
+
return this.getAIRobotInfos();
|
|
33432
32773
|
}
|
|
33433
|
-
|
|
32774
|
+
return [];
|
|
32775
|
+
});
|
|
32776
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_test_user_sig`), async data => {
|
|
32777
|
+
let sdkAppID = data.SDKAppID;
|
|
32778
|
+
let userID = data.userID;
|
|
32779
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
32780
|
+
SDKAppID: sdkAppID,
|
|
32781
|
+
userID: userID
|
|
32782
|
+
});
|
|
32783
|
+
let sigID = sigIDObject.userSig;
|
|
32784
|
+
return sigID;
|
|
32785
|
+
});
|
|
32786
|
+
this.handler.addChatListener(this.makeKey(`sdata_send_message_to_chat_server`), async (data, event) => {
|
|
32787
|
+
let message = data.message;
|
|
32788
|
+
let robotID = message.from;
|
|
32789
|
+
let result = await this.sendMessageToChatServer(robotID, message);
|
|
32790
|
+
return result;
|
|
32791
|
+
});
|
|
32792
|
+
this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
|
|
32793
|
+
return this.handler.closeWindow();
|
|
32794
|
+
});
|
|
32795
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
|
|
32796
|
+
return this.handler.getPortalDocmentInfo(data);
|
|
32797
|
+
});
|
|
32798
|
+
this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
|
|
32799
|
+
return this.handler.onAIAgentEvent(data, event);
|
|
32800
|
+
});
|
|
32801
|
+
this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
|
|
32802
|
+
console.log("recive chat regist event data:", data);
|
|
32803
|
+
this.appSKID = data.appid;
|
|
32804
|
+
this.imType = data.im_type;
|
|
32805
|
+
await this.initChatAIs();
|
|
32806
|
+
let charParams = {
|
|
32807
|
+
type: this.getChatTypeKey(this.chatType),
|
|
32808
|
+
singleChatID: this.singleChatID,
|
|
32809
|
+
customParams: this.customParams
|
|
32810
|
+
};
|
|
32811
|
+
this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
|
|
32812
|
+
if (result) {
|
|
32813
|
+
console.log("chat init finished:", result);
|
|
32814
|
+
this.handler.onChatInitFinished();
|
|
32815
|
+
}
|
|
32816
|
+
});
|
|
32817
|
+
});
|
|
32818
|
+
}
|
|
32819
|
+
getChatTypeKey(type) {
|
|
32820
|
+
switch (type) {
|
|
32821
|
+
case 0:
|
|
32822
|
+
return "IM_MULTIPLE_MODE";
|
|
32823
|
+
case 1:
|
|
32824
|
+
return "IM_SINGLE_MODE";
|
|
32825
|
+
case 2:
|
|
32826
|
+
return "IM_EMBED_MODE";
|
|
32827
|
+
case 3:
|
|
32828
|
+
return "IM_MOBILE_MULTIPLE_EMBED_MODE";
|
|
32829
|
+
case 4:
|
|
32830
|
+
return "IM_MOBILE_SINGLE_EMBED_MODE";
|
|
32831
|
+
default:
|
|
32832
|
+
return "IM_MULTIPLE_MODE";
|
|
32833
|
+
}
|
|
32834
|
+
}
|
|
32835
|
+
async initChatAIs() {
|
|
32836
|
+
if (window.imClient) {
|
|
32837
|
+
this.chatAIClient = window.imClient;
|
|
32838
|
+
} else {
|
|
32839
|
+
let classDatas = await this.handler.getChatClientClasses();
|
|
32840
|
+
const {
|
|
32841
|
+
TencentCloudChat,
|
|
32842
|
+
TIMUploadPlugin
|
|
32843
|
+
} = classDatas;
|
|
32844
|
+
window.imClient = TencentCloudChat.create({
|
|
32845
|
+
SDKAppID: this.appSKID,
|
|
32846
|
+
// 替换为你的 SDKAppID
|
|
32847
|
+
storage: {
|
|
32848
|
+
enable: true // 启用存储(可选,根据需求)
|
|
32849
|
+
}
|
|
32850
|
+
});
|
|
32851
|
+
window.imClient.registerPlugin({
|
|
32852
|
+
"tim-upload-plugin": TIMUploadPlugin
|
|
32853
|
+
});
|
|
32854
|
+
window.imClient.on(TencentCloudChat.EVENT.SDK_READY, this.onChatAIReady.bind(this));
|
|
32855
|
+
window.imClient.charAIs = {};
|
|
32856
|
+
this.chatAIClient = window.imClient;
|
|
33434
32857
|
}
|
|
33435
|
-
|
|
33436
|
-
|
|
33437
|
-
|
|
33438
|
-
|
|
33439
|
-
|
|
33440
|
-
|
|
33441
|
-
|
|
33442
|
-
|
|
33443
|
-
|
|
33444
|
-
|
|
33445
|
-
|
|
33446
|
-
|
|
33447
|
-
|
|
33448
|
-
|
|
33449
|
-
|
|
33450
|
-
|
|
33451
|
-
|
|
33452
|
-
|
|
33453
|
-
let newMatch = checkTextFormat(newValue);
|
|
33454
|
-
if (newMatch) {
|
|
33455
|
-
innerHTMLMatch = newMatch;
|
|
33456
|
-
} else {
|
|
33457
|
-
newValue = element.getAttribute("oldValue");
|
|
33458
|
-
if (!newValue) {
|
|
33459
|
-
newValue = element.innerHTML;
|
|
32858
|
+
if (!this.chatAIClient.charAIs) {
|
|
32859
|
+
this.chatAIClient.charAIs = {};
|
|
32860
|
+
}
|
|
32861
|
+
let robotInfos = await this.handler.getAIRobotInfos(this.userID, this.groupID);
|
|
32862
|
+
if (robotInfos && robotInfos.length > 0) {
|
|
32863
|
+
robotInfos.forEach(async robot => {
|
|
32864
|
+
let robotKey = robot.id;
|
|
32865
|
+
if (!this.chatAIClient.charAIs[robotKey]) {
|
|
32866
|
+
robot.chatID = robotKey;
|
|
32867
|
+
let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
|
|
32868
|
+
if (!userSig) {
|
|
32869
|
+
userSig = await this.generateUserSigAndAdd(robotKey);
|
|
32870
|
+
}
|
|
32871
|
+
robot.userSig = userSig;
|
|
32872
|
+
this.chatAIClient.charAIs[robotKey] = {
|
|
32873
|
+
robot: robot,
|
|
32874
|
+
messageCache: []
|
|
32875
|
+
};
|
|
33460
32876
|
}
|
|
33461
|
-
|
|
33462
|
-
}
|
|
33463
|
-
if (innerHTMLMatch) {
|
|
33464
|
-
// console.log("检查到innerHTML匹配元素:",element);
|
|
33465
|
-
element.setAttribute("oldValue", newValue);
|
|
33466
|
-
}
|
|
32877
|
+
});
|
|
33467
32878
|
}
|
|
33468
32879
|
}
|
|
33469
|
-
|
|
33470
|
-
|
|
33471
|
-
|
|
33472
|
-
|
|
33473
|
-
|
|
33474
|
-
|
|
33475
|
-
|
|
33476
|
-
|
|
33477
|
-
|
|
33478
|
-
|
|
33479
|
-
|
|
33480
|
-
|
|
33481
|
-
|
|
33482
|
-
|
|
33483
|
-
|
|
33484
|
-
|
|
33485
|
-
|
|
33486
|
-
|
|
33487
|
-
|
|
33488
|
-
id: elementId,
|
|
33489
|
-
isScriptAction: innerHTMLMatch ? innerHTMLMatch.isScriptAction || false : false,
|
|
33490
|
-
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
|
|
33491
|
-
isAttibuteAction: attrCheckResult.result,
|
|
33492
|
-
attrFunction: attrCheckResult.scriptFunction || null
|
|
33493
|
-
});
|
|
33494
|
-
// console.log("添加后元素缓冲数:",window.i18nElementsMap.size);
|
|
33495
|
-
applyTranslation(element);
|
|
33496
|
-
return true;
|
|
33497
|
-
}
|
|
33498
|
-
function unProcessElement(element) {
|
|
33499
|
-
if (element && element.nodeType !== 1) {
|
|
33500
|
-
return;
|
|
33501
|
-
}
|
|
33502
|
-
let hasChildren = hasChildElements(element);
|
|
33503
|
-
if (hasChildren) {
|
|
33504
|
-
let children = element.children;
|
|
33505
|
-
for (let i = 0; i < children.length; i++) {
|
|
33506
|
-
unProcessElement(children[i]);
|
|
32880
|
+
async generateUserSigAndUpdate(robotKey) {
|
|
32881
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
32882
|
+
SDKAppID: this.appSKID,
|
|
32883
|
+
userID: robotKey
|
|
32884
|
+
});
|
|
32885
|
+
let userSig = sigIDObject.userSig;
|
|
32886
|
+
if (userSig) {
|
|
32887
|
+
await this.chatAIClient.login({
|
|
32888
|
+
userID: robotKey,
|
|
32889
|
+
userSig: userSig
|
|
32890
|
+
});
|
|
32891
|
+
await this.chatAIClient.logout();
|
|
32892
|
+
let data = {
|
|
32893
|
+
userID: robotKey,
|
|
32894
|
+
userSig: userSig,
|
|
32895
|
+
im_type: this.imType,
|
|
32896
|
+
group_id: this.groupID
|
|
32897
|
+
};
|
|
32898
|
+
await this.handler.updateIMMapping(data);
|
|
33507
32899
|
}
|
|
32900
|
+
return userSig;
|
|
33508
32901
|
}
|
|
33509
|
-
|
|
33510
|
-
|
|
33511
|
-
|
|
33512
|
-
|
|
33513
|
-
|
|
33514
|
-
|
|
33515
|
-
|
|
33516
|
-
|
|
33517
|
-
|
|
33518
|
-
|
|
33519
|
-
// element.innerHTML = oldValue;
|
|
33520
|
-
// }
|
|
33521
|
-
window.i18nElementsMap.delete(localDomID);
|
|
33522
|
-
// console.log("移除后元素缓冲数:",window.i18nElementsMap.size);
|
|
33523
|
-
}
|
|
33524
|
-
}
|
|
33525
|
-
|
|
33526
|
-
/**
|
|
33527
|
-
* 应用翻译到单个元素
|
|
33528
|
-
* @param {HTMLElement} element - 要更新的DOM元素
|
|
33529
|
-
* @param {string} lang - 语言标识符
|
|
33530
|
-
*/
|
|
33531
|
-
const applyTranslation = async element => {
|
|
33532
|
-
let parentNode = element.parentNode;
|
|
33533
|
-
if (!parentNode) {
|
|
33534
|
-
unProcessElement(element);
|
|
33535
|
-
console.log("元素已无父节点,移除缓存");
|
|
33536
|
-
return;
|
|
33537
|
-
}
|
|
33538
|
-
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33539
|
-
let appID = getPoratlAppID();
|
|
33540
|
-
const elementId = element.getAttribute("localDomID");
|
|
33541
|
-
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
33542
|
-
if (!cachedItem) return;
|
|
33543
|
-
// 处理属性
|
|
33544
|
-
if (cachedItem.isAttibuteAction) {
|
|
33545
|
-
cachedItem.attrFunction(appID, lang);
|
|
33546
|
-
}
|
|
33547
|
-
// 处理innerHTML
|
|
33548
|
-
if (cachedItem.isScriptAction) {
|
|
33549
|
-
cachedItem.scriptFunction(appID, lang);
|
|
33550
|
-
} else {
|
|
33551
|
-
const oldValue = element.getAttribute("oldValue");
|
|
33552
|
-
if (oldValue) {
|
|
33553
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33554
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
33555
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
33556
|
-
let newValue = oldValue;
|
|
33557
|
-
let match;
|
|
33558
|
-
while ((match = regex.exec(oldValue)) !== null) {
|
|
33559
|
-
const fullMatch = match[0];
|
|
33560
|
-
const placeholderKey = match[1];
|
|
33561
|
-
const translation = i18n(placeholderKey, appID, lang);
|
|
33562
|
-
newValue = newValue.replace(fullMatch, translation);
|
|
33563
|
-
}
|
|
33564
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.nextTick)(() => {
|
|
33565
|
-
// 更新元素的innerHTML
|
|
33566
|
-
element.innerHTML = newValue;
|
|
32902
|
+
async generateUserSigAndAdd(robotKey) {
|
|
32903
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
32904
|
+
SDKAppID: this.appSKID,
|
|
32905
|
+
userID: robotKey
|
|
32906
|
+
});
|
|
32907
|
+
let userSig = sigIDObject.userSig;
|
|
32908
|
+
if (userSig) {
|
|
32909
|
+
await this.chatAIClient.login({
|
|
32910
|
+
userID: robotKey,
|
|
32911
|
+
userSig: userSig
|
|
33567
32912
|
});
|
|
32913
|
+
await this.chatAIClient.logout();
|
|
32914
|
+
await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
|
|
33568
32915
|
}
|
|
32916
|
+
return userSig;
|
|
33569
32917
|
}
|
|
33570
|
-
|
|
33571
|
-
|
|
33572
|
-
|
|
33573
|
-
|
|
33574
|
-
|
|
33575
|
-
|
|
33576
|
-
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
|
|
33582
|
-
|
|
32918
|
+
onChatAIReady(event) {
|
|
32919
|
+
let robotID = this.chatAIClient.lastRobotID;
|
|
32920
|
+
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
32921
|
+
console.log(`[AI chat] ${robotInfo.name}已经就绪:`, event);
|
|
32922
|
+
if (this.chatAIClient) {
|
|
32923
|
+
let messages = this.getAIRobotCacheMessagesByID(robotID);
|
|
32924
|
+
console.log(`[AI chat] ${robotInfo.name}就绪后查到的缓存信息:`, messages);
|
|
32925
|
+
console.log(`[AI chat] ${robotInfo.name}所有信息仓:`, this.chatAIClient.charAIs);
|
|
32926
|
+
if (messages && messages.length > 0) {
|
|
32927
|
+
const newMessages = [...messages];
|
|
32928
|
+
messages.splice(0, messages.length);
|
|
32929
|
+
newMessages.forEach(message => {
|
|
32930
|
+
console.log(`[AI chat] ${robotInfo.name}发送缓存消息:`, message);
|
|
32931
|
+
this.sendMessageToChatServer(robotID, message);
|
|
32932
|
+
});
|
|
32933
|
+
}
|
|
33583
32934
|
}
|
|
33584
|
-
}
|
|
33585
|
-
|
|
33586
|
-
|
|
33587
|
-
|
|
33588
|
-
|
|
33589
|
-
|
|
33590
|
-
|
|
33591
|
-
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
// console.log(`处理移除节点:`,node);
|
|
33605
|
-
unProcessElement(node);
|
|
33606
|
-
}
|
|
33607
|
-
}
|
|
33608
|
-
} else if (mutation.type === 'characterData') {
|
|
33609
|
-
// 处理文本变化
|
|
33610
|
-
const oldValue = mutation.oldValue;
|
|
33611
|
-
const targetNode = mutation.target;
|
|
33612
|
-
const newValue = targetNode.data;
|
|
33613
|
-
// 创建日志条目并显示
|
|
33614
|
-
console.log(`文本修改: ${oldValue} → ${newValue}`);
|
|
33615
|
-
const parentElement = targetNode.parentNode;
|
|
33616
|
-
if (parentElement) {
|
|
33617
|
-
let localDomID = parentElement.getAttribute("localDomID");
|
|
33618
|
-
// 如果有localDomID,说明之前处理过,先移除缓存
|
|
33619
|
-
if (localDomID) {
|
|
33620
|
-
unProcessElement(parentElement);
|
|
33621
|
-
}
|
|
33622
|
-
}
|
|
33623
|
-
processElement(parentElement);
|
|
32935
|
+
}
|
|
32936
|
+
getAIRobotInfos() {
|
|
32937
|
+
let resultRobots = [];
|
|
32938
|
+
for (let key in this.chatAIClient.charAIs) {
|
|
32939
|
+
resultRobots.push(this.chatAIClient.charAIs[key].robot);
|
|
32940
|
+
}
|
|
32941
|
+
return resultRobots;
|
|
32942
|
+
}
|
|
32943
|
+
getAIRobotInfoByID(robotID) {
|
|
32944
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].robot : null;
|
|
32945
|
+
}
|
|
32946
|
+
getAIRobotCacheMessagesByID(robotID) {
|
|
32947
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].messageCache : [];
|
|
32948
|
+
}
|
|
32949
|
+
async sendMessageToChatServer(robotID, messageOption) {
|
|
32950
|
+
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
32951
|
+
if (this.chatAIClient.lastRobotID != robotID) {
|
|
32952
|
+
console.log(`[AI chat]需要新机器人回答,切换到新机器人${robotInfo.name}`);
|
|
32953
|
+
if (this.chatAIClient.lastRobotID) {
|
|
32954
|
+
await this.chatAIClient.logout();
|
|
33624
32955
|
}
|
|
33625
|
-
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
|
|
33629
|
-
|
|
33630
|
-
|
|
33631
|
-
|
|
33632
|
-
|
|
33633
|
-
|
|
33634
|
-
|
|
33635
|
-
|
|
33636
|
-
|
|
33637
|
-
|
|
33638
|
-
|
|
33639
|
-
|
|
33640
|
-
|
|
33641
|
-
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
};
|
|
33645
|
-
|
|
33646
|
-
// 创建观察器实例
|
|
33647
|
-
const observer = new MutationObserver(mutations => {
|
|
33648
|
-
mutations.forEach(mutation => {
|
|
33649
|
-
if (mutation.type === 'childList') {
|
|
33650
|
-
// 节点添加
|
|
33651
|
-
if (mutation.addedNodes.length > 0) {
|
|
33652
|
-
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
33653
|
-
let node = mutation.addedNodes[i];
|
|
33654
|
-
processViewElement(node);
|
|
32956
|
+
try {
|
|
32957
|
+
await this.chatAIClient.login({
|
|
32958
|
+
userID: robotID,
|
|
32959
|
+
userSig: robotInfo.userSig
|
|
32960
|
+
});
|
|
32961
|
+
} catch (err) {
|
|
32962
|
+
console.log(`[AI chat]${robotInfo.name}登录失败`, err);
|
|
32963
|
+
let code = err.code;
|
|
32964
|
+
if (code == 70001) {
|
|
32965
|
+
console.log(`[AI chat]${robotInfo.name}UserSig过期,重新生成userSig`);
|
|
32966
|
+
let newUserSig = await this.generateUserSigAndUpdate(robotID);
|
|
32967
|
+
try {
|
|
32968
|
+
await this.chatAIClient.login({
|
|
32969
|
+
userID: robotID,
|
|
32970
|
+
userSig: newUserSig
|
|
32971
|
+
});
|
|
32972
|
+
this.sendMessageToChatServer(robotID, messageOption);
|
|
32973
|
+
return;
|
|
32974
|
+
} catch (err) {
|
|
32975
|
+
console.log(`[AI chat]${robotInfo.name}重新登录失败`, err);
|
|
32976
|
+
return;
|
|
33655
32977
|
}
|
|
33656
32978
|
}
|
|
33657
32979
|
}
|
|
33658
|
-
}
|
|
33659
|
-
|
|
33660
|
-
|
|
33661
|
-
|
|
33662
|
-
|
|
33663
|
-
|
|
33664
|
-
|
|
33665
|
-
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
|
|
33669
|
-
|
|
33670
|
-
|
|
33671
|
-
characterDataOldValue: true
|
|
33672
|
-
};
|
|
33673
|
-
// 开始观察目标节点
|
|
33674
|
-
const targetNode = document.body;
|
|
33675
|
-
processViewElement(targetNode);
|
|
33676
|
-
observer.observe(targetNode, config);
|
|
33677
|
-
};
|
|
33678
|
-
|
|
33679
|
-
// 处理单个DOM元素的函数
|
|
33680
|
-
function processViewElement(element) {
|
|
33681
|
-
if (!element) {
|
|
33682
|
-
return false;
|
|
33683
|
-
}
|
|
33684
|
-
// 仅处理元素节点
|
|
33685
|
-
if (element && element.nodeType !== Node.ELEMENT_NODE) {
|
|
33686
|
-
return false;
|
|
33687
|
-
}
|
|
33688
|
-
// 如果元素有子元素,则不处理innerHTML
|
|
33689
|
-
const hasChildren = hasChildElements(element);
|
|
33690
|
-
if (hasChildren) {
|
|
33691
|
-
let children = element.children;
|
|
33692
|
-
for (let i = 0; i < children.length; i++) {
|
|
33693
|
-
let child = children[i];
|
|
33694
|
-
processViewElement(child);
|
|
32980
|
+
}
|
|
32981
|
+
this.chatAIClient.lastRobotID = robotID;
|
|
32982
|
+
if (this.chatAIClient && this.chatAIClient.isReady()) {
|
|
32983
|
+
let new_message = await this.chatAIClient.createTextMessage(messageOption);
|
|
32984
|
+
this.chatAIClient.sendMessage(new_message).then(res => {
|
|
32985
|
+
console.log(`[AI chat]${robotInfo.name}发送信息成功`, res);
|
|
32986
|
+
}, err => {
|
|
32987
|
+
console.log(`[AI chat]${robotInfo.name}发送失败`, err);
|
|
32988
|
+
});
|
|
32989
|
+
} else {
|
|
32990
|
+
let messageCache = this.getAIRobotCacheMessagesByID(robotID);
|
|
32991
|
+
messageCache.push(messageOption);
|
|
32992
|
+
console.log(`[AI chat]${robotInfo.name}未就绪,缓存后消息:`, messageCache);
|
|
33695
32993
|
}
|
|
33696
32994
|
}
|
|
33697
|
-
|
|
33698
|
-
|
|
33699
|
-
|
|
33700
|
-
|
|
32995
|
+
converToAIServerParams(message, robotInfo, param) {
|
|
32996
|
+
let prompt = "";
|
|
32997
|
+
let type = message.type;
|
|
32998
|
+
switch (type) {
|
|
32999
|
+
case "TIMTextElem":
|
|
33000
|
+
prompt = message.payload?.text || "";
|
|
33001
|
+
break;
|
|
33002
|
+
case "TIMImageElem":
|
|
33003
|
+
break;
|
|
33004
|
+
case "TIMSoundElem":
|
|
33005
|
+
break;
|
|
33006
|
+
case "TIMVideoFileElem":
|
|
33007
|
+
break;
|
|
33008
|
+
case "TIMFileElem":
|
|
33009
|
+
break;
|
|
33010
|
+
default:
|
|
33011
|
+
break;
|
|
33012
|
+
}
|
|
33013
|
+
let cloudCustomData = message.cloudCustomData || {};
|
|
33014
|
+
let conversation_id = cloudCustomData.conversation_id || "";
|
|
33015
|
+
let params = {
|
|
33016
|
+
prompt: prompt,
|
|
33017
|
+
params: param || {},
|
|
33018
|
+
robotKey: robotInfo.password,
|
|
33019
|
+
conversation_id: conversation_id || "",
|
|
33020
|
+
userID: message.from || ""
|
|
33021
|
+
};
|
|
33022
|
+
return params;
|
|
33701
33023
|
}
|
|
33702
|
-
|
|
33703
|
-
|
|
33704
|
-
if (!viewCheckResult.result) {
|
|
33705
|
-
return false;
|
|
33024
|
+
abort() {
|
|
33025
|
+
this.chatAIClient = null;
|
|
33706
33026
|
}
|
|
33707
|
-
viewCheckResult.scriptFunction();
|
|
33708
|
-
return true;
|
|
33709
33027
|
}
|
|
33710
|
-
|
|
33711
|
-
// 获取所有i18n的类型
|
|
33712
|
-
const getAllI18nTypes = async () => {
|
|
33713
|
-
let requestData = {
|
|
33714
|
-
param: {}
|
|
33715
|
-
};
|
|
33716
|
-
let result = await request.post(`/dataservice/rest/orchestration/getAllI18nTypes`, requestData);
|
|
33717
|
-
let resultData = result.data.resultDatas;
|
|
33718
|
-
return resultData;
|
|
33719
|
-
};
|
|
33720
|
-
;// ./src/api/security.js
|
|
33721
|
-
|
|
33722
|
-
|
|
33723
|
-
|
|
33028
|
+
;// ./src/api/chat.js
|
|
33724
33029
|
|
|
33725
33030
|
|
|
33726
|
-
/**
|
|
33727
|
-
*
|
|
33728
|
-
* @returns 获取登录验证码图片
|
|
33729
|
-
*/
|
|
33730
|
-
const getAuthPic = () => request.get(`/system/authority/getAuthPic?module=loginPassword`, {
|
|
33731
|
-
responseType: "arraybuffer"
|
|
33732
|
-
});
|
|
33733
33031
|
|
|
33734
|
-
/**
|
|
33735
|
-
* 登出账号
|
|
33736
|
-
* @param endside_type 0: web 1:手机
|
|
33737
|
-
* @returns {Promise<*>}
|
|
33738
|
-
* @param endside_type 0: web 1:手机
|
|
33739
|
-
*
|
|
33740
|
-
*/
|
|
33741
|
-
const logoutAccount = async endside_type => {
|
|
33742
|
-
let resultData = await request.get(`/system/authority/logout?isMobileLogout=${endside_type}`);
|
|
33743
|
-
let response = JSON.parse(resultData.request.response);
|
|
33744
|
-
let resultCode = response.code;
|
|
33745
|
-
if (resultCode == "10110020") {
|
|
33746
|
-
window.sessionStorage.clear();
|
|
33747
|
-
return {
|
|
33748
|
-
code: resultCode,
|
|
33749
|
-
message: i18nText(response.message)
|
|
33750
|
-
};
|
|
33751
|
-
} else {
|
|
33752
|
-
return {
|
|
33753
|
-
code: resultCode,
|
|
33754
|
-
message: i18nText(response.message)
|
|
33755
|
-
};
|
|
33756
|
-
}
|
|
33757
|
-
};
|
|
33758
33032
|
|
|
33759
|
-
|
|
33760
|
-
* 服务端解密
|
|
33761
|
-
*/
|
|
33762
|
-
const serverDecrypt = async decryptStr => {
|
|
33763
|
-
let questUrl = `/ext/serverDecrypt`;
|
|
33033
|
+
const getRobotInfoByID = async (robotID, groupID) => {
|
|
33764
33034
|
let queryData = {
|
|
33765
|
-
param: {
|
|
33766
|
-
|
|
33035
|
+
"param": {
|
|
33036
|
+
"id": robotID,
|
|
33037
|
+
"groupID": groupID
|
|
33038
|
+
}
|
|
33039
|
+
};
|
|
33040
|
+
let result = await request.post(`/dataservice/rest/orchestration/getRobotInfoByID`, queryData);
|
|
33041
|
+
let robotInfo = result.data.robotInfo;
|
|
33042
|
+
return robotInfo;
|
|
33043
|
+
};
|
|
33044
|
+
const getIMHanlder = customerHanlder => {
|
|
33045
|
+
let handler = {
|
|
33046
|
+
genTestUserSig: async data => {
|
|
33047
|
+
// return genTestUserSig(data);
|
|
33048
|
+
},
|
|
33049
|
+
getChatClientClasses: async () => {
|
|
33050
|
+
return [];
|
|
33051
|
+
},
|
|
33052
|
+
getAIRobotInfos: async (user_id, groupID) => {
|
|
33053
|
+
return getAIRobotInfos(user_id, groupID);
|
|
33054
|
+
},
|
|
33055
|
+
getPortalUserSig: async (robotKey, platType, groupID) => {
|
|
33056
|
+
return getPortalUserSig(robotKey, platType, groupID);
|
|
33057
|
+
},
|
|
33058
|
+
addIMMapping: async (robotKey, platType, userSig, groupID) => {
|
|
33059
|
+
return addIMMapping(robotKey, platType, groupID, userSig);
|
|
33060
|
+
},
|
|
33061
|
+
updateIMMapping: async data => {
|
|
33062
|
+
let robotKey = data.userID;
|
|
33063
|
+
let platType = data.im_type;
|
|
33064
|
+
let groupID = data.group_id;
|
|
33065
|
+
let userSig = data.userSig;
|
|
33066
|
+
return updateIMMapping(robotKey, platType, groupID, userSig);
|
|
33067
|
+
},
|
|
33068
|
+
getPortalAccessToken: async data => {
|
|
33069
|
+
let appKey = data.appKey;
|
|
33070
|
+
let appSecret = data.appSecret;
|
|
33071
|
+
return getPortalAccessToken(appKey, appSecret);
|
|
33072
|
+
},
|
|
33073
|
+
getPortalUserInfo: async data => {
|
|
33074
|
+
let code = data.code;
|
|
33075
|
+
let access_token = data.access_token;
|
|
33076
|
+
return getPortalUserInfo(code, access_token);
|
|
33077
|
+
},
|
|
33078
|
+
getAllUserInfosByGroupID: async data => {
|
|
33079
|
+
let groupID = data.groupID;
|
|
33080
|
+
return getAllUserInfosByGroupID(groupID);
|
|
33081
|
+
},
|
|
33082
|
+
getChildrenOfficeInfosByID: async data => {
|
|
33083
|
+
let groupID = data.groupID;
|
|
33084
|
+
return getChildrenOfficeInfosByID(groupID);
|
|
33085
|
+
},
|
|
33086
|
+
getPojectDptsByUserAndGroupID: async data => {
|
|
33087
|
+
let groupID = data.groupID;
|
|
33088
|
+
let userID = data.userID;
|
|
33089
|
+
return getPojectDptsByUserAndGroupID(userID, groupID);
|
|
33090
|
+
},
|
|
33091
|
+
closeWindow: () => {
|
|
33092
|
+
// this.visable = false;
|
|
33093
|
+
return true;
|
|
33094
|
+
},
|
|
33095
|
+
addChatListener: async (listenerKey, handler) => {
|
|
33096
|
+
await addEventAction(listenerKey, handler);
|
|
33097
|
+
},
|
|
33098
|
+
fireEventToChatWindow: async (event, chart_origin, key, params, handler) => {
|
|
33099
|
+
await sendWindowMessage(event.source, chart_origin, key, params, handler);
|
|
33100
|
+
},
|
|
33101
|
+
onChatInitFinished: async () => {
|
|
33102
|
+
// this.chatInitFinish = true;
|
|
33103
|
+
},
|
|
33104
|
+
onAIAgentEvent: async (data, event) => {
|
|
33105
|
+
// this.onAIAgentEvent(data,event);
|
|
33106
|
+
},
|
|
33107
|
+
getPortalDocmentInfo: async data => {
|
|
33108
|
+
let kb_doc_id = data.kb_doc_id;
|
|
33109
|
+
let doc_info = await getPortalDocmentInfo(kb_doc_id);
|
|
33110
|
+
let urlStr = doc_info?.summary;
|
|
33111
|
+
if (urlStr) {
|
|
33112
|
+
let urlObj = JSON.parse(urlStr);
|
|
33113
|
+
if (urlObj) {
|
|
33114
|
+
let url = urlObj[0].url;
|
|
33115
|
+
let home_page = window.smardaten_api_context_path;
|
|
33116
|
+
let finalUrl = `${home_page}/storage_area/public${url}`;
|
|
33117
|
+
let fileSize = await getFileSize(finalUrl);
|
|
33118
|
+
doc_info.fileSize = fileSize;
|
|
33119
|
+
}
|
|
33120
|
+
}
|
|
33121
|
+
return doc_info;
|
|
33767
33122
|
}
|
|
33768
33123
|
};
|
|
33769
|
-
|
|
33770
|
-
|
|
33771
|
-
|
|
33772
|
-
|
|
33124
|
+
handler = {
|
|
33125
|
+
...handler,
|
|
33126
|
+
...customerHanlder
|
|
33127
|
+
};
|
|
33128
|
+
return handler;
|
|
33773
33129
|
};
|
|
33774
33130
|
|
|
33775
|
-
|
|
33776
|
-
* 解密
|
|
33777
|
-
*/
|
|
33778
|
-
const viewDecrypt = async decryptStr => {
|
|
33779
|
-
let secretKey = await getViewKey();
|
|
33780
|
-
const decrypted = crypto_js_default().AES.decrypt(decryptStr, secretKey).toString((crypto_js_default()).enc.Utf8);
|
|
33781
|
-
return decrypted;
|
|
33782
|
-
};
|
|
33131
|
+
;// ./src/api/dify.js
|
|
33783
33132
|
|
|
33784
|
-
/**
|
|
33785
|
-
* 加密
|
|
33786
|
-
*/
|
|
33787
|
-
const viewEncrypt = async decryptStr => {
|
|
33788
|
-
let secretKey = await getViewKey();
|
|
33789
|
-
const encrypted = crypto_js_default().AES.encrypt(decryptStr, secretKey).toString();
|
|
33790
|
-
return encrypted;
|
|
33791
|
-
};
|
|
33792
33133
|
|
|
33793
|
-
|
|
33794
|
-
|
|
33795
|
-
|
|
33796
|
-
|
|
33797
|
-
|
|
33798
|
-
|
|
33799
|
-
|
|
33800
|
-
|
|
33801
|
-
|
|
33134
|
+
const sendPostToAIAgent = async (queryData, successCallback, errorCallback) => {
|
|
33135
|
+
let appid = getPoratlAppID();
|
|
33136
|
+
let appCustomData = await getAppCustomData(appid);
|
|
33137
|
+
let aiAgentServerIP = appCustomData?.aiAgentServerIP || "";
|
|
33138
|
+
if (!aiAgentServerIP) {
|
|
33139
|
+
console.error("没有配置AI Agent服务地址,请联系管理员");
|
|
33140
|
+
if (errorCallback) errorCallback("没有配置AI Agent服务地址,请联系管理员");
|
|
33141
|
+
return;
|
|
33142
|
+
}
|
|
33143
|
+
let serverUrl = `${aiAgentServerIP}/addAndCleanDocument`;
|
|
33144
|
+
request.post(serverUrl, JSON.stringify(queryData)).then(res => {
|
|
33145
|
+
console.log("发送消息成功:", res);
|
|
33146
|
+
if (successCallback) successCallback(res);
|
|
33147
|
+
}).catch(error => {
|
|
33148
|
+
console.error("发送消息失败:", error);
|
|
33149
|
+
if (errorCallback) errorCallback(error);
|
|
33150
|
+
});
|
|
33151
|
+
};
|
|
33152
|
+
const getDifyFileType = fileType => {
|
|
33153
|
+
let typeOptions = {
|
|
33154
|
+
"DOCX": "document",
|
|
33155
|
+
"TXT": "document",
|
|
33156
|
+
"MD": "document",
|
|
33157
|
+
"MARKDOWN": "document",
|
|
33158
|
+
"MDX": "document",
|
|
33159
|
+
"PDF": "document",
|
|
33160
|
+
"HTML": "document",
|
|
33161
|
+
"XLSX": "document",
|
|
33162
|
+
"XLS": "document",
|
|
33163
|
+
"VTT": "document",
|
|
33164
|
+
"DOC": "document",
|
|
33165
|
+
"CSV": "document",
|
|
33166
|
+
"EML": "document",
|
|
33167
|
+
"MSG": "document",
|
|
33168
|
+
"PPTX": "document",
|
|
33169
|
+
"PPT": "document",
|
|
33170
|
+
"XML": "document",
|
|
33171
|
+
"EPUB": "document",
|
|
33172
|
+
"JPG": "image",
|
|
33173
|
+
"JPEG": "image",
|
|
33174
|
+
"PNG": "image",
|
|
33175
|
+
"GIF": "image",
|
|
33176
|
+
"WEBP": "image",
|
|
33177
|
+
"MP3": "audio",
|
|
33178
|
+
"M4A": "audio",
|
|
33179
|
+
"WAV": "audio",
|
|
33180
|
+
"WEBM": "audio",
|
|
33181
|
+
"MPGA": "audio",
|
|
33182
|
+
"MP4": "video",
|
|
33183
|
+
"MOV": "video",
|
|
33184
|
+
"MPEG": "video"
|
|
33802
33185
|
};
|
|
33803
|
-
|
|
33804
|
-
|
|
33805
|
-
encryptStr = resultData.data.encryptStr;
|
|
33806
|
-
return encryptStr;
|
|
33186
|
+
let key = fileType.toUpperCase();
|
|
33187
|
+
return typeOptions[key] || "custom";
|
|
33807
33188
|
};
|
|
33808
33189
|
|
|
33809
33190
|
/**
|
|
33810
|
-
|
|
33811
|
-
|
|
33812
|
-
|
|
33813
|
-
|
|
33814
|
-
|
|
33815
|
-
|
|
33816
|
-
|
|
33817
|
-
|
|
33818
|
-
|
|
33819
|
-
|
|
33820
|
-
|
|
33821
|
-
|
|
33822
|
-
|
|
33823
|
-
|
|
33824
|
-
|
|
33825
|
-
|
|
33826
|
-
|
|
33827
|
-
|
|
33191
|
+
* 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
|
|
33192
|
+
* @param {string} url - 文件 URL
|
|
33193
|
+
* @returns {string} - 提取的文件名
|
|
33194
|
+
*/
|
|
33195
|
+
const dify_extractFilenameFromUrl = url => {
|
|
33196
|
+
try {
|
|
33197
|
+
const urlObj = new URL(url);
|
|
33198
|
+
// 从路径中获取最后一个部分(文件名)
|
|
33199
|
+
return urlObj.pathname.split("/").pop() || "downloaded_file";
|
|
33200
|
+
} catch (e) {
|
|
33201
|
+
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
33202
|
+
}
|
|
33203
|
+
};
|
|
33204
|
+
;// external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
|
|
33205
|
+
var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
|
|
33206
|
+
;// ./src/api/i18n/smardaten_i18n/table_i18n.js
|
|
33207
|
+
|
|
33208
|
+
const check = element => {
|
|
33209
|
+
const checkResult = {
|
|
33210
|
+
result: false,
|
|
33211
|
+
innerHTMLMatch: null
|
|
33212
|
+
};
|
|
33213
|
+
const classes = element.classList;
|
|
33214
|
+
if (!classes) {
|
|
33215
|
+
return checkResult;
|
|
33216
|
+
}
|
|
33217
|
+
// 检查表格头部 序号 和 操作 列
|
|
33218
|
+
if (classes.contains("ant-table-cell")) {
|
|
33219
|
+
let innerHTML = element.innerHTML;
|
|
33220
|
+
if (innerHTML.includes("序号") || innerHTML.includes("Serial No.")) {
|
|
33221
|
+
// console.log("检查smardaten平台表格 序号 元素:",innerHTML);
|
|
33222
|
+
let tempHTMLMatch = {
|
|
33223
|
+
oldValue: '$L{序号}'
|
|
33224
|
+
};
|
|
33225
|
+
checkResult.result = true;
|
|
33226
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33227
|
+
return checkResult;
|
|
33228
|
+
}
|
|
33229
|
+
if (innerHTML.includes("操作")) {
|
|
33230
|
+
// console.log("检查smardaten平台表格 操作 元素:",innerHTML);
|
|
33231
|
+
let tempHTMLMatch = {
|
|
33232
|
+
oldValue: '$L{操作}'
|
|
33233
|
+
};
|
|
33234
|
+
checkResult.result = true;
|
|
33235
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33236
|
+
return checkResult;
|
|
33237
|
+
}
|
|
33238
|
+
}
|
|
33239
|
+
// 检查分页组件 导出按钮
|
|
33240
|
+
if (classes.contains("export_menu")) {
|
|
33241
|
+
let innerHTML = element.innerHTML;
|
|
33242
|
+
if (innerHTML.includes("导出进度") || innerHTML.includes("Export progress")) {
|
|
33243
|
+
// console.log("检查smardaten平台表格 导出按钮 元素:",innerHTML);
|
|
33244
|
+
let tempHTMLMatch = {
|
|
33245
|
+
oldValue: '$L{导出进度}'
|
|
33246
|
+
};
|
|
33247
|
+
checkResult.result = true;
|
|
33248
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33249
|
+
return checkResult;
|
|
33250
|
+
}
|
|
33251
|
+
}
|
|
33252
|
+
// 检查分页组件
|
|
33253
|
+
if (classes.contains("total_pag_num")) {
|
|
33254
|
+
let innerHTML = element.innerHTML;
|
|
33255
|
+
if (innerHTML.includes("共") && innerHTML.includes("条") || innerHTML.includes("Total") && innerHTML.includes("pieces")) {
|
|
33256
|
+
// console.log("检查smardaten平台分页 共xx条 元素:",innerHTML);
|
|
33257
|
+
let scriptFunction = (appID, lang) => {
|
|
33258
|
+
let scriptNode = null;
|
|
33259
|
+
for (let node of element.childNodes) {
|
|
33260
|
+
// 检查是否为文本节点且包含"Total"
|
|
33261
|
+
if (node.tagName === "SPAN") {
|
|
33262
|
+
scriptNode = node;
|
|
33263
|
+
}
|
|
33264
|
+
}
|
|
33265
|
+
let scriptNodes = [{
|
|
33266
|
+
nodeType: Node.TEXT_NODE,
|
|
33267
|
+
key: '共'
|
|
33268
|
+
}, {
|
|
33269
|
+
nodeType: "SCRIPTNODE",
|
|
33270
|
+
node: scriptNode
|
|
33271
|
+
}, {
|
|
33272
|
+
nodeType: Node.TEXT_NODE,
|
|
33273
|
+
key: '条'
|
|
33274
|
+
}];
|
|
33275
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33276
|
+
let childNode = element.childNodes[i];
|
|
33277
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
33278
|
+
element.removeChild(childNode);
|
|
33279
|
+
}
|
|
33280
|
+
}
|
|
33281
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
33282
|
+
let scriptNodeItem = scriptNodes[i];
|
|
33283
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33284
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
33285
|
+
element.appendChild(textNode);
|
|
33286
|
+
}
|
|
33287
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
33288
|
+
element.appendChild(scriptNodeItem.node);
|
|
33289
|
+
}
|
|
33290
|
+
}
|
|
33291
|
+
};
|
|
33292
|
+
let tempHTMLMatch = {
|
|
33293
|
+
isScriptAction: true,
|
|
33294
|
+
scriptFunction: scriptFunction
|
|
33295
|
+
};
|
|
33296
|
+
checkResult.result = true;
|
|
33297
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33298
|
+
return checkResult;
|
|
33299
|
+
}
|
|
33300
|
+
}
|
|
33301
|
+
// 检查分页组件 跳至xx页
|
|
33302
|
+
if (classes.contains("ant-pagination-options-quick-jumper")) {
|
|
33303
|
+
let innerHTML = element.innerHTML;
|
|
33304
|
+
if (innerHTML.includes("跳至") && innerHTML.includes("页") || innerHTML.includes("Go to") && innerHTML.includes("Page")) {
|
|
33305
|
+
// console.log("检查smardaten平台分页 跳至xx页 元素:",innerHTML);
|
|
33306
|
+
let scriptFunction = (appID, lang) => {
|
|
33307
|
+
let scriptNode = null;
|
|
33308
|
+
for (let node of element.childNodes) {
|
|
33309
|
+
// 检查是否为文本节点且包含"Total"
|
|
33310
|
+
if (node.tagName === "INPUT") {
|
|
33311
|
+
scriptNode = node;
|
|
33312
|
+
}
|
|
33313
|
+
}
|
|
33314
|
+
let scriptNodes = [{
|
|
33315
|
+
nodeType: Node.TEXT_NODE,
|
|
33316
|
+
key: '跳至'
|
|
33317
|
+
}, {
|
|
33318
|
+
nodeType: "SCRIPTNODE",
|
|
33319
|
+
node: scriptNode
|
|
33320
|
+
}, {
|
|
33321
|
+
nodeType: Node.TEXT_NODE,
|
|
33322
|
+
key: '页'
|
|
33323
|
+
}];
|
|
33324
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33325
|
+
let childNode = element.childNodes[i];
|
|
33326
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
33327
|
+
element.removeChild(childNode);
|
|
33328
|
+
}
|
|
33329
|
+
}
|
|
33330
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
33331
|
+
let scriptNodeItem = scriptNodes[i];
|
|
33332
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33333
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
33334
|
+
element.appendChild(textNode);
|
|
33335
|
+
}
|
|
33336
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
33337
|
+
element.appendChild(scriptNodeItem.node);
|
|
33338
|
+
}
|
|
33339
|
+
}
|
|
33340
|
+
};
|
|
33341
|
+
let tempHTMLMatch = {
|
|
33342
|
+
isScriptAction: true,
|
|
33343
|
+
scriptFunction: scriptFunction
|
|
33344
|
+
};
|
|
33345
|
+
checkResult.result = true;
|
|
33346
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33347
|
+
return checkResult;
|
|
33348
|
+
}
|
|
33828
33349
|
}
|
|
33829
|
-
|
|
33830
|
-
|
|
33831
|
-
|
|
33832
|
-
|
|
33833
|
-
|
|
33834
|
-
|
|
33835
|
-
|
|
33836
|
-
|
|
33837
|
-
|
|
33838
|
-
|
|
33839
|
-
|
|
33840
|
-
|
|
33841
|
-
|
|
33350
|
+
// 检查每页xx条
|
|
33351
|
+
if (classes.contains("ant-select-selection-item") || classes.contains("ant-select-item-option-content")) {
|
|
33352
|
+
let innerHTML = element.innerHTML;
|
|
33353
|
+
// console.log("检查smardaten平台分页 每页xx条 元素:",innerHTML);
|
|
33354
|
+
if (innerHTML.includes("/") && innerHTML.includes("page") || innerHTML.includes("/") && innerHTML.includes("条") && innerHTML.includes("页")) {
|
|
33355
|
+
let oldValue = element.innerHTML;
|
|
33356
|
+
if (innerHTML.includes("page")) {
|
|
33357
|
+
oldValue = oldValue.replace('page', '$L{页}');
|
|
33358
|
+
}
|
|
33359
|
+
if (innerHTML.includes("页")) {
|
|
33360
|
+
oldValue = oldValue.replace('页', '$L{页}');
|
|
33361
|
+
}
|
|
33362
|
+
if (innerHTML.includes("条")) {
|
|
33363
|
+
oldValue = oldValue.replace('条', '$L{条}');
|
|
33364
|
+
}
|
|
33365
|
+
let tempHTMLMatch = {
|
|
33366
|
+
oldValue: oldValue
|
|
33367
|
+
};
|
|
33368
|
+
checkResult.result = true;
|
|
33369
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33370
|
+
return checkResult;
|
|
33842
33371
|
}
|
|
33843
|
-
}
|
|
33844
|
-
|
|
33845
|
-
|
|
33846
|
-
|
|
33847
|
-
|
|
33848
|
-
|
|
33849
|
-
|
|
33850
|
-
|
|
33851
|
-
|
|
33852
|
-
|
|
33853
|
-
|
|
33854
|
-
|
|
33855
|
-
* 登录时需要传入验证码(authPicCode)和应用ID(dataappId),
|
|
33856
|
-
* mobileOrWeb参数用于区分是移动端还是网页端登录。
|
|
33857
|
-
*
|
|
33858
|
-
* @returns
|
|
33859
|
-
*/
|
|
33860
|
-
const loginAccount = async (data, appid) => {
|
|
33861
|
-
let questUrl = `/ext/loginAccount`;
|
|
33862
|
-
let password = await viewEncrypt(data.password);
|
|
33863
|
-
let queryData = {
|
|
33864
|
-
param: {
|
|
33865
|
-
account_view: data.account_view,
|
|
33866
|
-
groupid: data.groupid,
|
|
33867
|
-
password: password,
|
|
33868
|
-
account: data.account,
|
|
33869
|
-
appid: appid
|
|
33372
|
+
}
|
|
33373
|
+
// 检查删除确认对话框标题
|
|
33374
|
+
if (classes.contains("ant-popover-message-title")) {
|
|
33375
|
+
let innerHTML = element.innerHTML;
|
|
33376
|
+
if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
|
|
33377
|
+
// console.log("检查smardaten平台删除提问对话框:",innerHTML);
|
|
33378
|
+
let tempHTMLMatch = {
|
|
33379
|
+
oldValue: '$L{操作确认:删除?}'
|
|
33380
|
+
};
|
|
33381
|
+
checkResult.result = true;
|
|
33382
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33383
|
+
return checkResult;
|
|
33870
33384
|
}
|
|
33871
|
-
}
|
|
33872
|
-
|
|
33873
|
-
|
|
33874
|
-
|
|
33875
|
-
|
|
33876
|
-
|
|
33877
|
-
|
|
33878
|
-
|
|
33879
|
-
//登录平台成功
|
|
33880
|
-
if (code == 10110004) {
|
|
33881
|
-
key_code = await viewDecrypt(key_code);
|
|
33882
|
-
key_code = window.appSdk.Encrypt(key_code);
|
|
33883
|
-
queryData.param.password = key_code;
|
|
33884
|
-
resultData = await request.post(`/system/authority/loginAccount4Application?authPicCode=${data.imageCode}&dataappId=${appid}&mobileOrWeb=web`, queryData.param);
|
|
33885
|
-
let response = JSON.parse(resultData.request.response);
|
|
33886
|
-
code = response.code;
|
|
33887
|
-
message = response.message;
|
|
33888
|
-
if (code == 10110004) {
|
|
33889
|
-
let id = login_account_id;
|
|
33890
|
-
// 初始化解析器
|
|
33891
|
-
const parser = new UAParser();
|
|
33892
|
-
// 获取浏览器信息
|
|
33893
|
-
const browser = parser.getBrowser();
|
|
33894
|
-
let timestamp = new Date().getTime();
|
|
33895
|
-
let clientID = browser.name + "_" + browser.version + "_" + timestamp;
|
|
33896
|
-
window.sessionStorage.setItem("iportal_login_user_id", id);
|
|
33897
|
-
window.sessionStorage.setItem("iportal_group_id", data.groupid);
|
|
33898
|
-
window.sessionStorage.setItem("iportal_login_user_key", old_code);
|
|
33899
|
-
window.sessionStorage.setItem("iportal_client_id", clientID);
|
|
33900
|
-
window.sessionStorage.setItem("iportal_app_id", appid);
|
|
33901
|
-
return {
|
|
33902
|
-
code: code,
|
|
33903
|
-
message: i18nText(message)
|
|
33385
|
+
}
|
|
33386
|
+
// 检查删除确认对话框按钮 取消 确认
|
|
33387
|
+
if (classes.contains("ant-btn-sm")) {
|
|
33388
|
+
let innerHTML = element.innerHTML;
|
|
33389
|
+
if (innerHTML.includes("Cancel") || innerHTML.includes("取消")) {
|
|
33390
|
+
// console.log("检查smardaten平台 Tip提问取消删除按钮:",innerHTML);
|
|
33391
|
+
let tempHTMLMatch = {
|
|
33392
|
+
oldValue: '$L{取消}'
|
|
33904
33393
|
};
|
|
33905
|
-
|
|
33906
|
-
|
|
33907
|
-
|
|
33908
|
-
|
|
33394
|
+
checkResult.result = true;
|
|
33395
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33396
|
+
return checkResult;
|
|
33397
|
+
}
|
|
33398
|
+
if (innerHTML.includes("确定") || innerHTML.includes("OK")) {
|
|
33399
|
+
// console.log("检查smardaten平台 Tip提问确认删除按钮:",innerHTML);
|
|
33400
|
+
let tempHTMLMatch = {
|
|
33401
|
+
oldValue: '$L{确定}'
|
|
33909
33402
|
};
|
|
33403
|
+
checkResult.result = true;
|
|
33404
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33405
|
+
return checkResult;
|
|
33910
33406
|
}
|
|
33911
|
-
} else {
|
|
33912
|
-
return {
|
|
33913
|
-
code: code,
|
|
33914
|
-
message: i18nText(message)
|
|
33915
|
-
};
|
|
33916
33407
|
}
|
|
33408
|
+
return checkResult;
|
|
33917
33409
|
};
|
|
33410
|
+
;// ./src/api/i18n/smardaten_i18n/catalog_i18n.js
|
|
33918
33411
|
|
|
33919
|
-
|
|
33920
|
-
|
|
33921
|
-
|
|
33922
|
-
|
|
33923
|
-
const getViewKey = async () => {
|
|
33924
|
-
let queryData = {
|
|
33925
|
-
param: {}
|
|
33926
|
-
};
|
|
33927
|
-
let resultData = await request.post(`/dataservice/rest/orchestration/getViewKey`, queryData);
|
|
33928
|
-
let key = resultData.data.key;
|
|
33929
|
-
return key;
|
|
33930
|
-
};
|
|
33931
|
-
|
|
33932
|
-
/**
|
|
33933
|
-
* 通过账号获取账号数量
|
|
33934
|
-
* @returns
|
|
33935
|
-
*/
|
|
33936
|
-
const getAccountCountByName = async name => {
|
|
33937
|
-
let queryData = {
|
|
33938
|
-
param: {
|
|
33939
|
-
accountName: name
|
|
33940
|
-
}
|
|
33941
|
-
};
|
|
33942
|
-
let resultData = await request.post(`/dataservice/rest/orchestration/getAccountCountByName`, queryData);
|
|
33943
|
-
let count = resultData.data.count;
|
|
33944
|
-
return count;
|
|
33945
|
-
};
|
|
33946
|
-
|
|
33947
|
-
/**
|
|
33948
|
-
* 新建账户注册申请
|
|
33949
|
-
* @returns
|
|
33950
|
-
*/
|
|
33951
|
-
const createRegistApply = async registInfo => {
|
|
33952
|
-
let queryData = {
|
|
33953
|
-
param: {
|
|
33954
|
-
registInfo: registInfo
|
|
33955
|
-
}
|
|
33412
|
+
const catalog_i18n_check = element => {
|
|
33413
|
+
const checkResult = {
|
|
33414
|
+
result: false,
|
|
33415
|
+
innerHTMLMatch: null
|
|
33956
33416
|
};
|
|
33957
|
-
|
|
33958
|
-
|
|
33959
|
-
|
|
33960
|
-
};
|
|
33961
|
-
;// ./src/api/utils.js
|
|
33962
|
-
|
|
33963
|
-
|
|
33964
|
-
|
|
33965
|
-
|
|
33966
|
-
/**
|
|
33967
|
-
* 查询资产
|
|
33968
|
-
* @param id 资产ID
|
|
33969
|
-
*
|
|
33970
|
-
*/
|
|
33971
|
-
const queryAssetById = (id, count = 200) => request.post(`/asset/getAssetData?asset_id=${id}&count=${count}`, {
|
|
33972
|
-
filters: []
|
|
33973
|
-
});
|
|
33974
|
-
|
|
33975
|
-
/**
|
|
33976
|
-
* 获取URL参数值
|
|
33977
|
-
* @param {} eventName
|
|
33978
|
-
* @param {*} actionFun
|
|
33979
|
-
*/
|
|
33980
|
-
const getUrlParamValue = (urlStr, paramName) => {
|
|
33981
|
-
try {
|
|
33982
|
-
const url = new URL(urlStr);
|
|
33983
|
-
const value = url.searchParams.get(paramName);
|
|
33984
|
-
// 如果参数值包含#,则只返回#之前的部分
|
|
33985
|
-
if (value && value.indexOf("#") !== -1) {
|
|
33986
|
-
return value.split("#")[0];
|
|
33987
|
-
}
|
|
33988
|
-
return value;
|
|
33989
|
-
} catch (err) {
|
|
33990
|
-
console.error("URL 格式错误:", err);
|
|
33991
|
-
return "";
|
|
33417
|
+
const classes = element.classList;
|
|
33418
|
+
if (!classes) {
|
|
33419
|
+
return checkResult;
|
|
33992
33420
|
}
|
|
33993
|
-
|
|
33994
|
-
|
|
33995
|
-
|
|
33996
|
-
|
|
33997
|
-
* @param {string} url - 文件的网络 URL
|
|
33998
|
-
* @param {string} [filename] - 自定义文件名(可选,不传则从 URL 提取)
|
|
33999
|
-
* @returns {Promise<File>} - 返回 Promise 解析为 File 对象
|
|
34000
|
-
*/
|
|
34001
|
-
const createFileFromUrl = async (url, filename) => {
|
|
34002
|
-
try {
|
|
34003
|
-
// 1. 发起网络请求获取文件
|
|
34004
|
-
const response = await fetch(url);
|
|
34005
|
-
if (!response.ok) {
|
|
34006
|
-
throw new Error(`网络请求失败: ${response.status} ${response.statusText}`);
|
|
34007
|
-
}
|
|
34008
|
-
|
|
34009
|
-
// 2. 将响应转换为 Blob(保留原始 MIME 类型)
|
|
34010
|
-
const blob = await response.blob();
|
|
34011
|
-
|
|
34012
|
-
// 3. 确定文件名(若未自定义则从 URL 提取)
|
|
34013
|
-
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
34014
|
-
|
|
34015
|
-
// 4. 构造 File 对象(Blob + 文件名 + 类型)
|
|
34016
|
-
return new File([blob], finalFilename, {
|
|
34017
|
-
type: blob.type,
|
|
34018
|
-
// 使用 Blob 的 MIME 类型(如 image/png)
|
|
34019
|
-
lastModified: Date.now() // 可选:设置最后修改时间
|
|
34020
|
-
});
|
|
34021
|
-
} catch (error) {
|
|
34022
|
-
console.error("创建 File 失败:", error);
|
|
34023
|
-
throw error;
|
|
33421
|
+
let innerHTML = element.innerHTML;
|
|
33422
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33423
|
+
if (!oldValue) {
|
|
33424
|
+
oldValue = innerHTML;
|
|
34024
33425
|
}
|
|
34025
|
-
|
|
34026
|
-
|
|
34027
|
-
|
|
34028
|
-
|
|
34029
|
-
|
|
34030
|
-
|
|
34031
|
-
|
|
34032
|
-
|
|
34033
|
-
|
|
34034
|
-
|
|
34035
|
-
|
|
34036
|
-
|
|
34037
|
-
|
|
34038
|
-
|
|
33426
|
+
// 检查目录列表 名称 列
|
|
33427
|
+
if (classes.contains("catalog_name_content")) {
|
|
33428
|
+
// console.log("检查smardaten平台目录列表 元素:",innerHTML);
|
|
33429
|
+
let scriptFunction = (appID, lang) => {
|
|
33430
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33431
|
+
let scriptNodeItem = element.childNodes[i];
|
|
33432
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33433
|
+
let text = element.getAttribute("oldValue");
|
|
33434
|
+
let isTextMatch = checkTextFormat(text);
|
|
33435
|
+
if (!isTextMatch) {
|
|
33436
|
+
element.appendChild(scriptNodeItem);
|
|
33437
|
+
} else {
|
|
33438
|
+
element.removeChild(scriptNodeItem);
|
|
33439
|
+
let key = isTextMatch.key;
|
|
33440
|
+
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
33441
|
+
element.appendChild(textNode);
|
|
33442
|
+
}
|
|
33443
|
+
} else {
|
|
33444
|
+
element.appendChild(scriptNodeItem);
|
|
33445
|
+
}
|
|
33446
|
+
}
|
|
33447
|
+
};
|
|
33448
|
+
let tempHTMLMatch = {
|
|
33449
|
+
oldValue: oldValue,
|
|
33450
|
+
isScriptAction: true,
|
|
33451
|
+
scriptFunction: scriptFunction
|
|
33452
|
+
};
|
|
33453
|
+
checkResult.result = true;
|
|
33454
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33455
|
+
return checkResult;
|
|
33456
|
+
}
|
|
33457
|
+
if (classes.contains("catalog-tree-search")) {
|
|
33458
|
+
let scriptFunction = (appID, lang) => {
|
|
33459
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33460
|
+
let scriptNodeItem = element.childNodes[i];
|
|
33461
|
+
if (scriptNodeItem.tagName === 'INPUT') {
|
|
33462
|
+
let oldValue = scriptNodeItem.getAttribute("oldplaceholderValue");
|
|
33463
|
+
if (!oldValue) {
|
|
33464
|
+
let text = scriptNodeItem.getAttribute("placeholder");
|
|
33465
|
+
if (text) {
|
|
33466
|
+
text = `$L{${text}}`;
|
|
33467
|
+
}
|
|
33468
|
+
scriptNodeItem.setAttribute("placeholder", text);
|
|
33469
|
+
processElement(scriptNodeItem, appID, lang);
|
|
33470
|
+
}
|
|
33471
|
+
}
|
|
33472
|
+
}
|
|
33473
|
+
};
|
|
33474
|
+
let tempHTMLMatch = {
|
|
33475
|
+
oldValue: oldValue,
|
|
33476
|
+
isScriptAction: true,
|
|
33477
|
+
scriptFunction: scriptFunction
|
|
33478
|
+
};
|
|
33479
|
+
checkResult.result = true;
|
|
33480
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33481
|
+
return checkResult;
|
|
34039
33482
|
}
|
|
33483
|
+
return checkResult;
|
|
34040
33484
|
};
|
|
33485
|
+
;// ./src/api/i18n/commom_i18n/common_i18n.js
|
|
34041
33486
|
|
|
34042
|
-
/**
|
|
34043
|
-
* 提取数组中不在另一个数组中的元素
|
|
34044
|
-
* @param {*} oldItems 基础比较数组
|
|
34045
|
-
* @param {*} newItems 被提取检测的数组
|
|
34046
|
-
* @returns
|
|
34047
|
-
*/
|
|
34048
|
-
const extractNewItems = (oldItems, newItems) => {
|
|
34049
|
-
return oldItems.filter(item => !newItems.includes(item));
|
|
34050
|
-
};
|
|
34051
|
-
|
|
34052
|
-
/**
|
|
34053
|
-
* 获取远程文件大小(单位:字节)
|
|
34054
|
-
* @param {string} url - 文件的URL地址
|
|
34055
|
-
* @returns {Promise<number>} 文件大小(字节),失败时返回-1
|
|
34056
|
-
*/
|
|
34057
|
-
const getFileSize = async url => {
|
|
34058
|
-
try {
|
|
34059
|
-
// 发送HEAD请求(不下载文件内容)
|
|
34060
|
-
const response = await fetch(url, {
|
|
34061
|
-
method: "GET",
|
|
34062
|
-
headers: {
|
|
34063
|
-
Range: "bytes=0-0"
|
|
34064
|
-
} // 仅请求第 1 个字节
|
|
34065
|
-
});
|
|
34066
|
-
if (response.status !== 206) throw new Error("不支持 Range 请求");
|
|
34067
|
-
const contentRange = response.headers.get("Content-Range");
|
|
34068
|
-
const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
|
|
34069
|
-
return totalSize ? parseInt(totalSize, 10) : -1;
|
|
34070
|
-
} catch (error) {
|
|
34071
|
-
console.error("获取文件大小失败:", error);
|
|
34072
|
-
return -1; // 返回-1表示失败
|
|
34073
|
-
}
|
|
34074
|
-
};
|
|
34075
|
-
// 获取i18n key
|
|
34076
|
-
const getI18nKey = text => {
|
|
34077
|
-
// 正则表达式匹配 $L{...} 格式
|
|
34078
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
34079
|
-
let match = regex.exec(text);
|
|
34080
|
-
if (!match) return text;
|
|
34081
|
-
let key = match[1];
|
|
34082
|
-
return key;
|
|
34083
|
-
};
|
|
34084
33487
|
|
|
34085
|
-
|
|
34086
|
-
const
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
34090
|
-
|
|
34091
|
-
|
|
33488
|
+
function getOldValueNodeText(innerHTML, index) {
|
|
33489
|
+
const container = document.createElement('div');
|
|
33490
|
+
container.innerHTML = innerHTML;
|
|
33491
|
+
const childNode = container.childNodes[index];
|
|
33492
|
+
return childNode.textContent;
|
|
33493
|
+
}
|
|
33494
|
+
const common_i18n_check = element => {
|
|
33495
|
+
const checkResult = {
|
|
33496
|
+
result: false,
|
|
33497
|
+
innerHTMLMatch: null
|
|
33498
|
+
};
|
|
33499
|
+
// 检查目录列表 名称 列
|
|
33500
|
+
if (element.tagName === 'BUTTON' || element.tagName === 'P') {
|
|
33501
|
+
//TODO:先检查新的是否需要解析,新的不需要有可能是解析后的再次判断,如果有历史解析值,则解析
|
|
33502
|
+
//如果新的需要解析,更新缓存的历史解析值
|
|
33503
|
+
let innerHTML = element.innerHTML;
|
|
33504
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33505
|
+
if (!oldValue) {
|
|
33506
|
+
oldValue = innerHTML;
|
|
34092
33507
|
}
|
|
34093
|
-
|
|
34094
|
-
|
|
34095
|
-
|
|
34096
|
-
|
|
34097
|
-
|
|
34098
|
-
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
|
|
34103
|
-
|
|
34104
|
-
|
|
34105
|
-
|
|
34106
|
-
|
|
33508
|
+
let firstCheck = checkTextFormat(oldValue);
|
|
33509
|
+
let firstCheckResult = firstCheck ? true : false;
|
|
33510
|
+
// console.log("检查 button 元素:",innerHTML);
|
|
33511
|
+
// console.log("检查结果:",firstCheckResult);
|
|
33512
|
+
let scriptFunction = (appID, lang) => {
|
|
33513
|
+
let elementsArray = [];
|
|
33514
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33515
|
+
let scriptNodeItem = element.childNodes[i];
|
|
33516
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33517
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33518
|
+
// console.log("执行 button 文本节点翻译:", text);
|
|
33519
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33520
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33521
|
+
let isTextMatch = checkTextFormat(oldValue);
|
|
33522
|
+
if (!isTextMatch) {
|
|
33523
|
+
elementsArray.push(scriptNodeItem);
|
|
33524
|
+
} else {
|
|
33525
|
+
// console.log("执行 button 脚本节点翻译isTextMatch:", isTextMatch?true:false);
|
|
33526
|
+
// element.removeChild(scriptNodeItem);
|
|
33527
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
33528
|
+
let childNodeText = getOldValueNodeText(oldValue, i);
|
|
33529
|
+
let newValue = childNodeText;
|
|
33530
|
+
let match;
|
|
33531
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
33532
|
+
const fullMatch = match[0];
|
|
33533
|
+
const placeholderKey = match[1];
|
|
33534
|
+
const translation = i18n(placeholderKey, appID, lang);
|
|
33535
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
33536
|
+
}
|
|
33537
|
+
let textNode = document.createTextNode(newValue);
|
|
33538
|
+
elementsArray.push(textNode);
|
|
33539
|
+
}
|
|
33540
|
+
} else {
|
|
33541
|
+
elementsArray.push(scriptNodeItem);
|
|
33542
|
+
}
|
|
33543
|
+
}
|
|
33544
|
+
element.innerHTML = '';
|
|
33545
|
+
elementsArray.forEach(el => {
|
|
33546
|
+
element.appendChild(el);
|
|
33547
|
+
});
|
|
33548
|
+
};
|
|
33549
|
+
let tempHTMLMatch = {
|
|
33550
|
+
oldValue: oldValue,
|
|
33551
|
+
isScriptAction: true,
|
|
33552
|
+
scriptFunction: scriptFunction
|
|
33553
|
+
};
|
|
33554
|
+
checkResult.result = firstCheckResult;
|
|
33555
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33556
|
+
return checkResult;
|
|
34107
33557
|
}
|
|
33558
|
+
return checkResult;
|
|
34108
33559
|
};
|
|
33560
|
+
;// ./src/api/i18n/commom_i18n/attribute_i18n.js
|
|
34109
33561
|
|
|
34110
|
-
|
|
34111
|
-
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
|
|
34115
|
-
|
|
34116
|
-
|
|
34117
|
-
let resultData = await request.post(serverIP);
|
|
34118
|
-
let ipAddress = resultData?.data?.clientIp;
|
|
34119
|
-
return ipAddress;
|
|
34120
|
-
};
|
|
34121
|
-
|
|
34122
|
-
/**
|
|
34123
|
-
* 通用服务方法调用
|
|
34124
|
-
* @returns
|
|
34125
|
-
*/
|
|
34126
|
-
const doRestPost = async (url, param) => {
|
|
34127
|
-
let resultData = await request.post(url, param);
|
|
34128
|
-
return resultData;
|
|
34129
|
-
};
|
|
34130
|
-
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
|
|
34131
|
-
var es_iterator_some = __webpack_require__(3579);
|
|
34132
|
-
;// ./src/api/iframe.js
|
|
34133
|
-
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
const addWindowTrustedOrigin = origin => {
|
|
34137
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
34138
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
34139
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS.includes(origin)) {
|
|
34140
|
-
SDATA_WINDOW_TRUSTED_ORIGINS.push(origin);
|
|
34141
|
-
}
|
|
34142
|
-
};
|
|
34143
|
-
const removeWindowTrustedOrigin = origin => {
|
|
34144
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
34145
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
34146
|
-
let index = SDATA_WINDOW_TRUSTED_ORIGINS.indexOf(origin); // 查找元素在数组中的索引
|
|
34147
|
-
if (index > -1) {
|
|
34148
|
-
SDATA_WINDOW_TRUSTED_ORIGINS.splice(index, 1); // 删除元素
|
|
33562
|
+
const attribute_i18n_check = element => {
|
|
33563
|
+
const checkResult = {
|
|
33564
|
+
result: false,
|
|
33565
|
+
innerHTMLMatch: null
|
|
33566
|
+
};
|
|
33567
|
+
if (!element) {
|
|
33568
|
+
return checkResult;
|
|
34149
33569
|
}
|
|
34150
|
-
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
|
|
34154
|
-
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
|
|
34158
|
-
|
|
34159
|
-
delete window.sdataEventActions[eventKey];
|
|
34160
|
-
};
|
|
34161
|
-
const initFrameWindowListener = () => {
|
|
34162
|
-
if (window.isFrameWindowInited) return;
|
|
34163
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
34164
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
34165
|
-
let sdataEventActions = window.sdataEventActions;
|
|
34166
|
-
if (!sdataEventActions) window.sdataEventActions = {};
|
|
34167
|
-
// 监听主页面的消息
|
|
34168
|
-
window.addEventListener("message", async event => {
|
|
34169
|
-
// 步骤1:验证来源是否在白名单中
|
|
34170
|
-
const isTrusted = window.SDATA_WINDOW_TRUSTED_ORIGINS.some(origin => event.origin === origin || new RegExp(origin).test(event.origin));
|
|
34171
|
-
if (!isTrusted) {
|
|
34172
|
-
console.log("拒绝非可信源消息:", event.origin);
|
|
34173
|
-
return; // 直接终止处理
|
|
33570
|
+
const checkAttributes = ["placeholder", "title"];
|
|
33571
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
33572
|
+
let attr = checkAttributes[i];
|
|
33573
|
+
let attrValue = element.getAttribute(attr) || element[attr];
|
|
33574
|
+
const attrMatch = attrValue ? checkTextFormat(attrValue) : null;
|
|
33575
|
+
if (attrMatch) {
|
|
33576
|
+
// console.log("检查元素属性 i18n 元素:", attr, attrValue);
|
|
33577
|
+
element.setAttribute(`old${attr}Value`, attrValue);
|
|
33578
|
+
checkResult.result = true;
|
|
34174
33579
|
}
|
|
34175
|
-
|
|
34176
|
-
|
|
34177
|
-
let
|
|
34178
|
-
|
|
34179
|
-
|
|
34180
|
-
|
|
34181
|
-
|
|
34182
|
-
|
|
34183
|
-
|
|
34184
|
-
|
|
34185
|
-
|
|
34186
|
-
|
|
34187
|
-
|
|
34188
|
-
|
|
34189
|
-
|
|
34190
|
-
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
responseData.data = resultData;
|
|
33580
|
+
}
|
|
33581
|
+
let scriptFunction = (appID, lang) => {
|
|
33582
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
33583
|
+
let attr = checkAttributes[i];
|
|
33584
|
+
const oldAttrValue = element.getAttribute(`old${attr}Value`);
|
|
33585
|
+
if (oldAttrValue) {
|
|
33586
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33587
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33588
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
33589
|
+
let newAttrValue = oldAttrValue;
|
|
33590
|
+
let match;
|
|
33591
|
+
while ((match = regex.exec(oldAttrValue)) !== null) {
|
|
33592
|
+
const fullMatch = match[0];
|
|
33593
|
+
const attrKey = match[1];
|
|
33594
|
+
const translation = i18n(attrKey, appID, lang);
|
|
33595
|
+
newAttrValue = newAttrValue.replace(fullMatch, translation);
|
|
33596
|
+
}
|
|
33597
|
+
// 更新元素的placeholder属性
|
|
33598
|
+
element.setAttribute(attr, newAttrValue);
|
|
34195
33599
|
}
|
|
34196
|
-
event.source.postMessage(responseData, eventSourceKey);
|
|
34197
33600
|
}
|
|
34198
|
-
});
|
|
34199
|
-
window.isFrameWindowInited = true;
|
|
34200
|
-
};
|
|
34201
|
-
const sendWindowMessage = async (targetWindow, originKey, eventKey, data, callback) => {
|
|
34202
|
-
let timestamp = new Date().getTime();
|
|
34203
|
-
let randomNum = Math.floor(Math.random() * 10000) + 1;
|
|
34204
|
-
let eventOperateKey = `${eventKey}_${timestamp}_${randomNum}`;
|
|
34205
|
-
addEventAction(eventOperateKey, callback);
|
|
34206
|
-
let postData = {
|
|
34207
|
-
eventOperateKey: eventOperateKey,
|
|
34208
|
-
eventKey: eventKey,
|
|
34209
|
-
data: data
|
|
34210
33601
|
};
|
|
34211
|
-
|
|
33602
|
+
checkResult.scriptFunction = scriptFunction;
|
|
33603
|
+
return checkResult;
|
|
34212
33604
|
};
|
|
34213
|
-
;// ./src/api/
|
|
33605
|
+
;// ./src/api/i18n/smardaten_i18n/calendar_i18n.js
|
|
34214
33606
|
|
|
34215
33607
|
|
|
33608
|
+
function convertToChineseWeekday(englishInput) {
|
|
33609
|
+
// 清理输入:去除首尾空格并转为小写
|
|
33610
|
+
const input = englishInput.trim().toLowerCase();
|
|
34216
33611
|
|
|
34217
|
-
|
|
34218
|
-
|
|
34219
|
-
|
|
34220
|
-
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34227
|
-
|
|
34228
|
-
|
|
34229
|
-
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
33612
|
+
// 定义星期映射关系
|
|
33613
|
+
const weekdayMap = {
|
|
33614
|
+
'mon': '周一',
|
|
33615
|
+
'monday': '周一',
|
|
33616
|
+
'mondays': '周一',
|
|
33617
|
+
'tue': '周二',
|
|
33618
|
+
'tues': '周二',
|
|
33619
|
+
'tuesday': '周二',
|
|
33620
|
+
'tuesdays': '周二',
|
|
33621
|
+
'wed': '周三',
|
|
33622
|
+
'wednesday': '周三',
|
|
33623
|
+
'wednesdays': '周三',
|
|
33624
|
+
'thu': '周四',
|
|
33625
|
+
'thur': '周四',
|
|
33626
|
+
'thurs': '周四',
|
|
33627
|
+
'thursday': '周四',
|
|
33628
|
+
'thursdays': '周四',
|
|
33629
|
+
'fri': '周五',
|
|
33630
|
+
'friday': '周五',
|
|
33631
|
+
'fridays': '周五',
|
|
33632
|
+
'sat': '周六',
|
|
33633
|
+
'saturday': '周六',
|
|
33634
|
+
'saturdays': '周六',
|
|
33635
|
+
'sun': '周日',
|
|
33636
|
+
'sunday': '周日',
|
|
33637
|
+
'sundays': '周日'
|
|
33638
|
+
};
|
|
33639
|
+
|
|
33640
|
+
// 使用正则表达式匹配所有可能的星期格式
|
|
33641
|
+
const pattern = /^(mon(day)?s?\.?|tue(sday)?s?\.?|wed(nesday)?s?\.?|thu(r(sday)?)?s?\.?|fri(day)?s?\.?|sat(urday)?s?\.?|sun(day)?s?\.?)$/i;
|
|
33642
|
+
|
|
33643
|
+
// 测试输入是否匹配星期格式
|
|
33644
|
+
if (!pattern.test(input)) {
|
|
33645
|
+
return '未知日期';
|
|
34233
33646
|
}
|
|
34234
|
-
|
|
34235
|
-
|
|
34236
|
-
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
|
|
34240
|
-
|
|
34241
|
-
|
|
34242
|
-
|
|
34243
|
-
|
|
34244
|
-
|
|
34245
|
-
|
|
34246
|
-
|
|
34247
|
-
|
|
34248
|
-
|
|
34249
|
-
|
|
34250
|
-
|
|
34251
|
-
|
|
34252
|
-
|
|
34253
|
-
|
|
34254
|
-
|
|
34255
|
-
});
|
|
34256
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_users_by_group_id`), async data => {
|
|
34257
|
-
return await this.handler.getAllUserInfosByGroupID(data);
|
|
34258
|
-
});
|
|
34259
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_dpts_by_group_id`), async data => {
|
|
34260
|
-
return await this.handler.getChildrenOfficeInfosByID(data);
|
|
34261
|
-
});
|
|
34262
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_project_dpts_by_user_group_id`), async data => {
|
|
34263
|
-
return await this.handler.getPojectDptsByUserAndGroupID(data);
|
|
34264
|
-
});
|
|
34265
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_ai_robot_infos`), async data => {
|
|
34266
|
-
let groupID = data.groupID;
|
|
34267
|
-
let userID = data.userID;
|
|
34268
|
-
if (this.userID == userID && this.groupID == groupID) {
|
|
34269
|
-
return this.getAIRobotInfos();
|
|
34270
|
-
}
|
|
34271
|
-
return [];
|
|
34272
|
-
});
|
|
34273
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_test_user_sig`), async data => {
|
|
34274
|
-
let sdkAppID = data.SDKAppID;
|
|
34275
|
-
let userID = data.userID;
|
|
34276
|
-
let sigIDObject = await this.handler.genTestUserSig({
|
|
34277
|
-
SDKAppID: sdkAppID,
|
|
34278
|
-
userID: userID
|
|
34279
|
-
});
|
|
34280
|
-
let sigID = sigIDObject.userSig;
|
|
34281
|
-
return sigID;
|
|
34282
|
-
});
|
|
34283
|
-
this.handler.addChatListener(this.makeKey(`sdata_send_message_to_chat_server`), async (data, event) => {
|
|
34284
|
-
let message = data.message;
|
|
34285
|
-
let robotID = message.from;
|
|
34286
|
-
let result = await this.sendMessageToChatServer(robotID, message);
|
|
34287
|
-
return result;
|
|
34288
|
-
});
|
|
34289
|
-
this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
|
|
34290
|
-
return this.handler.closeWindow();
|
|
34291
|
-
});
|
|
34292
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
|
|
34293
|
-
return this.handler.getPortalDocmentInfo(data);
|
|
34294
|
-
});
|
|
34295
|
-
this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
|
|
34296
|
-
return this.handler.onAIAgentEvent(data, event);
|
|
34297
|
-
});
|
|
34298
|
-
this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
|
|
34299
|
-
console.log("recive chat regist event data:", data);
|
|
34300
|
-
this.appSKID = data.appid;
|
|
34301
|
-
this.imType = data.im_type;
|
|
34302
|
-
await this.initChatAIs();
|
|
34303
|
-
let charParams = {
|
|
34304
|
-
type: this.getChatTypeKey(this.chatType),
|
|
34305
|
-
singleChatID: this.singleChatID,
|
|
34306
|
-
customParams: this.customParams
|
|
34307
|
-
};
|
|
34308
|
-
this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
|
|
34309
|
-
if (result) {
|
|
34310
|
-
console.log("chat init finished:", result);
|
|
34311
|
-
this.handler.onChatInitFinished();
|
|
34312
|
-
}
|
|
34313
|
-
});
|
|
33647
|
+
|
|
33648
|
+
// 提取基础名称(去除复数形式和句点)
|
|
33649
|
+
const baseName = input.replace(/\./g, '') // 移除所有句点
|
|
33650
|
+
.replace(/s$/, ''); // 移除结尾的's'(复数形式)
|
|
33651
|
+
|
|
33652
|
+
// 特殊处理周四的多种缩写形式
|
|
33653
|
+
const normalized = baseName.startsWith('thu') ? 'thu' : baseName.slice(0, 3);
|
|
33654
|
+
|
|
33655
|
+
// 映射到中文名称
|
|
33656
|
+
return weekdayMap[normalized] || weekdayMap[baseName] || '未知日期';
|
|
33657
|
+
}
|
|
33658
|
+
function extractYearMonth(str) {
|
|
33659
|
+
const regex = /(\d{4})年(0?[1-9]|1[0-2])月/g;
|
|
33660
|
+
const matches = str.matchAll(regex);
|
|
33661
|
+
const result = [];
|
|
33662
|
+
for (const match of matches) {
|
|
33663
|
+
const year = parseInt(match[1], 10);
|
|
33664
|
+
const month = parseInt(match[2], 10);
|
|
33665
|
+
result.push({
|
|
33666
|
+
year,
|
|
33667
|
+
month
|
|
34314
33668
|
});
|
|
34315
33669
|
}
|
|
34316
|
-
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
|
|
34322
|
-
|
|
34323
|
-
|
|
34324
|
-
|
|
34325
|
-
|
|
34326
|
-
|
|
34327
|
-
|
|
34328
|
-
|
|
34329
|
-
|
|
33670
|
+
return result;
|
|
33671
|
+
}
|
|
33672
|
+
function extractDayNumbers(text) {
|
|
33673
|
+
// 匹配两种情况:
|
|
33674
|
+
// 1. "数字+日"格式(如"5日"、"12日")
|
|
33675
|
+
// 2. 独立的1-31数字(前后有边界)
|
|
33676
|
+
const regex = /(?:(\b(0?[1-9]|[12]\d|3[01])\b)(?=日))|(\b(0?[1-9]|[12]\d|3[01])\b)/g;
|
|
33677
|
+
const results = [];
|
|
33678
|
+
let match;
|
|
33679
|
+
while ((match = regex.exec(text)) !== null) {
|
|
33680
|
+
// match[2] 对应第一种情况(带"日"字的数字)
|
|
33681
|
+
// match[4] 对应第二种情况(独立数字)
|
|
33682
|
+
const numStr = match[2] || match[4];
|
|
33683
|
+
if (numStr) {
|
|
33684
|
+
// 转换为整数并验证范围
|
|
33685
|
+
const day = parseInt(numStr, 10);
|
|
33686
|
+
if (day >= 1 && day <= 31) {
|
|
33687
|
+
results.push(day);
|
|
33688
|
+
}
|
|
34330
33689
|
}
|
|
34331
33690
|
}
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
|
|
34337
|
-
|
|
34338
|
-
|
|
34339
|
-
|
|
34340
|
-
|
|
34341
|
-
|
|
34342
|
-
|
|
34343
|
-
|
|
34344
|
-
|
|
34345
|
-
|
|
34346
|
-
|
|
34347
|
-
|
|
34348
|
-
|
|
34349
|
-
|
|
33691
|
+
return results;
|
|
33692
|
+
}
|
|
33693
|
+
function extractNumbersFromScenarios(text) {
|
|
33694
|
+
// 定义两种场景的正则表达式
|
|
33695
|
+
const patterns = [
|
|
33696
|
+
// 场景1: "Other X pieces of data"
|
|
33697
|
+
/Other\s+(\d+)\s+pieces of data/gi,
|
|
33698
|
+
// 场景2: "其他 X 条记录"
|
|
33699
|
+
/其他\s+(\d+)\s+条记录/g];
|
|
33700
|
+
const results = [];
|
|
33701
|
+
|
|
33702
|
+
// 遍历所有模式进行匹配
|
|
33703
|
+
patterns.forEach(pattern => {
|
|
33704
|
+
let match;
|
|
33705
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
33706
|
+
// 提取捕获组中的数字
|
|
33707
|
+
const number = parseInt(match[1], 10);
|
|
33708
|
+
results.push({
|
|
33709
|
+
scenario: match[0],
|
|
33710
|
+
// 完整匹配的字符串
|
|
33711
|
+
number: number,
|
|
33712
|
+
// 提取的数字
|
|
33713
|
+
type: pattern.source.includes('Other') ? 'English' : 'Chinese'
|
|
34350
33714
|
});
|
|
34351
|
-
window.imClient.on(TencentCloudChat.EVENT.SDK_READY, this.onChatAIReady.bind(this));
|
|
34352
|
-
window.imClient.charAIs = {};
|
|
34353
|
-
this.chatAIClient = window.imClient;
|
|
34354
|
-
}
|
|
34355
|
-
if (!this.chatAIClient.charAIs) {
|
|
34356
|
-
this.chatAIClient.charAIs = {};
|
|
34357
33715
|
}
|
|
34358
|
-
|
|
34359
|
-
|
|
34360
|
-
|
|
34361
|
-
|
|
34362
|
-
|
|
34363
|
-
|
|
34364
|
-
|
|
34365
|
-
|
|
34366
|
-
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
|
|
34370
|
-
|
|
34371
|
-
|
|
34372
|
-
|
|
33716
|
+
});
|
|
33717
|
+
return results;
|
|
33718
|
+
}
|
|
33719
|
+
const calendar_i18n_check = element => {
|
|
33720
|
+
const checkResult = {
|
|
33721
|
+
result: false,
|
|
33722
|
+
innerHTMLMatch: null
|
|
33723
|
+
};
|
|
33724
|
+
const classes = element.classList;
|
|
33725
|
+
if (!classes) {
|
|
33726
|
+
return checkResult;
|
|
33727
|
+
}
|
|
33728
|
+
// 检查日历标题
|
|
33729
|
+
if (classes.contains("fc-toolbar-title")) {
|
|
33730
|
+
let scriptFunction = (appID, lang) => {
|
|
33731
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33732
|
+
let yearMonthList = extractYearMonth(oldValue);
|
|
33733
|
+
if (yearMonthList.length > 0) {
|
|
33734
|
+
let yearMonth = yearMonthList[0];
|
|
33735
|
+
let year = yearMonth.year;
|
|
33736
|
+
let month = yearMonth.month;
|
|
33737
|
+
let newInnerHTML = `${year}/${month}`;
|
|
33738
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33739
|
+
if (lang === "zh-CN") {
|
|
33740
|
+
newInnerHTML = `${year}年${month}月`;
|
|
34373
33741
|
}
|
|
34374
|
-
|
|
33742
|
+
element.innerHTML = newInnerHTML;
|
|
33743
|
+
}
|
|
33744
|
+
};
|
|
33745
|
+
let innerHTML = element.innerHTML;
|
|
33746
|
+
let testRule = /^\d{4}年(0?[1-9]|1[0-2])月$/;
|
|
33747
|
+
if (testRule.test(innerHTML)) {
|
|
33748
|
+
// console.log("检查smardaten平台日历标题 元素:",innerHTML);
|
|
33749
|
+
let tempHTMLMatch = {
|
|
33750
|
+
oldValue: innerHTML,
|
|
33751
|
+
isScriptAction: true,
|
|
33752
|
+
scriptFunction: scriptFunction
|
|
33753
|
+
};
|
|
33754
|
+
checkResult.result = true;
|
|
33755
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33756
|
+
return checkResult;
|
|
34375
33757
|
}
|
|
34376
33758
|
}
|
|
34377
|
-
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
await this.chatAIClient.login({
|
|
34385
|
-
userID: robotKey,
|
|
34386
|
-
userSig: userSig
|
|
34387
|
-
});
|
|
34388
|
-
await this.chatAIClient.logout();
|
|
34389
|
-
let data = {
|
|
34390
|
-
userID: robotKey,
|
|
34391
|
-
userSig: userSig,
|
|
34392
|
-
im_type: this.imType,
|
|
34393
|
-
group_id: this.groupID
|
|
33759
|
+
// 检查日历今天按钮
|
|
33760
|
+
if (classes.contains("fc-today-button")) {
|
|
33761
|
+
let innerHTML = element.innerHTML;
|
|
33762
|
+
if (innerHTML.includes("今天") || innerHTML.includes("today")) {
|
|
33763
|
+
// console.log("检查smardaten平台日历 今天 元素:",innerHTML);
|
|
33764
|
+
let tempHTMLMatch = {
|
|
33765
|
+
oldValue: '$L{今天}'
|
|
34394
33766
|
};
|
|
34395
|
-
|
|
33767
|
+
checkResult.result = true;
|
|
33768
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33769
|
+
return checkResult;
|
|
34396
33770
|
}
|
|
34397
|
-
return userSig;
|
|
34398
33771
|
}
|
|
34399
|
-
|
|
34400
|
-
|
|
34401
|
-
|
|
34402
|
-
|
|
34403
|
-
|
|
34404
|
-
let
|
|
34405
|
-
if (
|
|
34406
|
-
|
|
34407
|
-
|
|
34408
|
-
|
|
34409
|
-
|
|
34410
|
-
|
|
34411
|
-
|
|
33772
|
+
// 检查日历标题
|
|
33773
|
+
if (classes.contains("fullCalendar_title_value")) {
|
|
33774
|
+
let innerHTML = element.innerHTML;
|
|
33775
|
+
const regex = /周[一二三四五六日]/;
|
|
33776
|
+
const regex_en = /^(mon(day)?s?\.?|tue(sday)?s?\.?|wed(nesday)?s?\.?|thu(r(sday)?)?s?\.?|fri(day)?s?\.?|sat(urday)?s?\.?|sun(day)?s?\.?)$/i;
|
|
33777
|
+
let match = innerHTML.match(regex);
|
|
33778
|
+
if (match) {
|
|
33779
|
+
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33780
|
+
let day = match[0];
|
|
33781
|
+
let tempHTMLMatch = {
|
|
33782
|
+
oldValue: `$L{${day}}`
|
|
33783
|
+
};
|
|
33784
|
+
checkResult.result = true;
|
|
33785
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33786
|
+
return checkResult;
|
|
33787
|
+
}
|
|
33788
|
+
match = innerHTML.match(regex_en);
|
|
33789
|
+
if (match) {
|
|
33790
|
+
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33791
|
+
let day = match[0];
|
|
33792
|
+
let tempHTMLMatch = {
|
|
33793
|
+
oldValue: `$L{${convertToChineseWeekday(day)}}`
|
|
33794
|
+
};
|
|
33795
|
+
checkResult.result = true;
|
|
33796
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33797
|
+
return checkResult;
|
|
34412
33798
|
}
|
|
34413
|
-
return userSig;
|
|
34414
33799
|
}
|
|
34415
|
-
|
|
34416
|
-
|
|
34417
|
-
let
|
|
34418
|
-
|
|
34419
|
-
|
|
34420
|
-
|
|
34421
|
-
|
|
34422
|
-
|
|
34423
|
-
|
|
34424
|
-
|
|
34425
|
-
|
|
34426
|
-
|
|
34427
|
-
|
|
34428
|
-
this.sendMessageToChatServer(robotID, message);
|
|
34429
|
-
});
|
|
33800
|
+
//日期单元格
|
|
33801
|
+
if (classes.contains("fc-daygrid-day-number")) {
|
|
33802
|
+
let scriptFunction = (appID, lang) => {
|
|
33803
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33804
|
+
let result = extractDayNumbers(oldValue);
|
|
33805
|
+
if (result && result.length > 0) {
|
|
33806
|
+
let day = result[0];
|
|
33807
|
+
let newInnerHTML = `${day}`;
|
|
33808
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33809
|
+
if (lang === "zh-CN") {
|
|
33810
|
+
newInnerHTML = `${day}日`;
|
|
33811
|
+
}
|
|
33812
|
+
element.innerHTML = newInnerHTML;
|
|
34430
33813
|
}
|
|
33814
|
+
};
|
|
33815
|
+
let innerHTML = element.innerHTML;
|
|
33816
|
+
let match = extractDayNumbers(innerHTML);
|
|
33817
|
+
if (match.length > 0) {
|
|
33818
|
+
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33819
|
+
let tempHTMLMatch = {
|
|
33820
|
+
oldValue: innerHTML,
|
|
33821
|
+
isScriptAction: true,
|
|
33822
|
+
scriptFunction: scriptFunction
|
|
33823
|
+
};
|
|
33824
|
+
checkResult.result = true;
|
|
33825
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33826
|
+
return checkResult;
|
|
34431
33827
|
}
|
|
34432
33828
|
}
|
|
34433
|
-
|
|
34434
|
-
|
|
34435
|
-
|
|
34436
|
-
|
|
33829
|
+
// 日历更多按钮
|
|
33830
|
+
if (classes.contains("fc-daygrid-more-link")) {
|
|
33831
|
+
let scriptFunction = (appID, lang) => {
|
|
33832
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33833
|
+
let result = extractNumbersFromScenarios(oldValue);
|
|
33834
|
+
if (result && result.length > 0) {
|
|
33835
|
+
let day = result[0]["number"];
|
|
33836
|
+
let newInnerHTML = "另外${X}条数据";
|
|
33837
|
+
newInnerHTML = i18n(newInnerHTML, appID, lang);
|
|
33838
|
+
newInnerHTML = newInnerHTML.replace("${X}", day);
|
|
33839
|
+
element.innerHTML = newInnerHTML;
|
|
33840
|
+
}
|
|
33841
|
+
};
|
|
33842
|
+
let innerHTML = element.innerHTML;
|
|
33843
|
+
let match = extractNumbersFromScenarios(innerHTML);
|
|
33844
|
+
if (match.length > 0) {
|
|
33845
|
+
// console.log("检查smardaten平台日历 更多 元素:",innerHTML);
|
|
33846
|
+
let tempHTMLMatch = {
|
|
33847
|
+
oldValue: innerHTML,
|
|
33848
|
+
isScriptAction: true,
|
|
33849
|
+
scriptFunction: scriptFunction
|
|
33850
|
+
};
|
|
33851
|
+
checkResult.result = true;
|
|
33852
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33853
|
+
return checkResult;
|
|
34437
33854
|
}
|
|
34438
|
-
return resultRobots;
|
|
34439
33855
|
}
|
|
34440
|
-
|
|
34441
|
-
|
|
34442
|
-
|
|
34443
|
-
|
|
34444
|
-
|
|
34445
|
-
|
|
34446
|
-
|
|
34447
|
-
|
|
34448
|
-
|
|
34449
|
-
|
|
34450
|
-
|
|
34451
|
-
|
|
34452
|
-
|
|
34453
|
-
|
|
34454
|
-
|
|
34455
|
-
|
|
34456
|
-
|
|
34457
|
-
});
|
|
34458
|
-
} catch (err) {
|
|
34459
|
-
console.log(`[AI chat]${robotInfo.name}登录失败`, err);
|
|
34460
|
-
let code = err.code;
|
|
34461
|
-
if (code == 70001) {
|
|
34462
|
-
console.log(`[AI chat]${robotInfo.name}UserSig过期,重新生成userSig`);
|
|
34463
|
-
let newUserSig = await this.generateUserSigAndUpdate(robotID);
|
|
34464
|
-
try {
|
|
34465
|
-
await this.chatAIClient.login({
|
|
34466
|
-
userID: robotID,
|
|
34467
|
-
userSig: newUserSig
|
|
34468
|
-
});
|
|
34469
|
-
this.sendMessageToChatServer(robotID, messageOption);
|
|
34470
|
-
return;
|
|
34471
|
-
} catch (err) {
|
|
34472
|
-
console.log(`[AI chat]${robotInfo.name}重新登录失败`, err);
|
|
34473
|
-
return;
|
|
33856
|
+
// 日历弹窗标题
|
|
33857
|
+
if (classes.contains("fc-popover-title")) {
|
|
33858
|
+
// 正则表达式匹配中文日期格式
|
|
33859
|
+
const regex = /(\d{4})年(\d{1,2})月(\d{1,2})日/g;
|
|
33860
|
+
let scriptFunction = (appID, lang) => {
|
|
33861
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33862
|
+
let match = oldValue.match(regex);
|
|
33863
|
+
if (match) {
|
|
33864
|
+
// 替换函数
|
|
33865
|
+
const convertedText = oldValue.replace(regex, function (match, year, month, day) {
|
|
33866
|
+
// 格式化月份和日期为两位数
|
|
33867
|
+
const formattedMonth = month.padStart(2, '0');
|
|
33868
|
+
const formattedDay = day.padStart(2, '0');
|
|
33869
|
+
let result = `${year}/${formattedMonth}/${formattedDay}`;
|
|
33870
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33871
|
+
if (lang === "zh-CN") {
|
|
33872
|
+
result = `${year}年${formattedMonth}月${formattedDay}日`;
|
|
34474
33873
|
}
|
|
34475
|
-
|
|
33874
|
+
// 返回新格式的日期
|
|
33875
|
+
return result;
|
|
33876
|
+
});
|
|
33877
|
+
element.innerHTML = convertedText;
|
|
34476
33878
|
}
|
|
34477
|
-
}
|
|
34478
|
-
|
|
34479
|
-
|
|
34480
|
-
|
|
34481
|
-
|
|
34482
|
-
|
|
34483
|
-
|
|
34484
|
-
|
|
34485
|
-
|
|
34486
|
-
|
|
34487
|
-
|
|
34488
|
-
|
|
34489
|
-
|
|
33879
|
+
};
|
|
33880
|
+
let innerHTML = element.innerHTML;
|
|
33881
|
+
let match = innerHTML.match(regex);
|
|
33882
|
+
if (match && match.length > 0) {
|
|
33883
|
+
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33884
|
+
let tempHTMLMatch = {
|
|
33885
|
+
oldValue: innerHTML,
|
|
33886
|
+
isScriptAction: true,
|
|
33887
|
+
scriptFunction: scriptFunction
|
|
33888
|
+
};
|
|
33889
|
+
checkResult.result = true;
|
|
33890
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33891
|
+
return checkResult;
|
|
34490
33892
|
}
|
|
34491
33893
|
}
|
|
34492
|
-
|
|
34493
|
-
|
|
34494
|
-
|
|
34495
|
-
|
|
34496
|
-
|
|
34497
|
-
|
|
34498
|
-
|
|
34499
|
-
|
|
34500
|
-
|
|
34501
|
-
|
|
34502
|
-
|
|
34503
|
-
|
|
34504
|
-
|
|
34505
|
-
|
|
34506
|
-
|
|
34507
|
-
|
|
34508
|
-
|
|
33894
|
+
return checkResult;
|
|
33895
|
+
};
|
|
33896
|
+
;// ./src/api/i18n/i18n.js
|
|
33897
|
+
|
|
33898
|
+
|
|
33899
|
+
|
|
33900
|
+
|
|
33901
|
+
|
|
33902
|
+
|
|
33903
|
+
|
|
33904
|
+
|
|
33905
|
+
|
|
33906
|
+
|
|
33907
|
+
|
|
33908
|
+
const getLanguages = async appID => {
|
|
33909
|
+
let queryData = {
|
|
33910
|
+
param: {
|
|
33911
|
+
appID: appID
|
|
34509
33912
|
}
|
|
34510
|
-
|
|
34511
|
-
|
|
34512
|
-
|
|
34513
|
-
|
|
34514
|
-
|
|
34515
|
-
|
|
34516
|
-
|
|
34517
|
-
|
|
33913
|
+
};
|
|
33914
|
+
let response = await request.post(`/dataservice/rest/orchestration/getAppLanguages`, queryData);
|
|
33915
|
+
let resultDatas = response.data.resultDatas || [];
|
|
33916
|
+
return resultDatas;
|
|
33917
|
+
};
|
|
33918
|
+
const i18n = (key, appID, localID) => {
|
|
33919
|
+
let result = window.customI18nObject?.get(`${appID}-${key}-${localID}`) || key;
|
|
33920
|
+
return result;
|
|
33921
|
+
};
|
|
33922
|
+
const loadi18nTexts = async appID => {
|
|
33923
|
+
let queryData = {
|
|
33924
|
+
param: {
|
|
33925
|
+
appID: appID
|
|
33926
|
+
}
|
|
33927
|
+
};
|
|
33928
|
+
let response = await request.post(`/dataservice/rest/orchestration/getAllTexts`, queryData);
|
|
33929
|
+
let resultDatas = response.data.resultDatas || [];
|
|
33930
|
+
window.customI18nObject = new Map();
|
|
33931
|
+
for (let item of resultDatas) {
|
|
33932
|
+
window.customI18nObject.set(`${appID}-${item.key}-${item.lang}`, item.value);
|
|
33933
|
+
}
|
|
33934
|
+
};
|
|
33935
|
+
|
|
33936
|
+
/**
|
|
33937
|
+
* 检查元素是否有子DOM元素
|
|
33938
|
+
* @param {HTMLElement} element - 要检查的DOM元素
|
|
33939
|
+
* @returns {boolean} - 是否有子元素
|
|
33940
|
+
*/
|
|
33941
|
+
function hasChildElements(element) {
|
|
33942
|
+
return element && element.children?.length > 0;
|
|
33943
|
+
}
|
|
33944
|
+
|
|
33945
|
+
/**
|
|
33946
|
+
* 检查文本是否匹配$L{...}格式
|
|
33947
|
+
* @param {string} text - 要检查的文本
|
|
33948
|
+
* @returns {Object|null} - 匹配结果或null
|
|
33949
|
+
*/
|
|
33950
|
+
function checkTextFormat(text) {
|
|
33951
|
+
if (!text) return null;
|
|
33952
|
+
const regex = /\$L\{([^}]+)\}/;
|
|
33953
|
+
const match = text.match(regex);
|
|
33954
|
+
if (match) {
|
|
33955
|
+
return {
|
|
33956
|
+
fullMatch: match[0],
|
|
33957
|
+
key: match[1]
|
|
34518
33958
|
};
|
|
34519
|
-
return params;
|
|
34520
33959
|
}
|
|
34521
|
-
|
|
34522
|
-
|
|
33960
|
+
return null;
|
|
33961
|
+
}
|
|
33962
|
+
function generateUniqueId() {
|
|
33963
|
+
window.idCounter = window.idCounter || 0;
|
|
33964
|
+
return `i18n_${Date.now()}_${window.idCounter++}`;
|
|
33965
|
+
}
|
|
33966
|
+
|
|
33967
|
+
/**
|
|
33968
|
+
* 检查平台特定元素并返回匹配结果
|
|
33969
|
+
* @param {*} element
|
|
33970
|
+
* @returns
|
|
33971
|
+
*/
|
|
33972
|
+
function checkPlatformElementContent(element) {
|
|
33973
|
+
const checkContentResult = {
|
|
33974
|
+
result: false,
|
|
33975
|
+
innerHTMLMatch: null
|
|
33976
|
+
};
|
|
33977
|
+
let checkArr = [check, catalog_i18n_check, calendar_i18n_check, common_i18n_check];
|
|
33978
|
+
for (let i = 0; i < checkArr.length; i++) {
|
|
33979
|
+
let checkFunc = checkArr[i];
|
|
33980
|
+
let checkContentResult = checkFunc(element);
|
|
33981
|
+
if (checkContentResult.result) {
|
|
33982
|
+
return checkContentResult;
|
|
33983
|
+
}
|
|
34523
33984
|
}
|
|
33985
|
+
return checkContentResult;
|
|
34524
33986
|
}
|
|
34525
|
-
|
|
33987
|
+
function processElement(element) {
|
|
33988
|
+
if (!element) {
|
|
33989
|
+
return false;
|
|
33990
|
+
}
|
|
34526
33991
|
|
|
33992
|
+
// 仅处理元素节点
|
|
33993
|
+
if (element && element.nodeType !== Node.ELEMENT_NODE) {
|
|
33994
|
+
return false;
|
|
33995
|
+
}
|
|
34527
33996
|
|
|
33997
|
+
// 如果元素有子元素,则不处理innerHTML
|
|
33998
|
+
const hasChildren = hasChildElements(element);
|
|
33999
|
+
if (hasChildren) {
|
|
34000
|
+
let children = element.children;
|
|
34001
|
+
for (let i = 0; i < children.length; i++) {
|
|
34002
|
+
let child = children[i];
|
|
34003
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
34004
|
+
let childLocalDomID = child.getAttribute("localDomID");
|
|
34005
|
+
// 如果子元素有localDomID但不在缓存中,移除localDomID属性
|
|
34006
|
+
if (childLocalDomID && window.i18nElementsMap && !window.i18nElementsMap.has(childLocalDomID)) {
|
|
34007
|
+
unProcessElement(child);
|
|
34008
|
+
}
|
|
34009
|
+
}
|
|
34010
|
+
processElement(children[i]);
|
|
34011
|
+
}
|
|
34012
|
+
}
|
|
34528
34013
|
|
|
34014
|
+
// 检查innerHTML是否匹配(仅对没有子元素的元素)
|
|
34015
|
+
let innerHTMLMatch = null;
|
|
34016
|
+
const attrCheckResult = attribute_i18n_check(element);
|
|
34017
|
+
if (attrCheckResult.result) {
|
|
34018
|
+
console.log("检查到属性匹配元素:", element);
|
|
34019
|
+
}
|
|
34529
34020
|
|
|
34530
|
-
|
|
34531
|
-
|
|
34532
|
-
|
|
34533
|
-
|
|
34534
|
-
|
|
34535
|
-
|
|
34536
|
-
|
|
34537
|
-
|
|
34538
|
-
|
|
34539
|
-
|
|
34540
|
-
|
|
34541
|
-
|
|
34542
|
-
|
|
34543
|
-
|
|
34544
|
-
|
|
34545
|
-
|
|
34546
|
-
getChatClientClasses: async () => {
|
|
34547
|
-
return [];
|
|
34548
|
-
},
|
|
34549
|
-
getAIRobotInfos: async (user_id, groupID) => {
|
|
34550
|
-
return getAIRobotInfos(user_id, groupID);
|
|
34551
|
-
},
|
|
34552
|
-
getPortalUserSig: async (robotKey, platType, groupID) => {
|
|
34553
|
-
return getPortalUserSig(robotKey, platType, groupID);
|
|
34554
|
-
},
|
|
34555
|
-
addIMMapping: async (robotKey, platType, userSig, groupID) => {
|
|
34556
|
-
return addIMMapping(robotKey, platType, groupID, userSig);
|
|
34557
|
-
},
|
|
34558
|
-
updateIMMapping: async data => {
|
|
34559
|
-
let robotKey = data.userID;
|
|
34560
|
-
let platType = data.im_type;
|
|
34561
|
-
let groupID = data.group_id;
|
|
34562
|
-
let userSig = data.userSig;
|
|
34563
|
-
return updateIMMapping(robotKey, platType, groupID, userSig);
|
|
34564
|
-
},
|
|
34565
|
-
getPortalAccessToken: async data => {
|
|
34566
|
-
let appKey = data.appKey;
|
|
34567
|
-
let appSecret = data.appSecret;
|
|
34568
|
-
return getPortalAccessToken(appKey, appSecret);
|
|
34569
|
-
},
|
|
34570
|
-
getPortalUserInfo: async data => {
|
|
34571
|
-
let code = data.code;
|
|
34572
|
-
let access_token = data.access_token;
|
|
34573
|
-
return getPortalUserInfo(code, access_token);
|
|
34574
|
-
},
|
|
34575
|
-
getAllUserInfosByGroupID: async data => {
|
|
34576
|
-
let groupID = data.groupID;
|
|
34577
|
-
return getAllUserInfosByGroupID(groupID);
|
|
34578
|
-
},
|
|
34579
|
-
getChildrenOfficeInfosByID: async data => {
|
|
34580
|
-
let groupID = data.groupID;
|
|
34581
|
-
return getChildrenOfficeInfosByID(groupID);
|
|
34582
|
-
},
|
|
34583
|
-
getPojectDptsByUserAndGroupID: async data => {
|
|
34584
|
-
let groupID = data.groupID;
|
|
34585
|
-
let userID = data.userID;
|
|
34586
|
-
return getPojectDptsByUserAndGroupID(userID, groupID);
|
|
34587
|
-
},
|
|
34588
|
-
closeWindow: () => {
|
|
34589
|
-
// this.visable = false;
|
|
34590
|
-
return true;
|
|
34591
|
-
},
|
|
34592
|
-
addChatListener: async (listenerKey, handler) => {
|
|
34593
|
-
await addEventAction(listenerKey, handler);
|
|
34594
|
-
},
|
|
34595
|
-
fireEventToChatWindow: async (event, chart_origin, key, params, handler) => {
|
|
34596
|
-
await sendWindowMessage(event.source, chart_origin, key, params, handler);
|
|
34597
|
-
},
|
|
34598
|
-
onChatInitFinished: async () => {
|
|
34599
|
-
// this.chatInitFinish = true;
|
|
34600
|
-
},
|
|
34601
|
-
onAIAgentEvent: async (data, event) => {
|
|
34602
|
-
// this.onAIAgentEvent(data,event);
|
|
34603
|
-
},
|
|
34604
|
-
getPortalDocmentInfo: async data => {
|
|
34605
|
-
let kb_doc_id = data.kb_doc_id;
|
|
34606
|
-
let doc_info = await getPortalDocmentInfo(kb_doc_id);
|
|
34607
|
-
let urlStr = doc_info?.summary;
|
|
34608
|
-
if (urlStr) {
|
|
34609
|
-
let urlObj = JSON.parse(urlStr);
|
|
34610
|
-
if (urlObj) {
|
|
34611
|
-
let url = urlObj[0].url;
|
|
34612
|
-
let home_page = window.smardaten_api_context_path;
|
|
34613
|
-
let finalUrl = `${home_page}/storage_area/public${url}`;
|
|
34614
|
-
let fileSize = await getFileSize(finalUrl);
|
|
34615
|
-
doc_info.fileSize = fileSize;
|
|
34021
|
+
//检查是否是smardaten平台元素
|
|
34022
|
+
const checkContentResult = checkPlatformElementContent(element);
|
|
34023
|
+
if (checkContentResult.result) {
|
|
34024
|
+
innerHTMLMatch = checkContentResult.innerHTMLMatch;
|
|
34025
|
+
element.setAttribute("oldValue", innerHTMLMatch.oldValue);
|
|
34026
|
+
} else {
|
|
34027
|
+
if (!hasChildren) {
|
|
34028
|
+
//如果存在历史值,说明之前解析过,有可能是值需要刷新触发
|
|
34029
|
+
let newValue = element.innerHTML;
|
|
34030
|
+
let newMatch = checkTextFormat(newValue);
|
|
34031
|
+
if (newMatch) {
|
|
34032
|
+
innerHTMLMatch = newMatch;
|
|
34033
|
+
} else {
|
|
34034
|
+
newValue = element.getAttribute("oldValue");
|
|
34035
|
+
if (!newValue) {
|
|
34036
|
+
newValue = element.innerHTML;
|
|
34616
34037
|
}
|
|
34038
|
+
innerHTMLMatch = checkTextFormat(newValue);
|
|
34039
|
+
}
|
|
34040
|
+
if (innerHTMLMatch) {
|
|
34041
|
+
// console.log("检查到innerHTML匹配元素:",element);
|
|
34042
|
+
element.setAttribute("oldValue", newValue);
|
|
34617
34043
|
}
|
|
34618
|
-
return doc_info;
|
|
34619
34044
|
}
|
|
34620
|
-
}
|
|
34621
|
-
handler = {
|
|
34622
|
-
...handler,
|
|
34623
|
-
...customerHanlder
|
|
34624
|
-
};
|
|
34625
|
-
return handler;
|
|
34626
|
-
};
|
|
34627
|
-
|
|
34628
|
-
;// ./src/api/dify.js
|
|
34629
|
-
|
|
34045
|
+
}
|
|
34630
34046
|
|
|
34631
|
-
|
|
34632
|
-
|
|
34633
|
-
|
|
34634
|
-
let aiAgentServerIP = appCustomData?.aiAgentServerIP || "";
|
|
34635
|
-
if (!aiAgentServerIP) {
|
|
34636
|
-
console.error("没有配置AI Agent服务地址,请联系管理员");
|
|
34637
|
-
if (errorCallback) errorCallback("没有配置AI Agent服务地址,请联系管理员");
|
|
34638
|
-
return;
|
|
34047
|
+
// 如果没有匹配的内容,则不处理
|
|
34048
|
+
if (!innerHTMLMatch && !checkContentResult.result && !attrCheckResult.result) {
|
|
34049
|
+
return false;
|
|
34639
34050
|
}
|
|
34640
|
-
let
|
|
34641
|
-
|
|
34642
|
-
|
|
34643
|
-
|
|
34644
|
-
|
|
34645
|
-
|
|
34646
|
-
|
|
34051
|
+
let elementId = element.getAttribute("localDomID");
|
|
34052
|
+
if (!elementId) {
|
|
34053
|
+
elementId = generateUniqueId();
|
|
34054
|
+
} else {
|
|
34055
|
+
// 已经处理过的元素跳过
|
|
34056
|
+
return false;
|
|
34057
|
+
}
|
|
34058
|
+
element.setAttribute("localDomID", elementId);
|
|
34059
|
+
if (!window.i18nElementsMap) {
|
|
34060
|
+
window.i18nElementsMap = new Map();
|
|
34061
|
+
}
|
|
34062
|
+
// 添加到Map缓存
|
|
34063
|
+
window.i18nElementsMap.set(elementId, {
|
|
34064
|
+
dom: element,
|
|
34065
|
+
id: elementId,
|
|
34066
|
+
isScriptAction: innerHTMLMatch ? innerHTMLMatch.isScriptAction || false : false,
|
|
34067
|
+
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
|
|
34068
|
+
isAttibuteAction: attrCheckResult.result,
|
|
34069
|
+
attrFunction: attrCheckResult.scriptFunction || null
|
|
34647
34070
|
});
|
|
34648
|
-
|
|
34649
|
-
|
|
34650
|
-
|
|
34651
|
-
|
|
34652
|
-
|
|
34653
|
-
|
|
34654
|
-
|
|
34655
|
-
|
|
34656
|
-
|
|
34657
|
-
|
|
34658
|
-
|
|
34659
|
-
|
|
34660
|
-
|
|
34661
|
-
|
|
34662
|
-
|
|
34663
|
-
|
|
34664
|
-
|
|
34665
|
-
|
|
34666
|
-
"
|
|
34667
|
-
|
|
34668
|
-
|
|
34669
|
-
|
|
34670
|
-
|
|
34671
|
-
"
|
|
34672
|
-
|
|
34673
|
-
|
|
34674
|
-
|
|
34675
|
-
|
|
34676
|
-
|
|
34677
|
-
|
|
34678
|
-
|
|
34679
|
-
"MP4": "video",
|
|
34680
|
-
"MOV": "video",
|
|
34681
|
-
"MPEG": "video"
|
|
34682
|
-
};
|
|
34683
|
-
let key = fileType.toUpperCase();
|
|
34684
|
-
return typeOptions[key] || "custom";
|
|
34685
|
-
};
|
|
34071
|
+
// console.log("添加后元素缓冲数:",window.i18nElementsMap.size);
|
|
34072
|
+
applyTranslation(element);
|
|
34073
|
+
return true;
|
|
34074
|
+
}
|
|
34075
|
+
function unProcessElement(element) {
|
|
34076
|
+
if (element && element.nodeType !== 1) {
|
|
34077
|
+
return;
|
|
34078
|
+
}
|
|
34079
|
+
let hasChildren = hasChildElements(element);
|
|
34080
|
+
if (hasChildren) {
|
|
34081
|
+
let children = element.children;
|
|
34082
|
+
for (let i = 0; i < children.length; i++) {
|
|
34083
|
+
unProcessElement(children[i]);
|
|
34084
|
+
}
|
|
34085
|
+
}
|
|
34086
|
+
const localDomID = element.getAttribute("localDomID");
|
|
34087
|
+
if (localDomID) {
|
|
34088
|
+
// console.log(`处理元素ID:${localDomID} 移除缓存`);
|
|
34089
|
+
element.removeAttribute("localDomID");
|
|
34090
|
+
}
|
|
34091
|
+
if (localDomID && window.i18nElementsMap.has(localDomID)) {
|
|
34092
|
+
// let oldValue = element.getAttribute("oldValue");
|
|
34093
|
+
// if(oldValue){
|
|
34094
|
+
// element.removeAttribute("oldValue");
|
|
34095
|
+
// 更新元素的innerHTML
|
|
34096
|
+
// element.innerHTML = oldValue;
|
|
34097
|
+
// }
|
|
34098
|
+
window.i18nElementsMap.delete(localDomID);
|
|
34099
|
+
// console.log("移除后元素缓冲数:",window.i18nElementsMap.size);
|
|
34100
|
+
}
|
|
34101
|
+
}
|
|
34686
34102
|
|
|
34687
34103
|
/**
|
|
34688
|
-
*
|
|
34689
|
-
* @param {
|
|
34690
|
-
* @
|
|
34691
|
-
*/
|
|
34692
|
-
const
|
|
34693
|
-
|
|
34694
|
-
|
|
34695
|
-
|
|
34696
|
-
|
|
34697
|
-
|
|
34698
|
-
|
|
34104
|
+
* 应用翻译到单个元素
|
|
34105
|
+
* @param {HTMLElement} element - 要更新的DOM元素
|
|
34106
|
+
* @param {string} lang - 语言标识符
|
|
34107
|
+
*/
|
|
34108
|
+
const applyTranslation = async element => {
|
|
34109
|
+
let parentNode = element.parentNode;
|
|
34110
|
+
if (!parentNode) {
|
|
34111
|
+
unProcessElement(element);
|
|
34112
|
+
console.log("元素已无父节点,移除缓存");
|
|
34113
|
+
return;
|
|
34114
|
+
}
|
|
34115
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
34116
|
+
let appID = getPoratlAppID();
|
|
34117
|
+
const elementId = element.getAttribute("localDomID");
|
|
34118
|
+
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
34119
|
+
if (!cachedItem) return;
|
|
34120
|
+
// 处理属性
|
|
34121
|
+
if (cachedItem.isAttibuteAction) {
|
|
34122
|
+
cachedItem.attrFunction(appID, lang);
|
|
34123
|
+
}
|
|
34124
|
+
// 处理innerHTML
|
|
34125
|
+
if (cachedItem.isScriptAction) {
|
|
34126
|
+
cachedItem.scriptFunction(appID, lang);
|
|
34127
|
+
} else {
|
|
34128
|
+
const oldValue = element.getAttribute("oldValue");
|
|
34129
|
+
if (oldValue) {
|
|
34130
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
34131
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
34132
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
34133
|
+
let newValue = oldValue;
|
|
34134
|
+
let match;
|
|
34135
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
34136
|
+
const fullMatch = match[0];
|
|
34137
|
+
const placeholderKey = match[1];
|
|
34138
|
+
const translation = i18n(placeholderKey, appID, lang);
|
|
34139
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
34140
|
+
}
|
|
34141
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.nextTick)(() => {
|
|
34142
|
+
// 更新元素的innerHTML
|
|
34143
|
+
element.innerHTML = newValue;
|
|
34144
|
+
});
|
|
34145
|
+
}
|
|
34699
34146
|
}
|
|
34700
34147
|
};
|
|
34701
|
-
|
|
34702
|
-
|
|
34703
|
-
|
|
34704
|
-
|
|
34705
|
-
|
|
34706
|
-
|
|
34707
|
-
|
|
34708
|
-
|
|
34709
|
-
|
|
34710
|
-
|
|
34711
|
-
|
|
34712
|
-
|
|
34713
|
-
|
|
34148
|
+
const initDomNodeI18NObserver = () => {
|
|
34149
|
+
if (!window.i18nElementsMap) {
|
|
34150
|
+
window.i18nElementsMap = new Map();
|
|
34151
|
+
} else {
|
|
34152
|
+
window.i18nElementsMap.clear();
|
|
34153
|
+
}
|
|
34154
|
+
registerEventListener("IPORTAL_LANGUAGE_CHANGE_EVENT", async lang => {
|
|
34155
|
+
console.log("语言切换事件触发,更新已处理元素的翻译:", lang);
|
|
34156
|
+
// 遍历Map,更新每个已处理元素的翻译
|
|
34157
|
+
for (const [elementId, item] of window.i18nElementsMap.entries()) {
|
|
34158
|
+
// console.log("更新元素翻译:", elementId, item.dom);
|
|
34159
|
+
applyTranslation(item.dom);
|
|
34160
|
+
}
|
|
34161
|
+
});
|
|
34162
|
+
// 创建观察器实例
|
|
34163
|
+
const observer = new MutationObserver(mutations => {
|
|
34164
|
+
mutations.forEach(mutation => {
|
|
34165
|
+
if (mutation.type === 'childList') {
|
|
34166
|
+
// 节点添加
|
|
34167
|
+
if (mutation.addedNodes.length > 0) {
|
|
34168
|
+
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
34169
|
+
let node = mutation.addedNodes[i];
|
|
34170
|
+
// console.log(`处理新增节点:`,node);
|
|
34171
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
34172
|
+
node = node.parentNode;
|
|
34173
|
+
}
|
|
34174
|
+
processElement(node);
|
|
34175
|
+
}
|
|
34176
|
+
}
|
|
34177
|
+
// 节点移除
|
|
34178
|
+
if (mutation.removedNodes.length > 0) {
|
|
34179
|
+
for (let i = 0; i < mutation.removedNodes.length; i++) {
|
|
34180
|
+
let node = mutation.removedNodes[i];
|
|
34181
|
+
// console.log(`处理移除节点:`,node);
|
|
34182
|
+
unProcessElement(node);
|
|
34183
|
+
}
|
|
34184
|
+
}
|
|
34185
|
+
} else if (mutation.type === 'characterData') {
|
|
34186
|
+
// 处理文本变化
|
|
34187
|
+
const oldValue = mutation.oldValue;
|
|
34188
|
+
const targetNode = mutation.target;
|
|
34189
|
+
const newValue = targetNode.data;
|
|
34190
|
+
// 创建日志条目并显示
|
|
34191
|
+
console.log(`文本修改: ${oldValue} → ${newValue}`);
|
|
34192
|
+
const parentElement = targetNode.parentNode;
|
|
34193
|
+
if (parentElement) {
|
|
34194
|
+
let localDomID = parentElement.getAttribute("localDomID");
|
|
34195
|
+
// 如果有localDomID,说明之前处理过,先移除缓存
|
|
34196
|
+
if (localDomID) {
|
|
34197
|
+
unProcessElement(parentElement);
|
|
34198
|
+
}
|
|
34199
|
+
}
|
|
34200
|
+
processElement(parentElement);
|
|
34201
|
+
}
|
|
34202
|
+
});
|
|
34714
34203
|
});
|
|
34715
|
-
};
|
|
34716
34204
|
|
|
34717
|
-
|
|
34718
|
-
|
|
34719
|
-
|
|
34720
|
-
|
|
34721
|
-
|
|
34722
|
-
|
|
34723
|
-
|
|
34724
|
-
|
|
34725
|
-
|
|
34726
|
-
|
|
34727
|
-
|
|
34728
|
-
const isSMSCodeValidate = async (smsCode, sms_service_name_type, beyond_type_id, account_id) => {
|
|
34729
|
-
let questUrl = `/ext/validateSMSCode`;
|
|
34730
|
-
let queryData = {
|
|
34731
|
-
param: {
|
|
34732
|
-
smsCode: smsCode,
|
|
34733
|
-
sms_service_name_type: sms_service_name_type,
|
|
34734
|
-
beyond_type_id: beyond_type_id,
|
|
34735
|
-
account_id: account_id
|
|
34736
|
-
}
|
|
34205
|
+
// 配置观察选项
|
|
34206
|
+
const config = {
|
|
34207
|
+
childList: true,
|
|
34208
|
+
// 观察子节点变化
|
|
34209
|
+
subtree: true,
|
|
34210
|
+
// 观察所有后代节点
|
|
34211
|
+
attributes: false,
|
|
34212
|
+
// 不观察属性变化
|
|
34213
|
+
characterData: true,
|
|
34214
|
+
// 不观察文本内容变化
|
|
34215
|
+
characterDataOldValue: true
|
|
34737
34216
|
};
|
|
34738
|
-
|
|
34739
|
-
|
|
34740
|
-
|
|
34741
|
-
|
|
34217
|
+
// 开始观察目标节点
|
|
34218
|
+
const targetNode = document.body;
|
|
34219
|
+
processElement(targetNode);
|
|
34220
|
+
observer.observe(targetNode, config);
|
|
34742
34221
|
};
|
|
34743
34222
|
;// ./src/main.js
|
|
34744
34223
|
|
|
@@ -34749,7 +34228,6 @@ const isSMSCodeValidate = async (smsCode, sms_service_name_type, beyond_type_id,
|
|
|
34749
34228
|
|
|
34750
34229
|
|
|
34751
34230
|
|
|
34752
|
-
|
|
34753
34231
|
;// ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js
|
|
34754
34232
|
|
|
34755
34233
|
|