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