isdata-customer-sdk 0.1.100 → 0.2.2

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.
@@ -33089,7 +33089,7 @@ const dify_extractFilenameFromUrl = url => {
33089
33089
  };
33090
33090
  ;// external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
33091
33091
  var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
33092
- ;// ./src/api/smardaten_i18n/table_i18n.js
33092
+ ;// ./src/api/i18n/smardaten_i18n/table_i18n.js
33093
33093
 
33094
33094
  const check = element => {
33095
33095
  const checkResult = {
@@ -33119,6 +33119,19 @@ const check = element => {
33119
33119
  return checkResult;
33120
33120
  }
33121
33121
  }
33122
+ // 检查分页组件 导出按钮
33123
+ if (classes.contains("export_menu")) {
33124
+ let innerHTML = element.innerHTML;
33125
+ if (innerHTML.includes("导出进度") || innerHTML.includes("Export progress")) {
33126
+ console.log("检查smardaten平台表格 导出按钮 元素:", innerHTML);
33127
+ let tempHTMLMatch = {
33128
+ oldValue: '$L{PLATFORM_EXPORT_ALL}'
33129
+ };
33130
+ checkResult.result = true;
33131
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33132
+ return checkResult;
33133
+ }
33134
+ }
33122
33135
  // 检查分页组件
33123
33136
  if (classes.contains("total_pag_num")) {
33124
33137
  let innerHTML = element.innerHTML;
@@ -33160,7 +33173,7 @@ const check = element => {
33160
33173
  }
33161
33174
  };
33162
33175
  let tempHTMLMatch = {
33163
- isScriptOldValue: true,
33176
+ isScriptAction: true,
33164
33177
  scriptFunction: scriptFunction
33165
33178
  };
33166
33179
  checkResult.result = true;
@@ -33209,7 +33222,7 @@ const check = element => {
33209
33222
  }
33210
33223
  };
33211
33224
  let tempHTMLMatch = {
33212
- isScriptOldValue: true,
33225
+ isScriptAction: true,
33213
33226
  scriptFunction: scriptFunction
33214
33227
  };
33215
33228
  checkResult.result = true;
@@ -33277,7 +33290,7 @@ const check = element => {
33277
33290
  }
33278
33291
  return checkResult;
33279
33292
  };
33280
- ;// ./src/api/smardaten_i18n/catalog_i18n.js
33293
+ ;// ./src/api/i18n/smardaten_i18n/catalog_i18n.js
33281
33294
 
33282
33295
  const catalog_i18n_check = element => {
33283
33296
  const checkResult = {
@@ -33311,7 +33324,49 @@ const catalog_i18n_check = element => {
33311
33324
  };
33312
33325
  let tempHTMLMatch = {
33313
33326
  oldValue: oldValue,
33314
- isScriptOldValue: true,
33327
+ isScriptAction: true,
33328
+ scriptFunction: scriptFunction
33329
+ };
33330
+ checkResult.result = true;
33331
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33332
+ return checkResult;
33333
+ }
33334
+ return checkResult;
33335
+ };
33336
+ ;// ./src/api/i18n/commom_i18n/common_i18n.js
33337
+
33338
+ const common_i18n_check = element => {
33339
+ const checkResult = {
33340
+ result: false,
33341
+ innerHTMLMatch: null
33342
+ };
33343
+ // 检查目录列表 名称 列
33344
+ if (element.tagName === 'BUTTON') {
33345
+ let innerHTML = element.innerHTML;
33346
+ let oldValue = innerHTML;
33347
+ console.log("检查 button 元素:", innerHTML);
33348
+ let scriptFunction = (appID, lang) => {
33349
+ for (let i = 0; i < element.childNodes.length; i++) {
33350
+ let scriptNodeItem = element.childNodes[i];
33351
+ if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
33352
+ let text = element.getAttribute("oldValue");
33353
+ let isTextMatch = checkTextFormat(text);
33354
+ if (!isTextMatch) {
33355
+ element.appendChild(scriptNodeItem);
33356
+ } else {
33357
+ element.removeChild(scriptNodeItem);
33358
+ let key = isTextMatch.key;
33359
+ let textNode = document.createTextNode(i18n(key, appID, lang) || key);
33360
+ element.appendChild(textNode);
33361
+ }
33362
+ } else {
33363
+ element.appendChild(scriptNodeItem);
33364
+ }
33365
+ }
33366
+ };
33367
+ let tempHTMLMatch = {
33368
+ oldValue: oldValue,
33369
+ isScriptAction: true,
33315
33370
  scriptFunction: scriptFunction
33316
33371
  };
33317
33372
  checkResult.result = true;
@@ -33320,7 +33375,51 @@ const catalog_i18n_check = element => {
33320
33375
  }
33321
33376
  return checkResult;
33322
33377
  };
