isdata-customer-sdk 0.2.87 → 0.2.89

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