33323
- ;// ./src/api/i18n.js
33378
+ ;// ./src/api/i18n/commom_i18n/attribute_i18n.js
33379
+
33380
+ const attribute_i18n_check = element => {
33381
+ const checkResult = {
33382
+ result: false,
33383
+ innerHTMLMatch: null
33384
+ };
33385
+ const checkAttributes = ["placeholder", "title"];
33386
+ for (let i = 0; i < checkAttributes.length; i++) {
33387
+ let attr = checkAttributes[i];
33388
+ let attrValue = element.getAttribute(attr) || element[attr];
33389
+ const attrMatch = attrValue ? checkTextFormat(attrValue) : null;
33390
+ if (attrMatch) {
33391
+ console.log("检查元素属性 i18n 元素:", attr, attrValue);
33392
+ element.setAttribute(`old${attr}Value`, attrValue);
33393
+ checkResult.result = true;
33394
+ }
33395
+ }
33396
+ let scriptFunction = (appID, lang) => {
33397
+ for (let i = 0; i < checkAttributes.length; i++) {
33398
+ let attr = checkAttributes[i];
33399
+ const oldAttrValue = element.getAttribute(`old${attr}Value`);
33400
+ if (oldAttrValue) {
33401
+ // 创建正则表达式匹配所有 $L{...} 格式
33402
+ const regex = /\$L\{([^}]+)\}/g;
33403
+ // 替换所有 $L{...} 占位符为翻译文本
33404
+ let newAttrValue = oldAttrValue;
33405
+ let match;
33406
+ while ((match = regex.exec(oldAttrValue)) !== null) {
33407
+ const fullMatch = match[0];
33408
+ const attrKey = match[1];
33409
+ const translation = i18n(attrKey, appID, lang);
33410
+ newAttrValue = newAttrValue.replace(fullMatch, translation);
33411
+ }
33412
+ // 更新元素的placeholder属性
33413
+ element.setAttribute(attr, newAttrValue);
33414
+ }
33415
+ }
33416
+ };
33417
+ checkResult.scriptFunction = scriptFunction;
33418
+ return checkResult;
33419
+ };
33420
+ ;// ./src/api/i18n/i18n.js
33421
+
33422
+
33324
33423
 
33325
33424
 
33326
33425
 
@@ -33393,41 +33492,20 @@ function generateUniqueId() {
33393
33492
  * @param {*} element
33394
33493
  * @returns
33395
33494
  */
33396
- function checkPlatformElement(element) {
33397
- const checkResult = {
33495
+ function checkPlatformElementContent(element) {
33496
+ const checkContentResult = {
33398
33497
  result: false,
33399
33498
  innerHTMLMatch: null
33400
33499
  };
33401
- let checkArr = [check, catalog_i18n_check];
33500
+ let checkArr = [check, catalog_i18n_check, common_i18n_check];
33402
33501
  for (let i = 0; i < checkArr.length; i++) {
33403
33502
  let checkFunc = checkArr[i];
33404
- let checkResult = checkFunc(element);
33405
- if (checkResult.result) {
33406
- return checkResult;
33503
+ let checkContentResult = checkFunc(element);
33504
+ if (checkContentResult.result) {
33505
+ return checkContentResult;
33407
33506
  }
33408
33507
  }
33409
- return checkResult;
33410
- }
33411
- function checkParantNodeNeedFiller(element) {
33412
- const filterTags = ["BUTTON"];
33413
- for (let tag of filterTags) {
33414
- if (element.tagName === tag) {
33415
- return false;
33416
- }
33417
- }
33418
- //当为目录列表时catalog_name_content
33419
- //当为表格单元格时ant-table-cell
33420
- //当为分页总数时total_pag_num
33421
- //当为分页每页条数选择时ant-pagination-options-quick-jumper
33422
- //当为分页下拉选择时ant-select-selection-item
33423
- //当为分页下拉选项时ant-select-item-option-content
33424
- const classes = ["catalog_name_content", "ant-table-cell", "total_pag_num", "ant-pagination-options-quick-jumper", "ant-select-selection-item", "ant-select-item-option-content", "catalog_name_content", "catalog_tree_node"];
33425
- for (let cls of classes) {
33426
- if (element.classList.contains(cls)) {
33427
- return false;
33428
- }
33429
- }
33430
- return true;
33508
+ return checkContentResult;
33431
33509
  }
33432
33510
 
33433
33511
  // 处理DOM元素的函数
@@ -33442,33 +33520,32 @@ function processElement(element) {
33442
33520
  for (let i = 0; i < children.length; i++) {
33443
33521
  processElement(children[i]);
33444
33522
  }
33445
-
33446
- // 检查父亲性质节点是否需要被过滤
33447
- const isParentNodeNeedFilter = checkParantNodeNeedFiller(element);
33448
- if (isParentNodeNeedFilter) {
33449
- return false;
33450
- }
33451
33523
  }
33452
- // element.setAttribute("i18nProcessed", "true"); // 标记元素已被处理
33453
- // 检查placeholder是否匹配
33454
- const placeholder = element.getAttribute("placeholder") || element.placeholder;
33455
- const placeholderMatch = placeholder ? checkTextFormat(placeholder) : null;
33456
- const title = element.getAttribute("title") || element.title;
33457
- const titleMatch = title ? checkTextFormat(title) : null;
33458
33524
 
33459
33525
  // 检查innerHTML是否匹配(仅对没有子元素的元素)
33460
33526
  let innerHTMLMatch = null;
33461
- const innerHTML = element.innerHTML;
33462
- innerHTMLMatch = checkTextFormat(innerHTML);
33527
+ const attrCheckResult = attribute_i18n_check(element);
33528
+ if (attrCheckResult.result) {
33529
+ console.log("检查到属性匹配元素:", element);
33530
+ }
33463
33531
 
33464
33532
  //检查是否是smardaten平台元素
33465
- const checkResult = checkPlatformElement(element);
33466
- if (checkResult.result) {
33467
- innerHTMLMatch = checkResult.innerHTMLMatch;
33533
+ const checkContentResult = checkPlatformElementContent(element);
33534
+ if (checkContentResult.result) {
33535
+ innerHTMLMatch = checkContentResult.innerHTMLMatch;
33536
+ element.setAttribute("oldValue", innerHTMLMatch.oldValue);
33537
+ } else {
33538
+ if (!hasChildren) {
33539
+ const innerHTML = element.innerHTML;
33540
+ innerHTMLMatch = checkTextFormat(innerHTML);
33541
+ if (innerHTMLMatch) {
33542
+ element.setAttribute("oldValue", element.innerHTML);
33543
+ }
33544
+ }
33468
33545
  }
33469
33546
 
33470
33547
  // 如果没有匹配的内容,则不处理
33471
- if (!placeholderMatch && !innerHTMLMatch && !checkResult.result && !titleMatch) {
33548
+ if (!innerHTMLMatch && !checkContentResult.result && !attrCheckResult.result) {
33472
33549
  return false;
33473
33550
  }
33474
33551
  let elementId = element.getAttribute("localDomID");
@@ -33477,36 +33554,14 @@ function processElement(element) {
33477
33554
  }
33478
33555
  element.setAttribute("localDomID", elementId);
33479
33556
 
33480
- // console.log("处理元素:", element, {
33481
- // placeholderMatch,
33482
- // valueMatch,
33483
- // innerHTMLMatch,
33484
- // });
33485
- // 处理placeholder
33486
- if (placeholderMatch) {
33487
- element.setAttribute("oldPlaceholderValue", placeholder);
33488
- }
33489
- if (titleMatch) {
33490
- element.setAttribute("oldTitleValue", title);
33491
- }
33492
-
33493
- // 处理innerHTML(仅对没有子元素的元素)
33494
- if (!hasChildren && innerHTMLMatch) {
33495
- element.setAttribute("oldValue", element.innerHTML);
33496
- }
33497
- if (checkResult.result) {
33498
- element.setAttribute("oldValue", innerHTMLMatch.oldValue);
33499
- }
33500
-
33501
33557
  // 添加到Map缓存
33502
33558
  window.i18nElementsMap.set(elementId, {
33503
33559
  dom: element,
33504
33560
  id: elementId,
33505
- oldValue: innerHTMLMatch ? element.innerHTML : null,
33506
- oldPlaceholderValue: placeholderMatch ? placeholder : null,
33507
- oldTitleValue: titleMatch ? title : null,
33508
- isScriptOldValue: innerHTMLMatch ? innerHTMLMatch.isScriptOldValue || false : false,
33509
- scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null
33561
+ isScriptAction: innerHTMLMatch ? innerHTMLMatch.isScriptAction || false : false,
33562
+ scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
33563
+ isAttibuteAction: attrCheckResult.result,
33564
+ attrFunction: attrCheckResult.scriptFunction || null
33510
33565
  });
33511
33566
  applyTranslation(element);
33512
33567
  return true;
@@ -33540,66 +33595,31 @@ const applyTranslation = async element => {
33540
33595
  const elementId = element.getAttribute("localDomID");
33541
33596
  const cachedItem = window.i18nElementsMap.get(elementId);
33542
33597
  if (!cachedItem) return;
33543
- // 处理placeholder(如果是input元素)
33544
- if (cachedItem.oldPlaceholderValue) {
33545
- const oldPlaceholderValue = element.getAttribute("oldPlaceholderValue");
33546
- if (oldPlaceholderValue) {
33598
+ // 处理属性
33599
+ if (cachedItem.isAttibuteAction) {
33600
+ cachedItem.attrFunction(appID, lang);
33601
+ }
33602
+ // 处理innerHTML
33603
+ if (cachedItem.isScriptAction) {
33604
+ cachedItem.scriptFunction(appID, lang);
33605
+ } else {
33606
+ const oldValue = element.getAttribute("oldValue");
33607
+ if (oldValue) {
33547
33608
  // 创建正则表达式匹配所有 $L{...} 格式
33548
33609
  const regex = /\$L\{([^}]+)\}/g;
33549
33610
  // 替换所有 $L{...} 占位符为翻译文本
33550
- let newPlaceholderValue = oldPlaceholderValue;
33611
+ let newValue = oldValue;
33551
33612
  let match;
33552
- while ((match = regex.exec(oldPlaceholderValue)) !== null) {
33613
+ while ((match = regex.exec(oldValue)) !== null) {
33553
33614
  const fullMatch = match[0];
33554
33615
  const placeholderKey = match[1];
33555
33616
  const translation = i18n(placeholderKey, appID, lang);
33556
- newPlaceholderValue = newPlaceholderValue.replace(fullMatch, translation);
33557
- }
33558
- // 更新元素的placeholder属性
33559
- element.setAttribute("placeholder", newPlaceholderValue);
33560
- }
33561
- }
33562
- if (cachedItem.oldTitleValue) {
33563
- const oldTitleValue = element.getAttribute("oldTitleValue");
33564
- if (oldTitleValue) {
33565
- // 创建正则表达式匹配所有 $L{...} 格式
33566
- const regex = /\$L\{([^}]+)\}/g;
33567
- // 替换所有 $L{...} 占位符为翻译文本
33568
- let newTitleValue = oldTitleValue;
33569
- let match;
33570
- while ((match = regex.exec(oldTitleValue)) !== null) {
33571
- const fullMatch = match[0];
33572
- const titleKey = match[1];
33573
- const translation = i18n(titleKey, appID, lang);
33574
- newTitleValue = newTitleValue.replace(fullMatch, translation);
33575
- // 更新元素的title属性
33576
- element.setAttribute("title", newTitleValue);
33577
- }
33578
- }
33579
- }
33580
- // console.log("更新innerHTML翻译:", element);
33581
- if (cachedItem.isScriptOldValue) {
33582
- cachedItem.scriptFunction(appID, lang);
33583
- } else {
33584
- if (cachedItem.oldValue) {
33585
- const oldValue = element.getAttribute("oldValue");
33586
- if (oldValue) {
33587
- // 创建正则表达式匹配所有 $L{...} 格式
33588
- const regex = /\$L\{([^}]+)\}/g;
33589
- // 替换所有 $L{...} 占位符为翻译文本
33590
- let newValue = oldValue;
33591
- let match;
33592
- while ((match = regex.exec(oldValue)) !== null) {
33593
- const fullMatch = match[0];
33594
- const placeholderKey = match[1];
33595
- const translation = i18n(placeholderKey, appID, lang);
33596
- newValue = newValue.replace(fullMatch, translation);
33597
- }
33598
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.nextTick)(() => {
33599
- // 更新元素的innerHTML
33600
- element.innerHTML = newValue;
33601
- });
33617
+ newValue = newValue.replace(fullMatch, translation);
33602
33618
  }
33619
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.nextTick)(() => {
33620
+ // 更新元素的innerHTML
33621
+ element.innerHTML = newValue;
33622
+ });
33603
33623
  }
33604
33624
  }
33605
33625
  };