isdata-customer-sdk 0.1.98 → 0.1.100

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.
@@ -29556,6 +29556,7 @@ __webpack_require__.d(__webpack_exports__, {
29556
29556
  addIMMapping: function() { return /* reexport */ addIMMapping; },
29557
29557
  addObjectUsedTimes: function() { return /* reexport */ addObjectUsedTimes; },
29558
29558
  addWindowTrustedOrigin: function() { return /* reexport */ addWindowTrustedOrigin; },
29559
+ checkTextFormat: function() { return /* reexport */ checkTextFormat; },
29559
29560
  createFileFromUrl: function() { return /* reexport */ createFileFromUrl; },
29560
29561
  decrypt: function() { return /* reexport */ decrypt; },
29561
29562
  destroyEventCenter: function() { return /* reexport */ destroyEventCenter; },
@@ -33086,12 +33087,248 @@ const dify_extractFilenameFromUrl = url => {
33086
33087
  return "downloaded_file"; // URL 解析失败时的默认文件名
33087
33088
  }
33088
33089
  };
33090
+ ;// external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
33091
+ var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
33092
+ ;// ./src/api/smardaten_i18n/table_i18n.js
33093
+
33094
+ const check = element => {
33095
+ const checkResult = {
33096
+ result: false,
33097
+ innerHTMLMatch: null
33098
+ };
33099
+ const classes = element.classList;
33100
+ // 检查表格头部 序号 和 操作 列
33101
+ if (classes.contains("ant-table-cell")) {
33102
+ let innerHTML = element.innerHTML;
33103
+ if (innerHTML.includes("序号") || innerHTML.includes("Serial No.")) {
33104
+ console.log("检查smardaten平台表格 序号 元素:", innerHTML);
33105
+ let tempHTMLMatch = {
33106
+ oldValue: '$L{PLATFORM_SERIAL_NO}'
33107
+ };
33108
+ checkResult.result = true;
33109
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33110
+ return checkResult;
33111
+ }
33112
+ if (innerHTML.includes("操作")) {
33113
+ console.log("检查smardaten平台表格 操作 元素:", innerHTML);
33114
+ let tempHTMLMatch = {
33115
+ oldValue: '$L{PLATFORM_OPERATE}'
33116
+ };
33117
+ checkResult.result = true;
33118
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33119
+ return checkResult;
33120
+ }
33121
+ }
33122
+ // 检查分页组件
33123
+ if (classes.contains("total_pag_num")) {
33124
+ let innerHTML = element.innerHTML;
33125
+ if (innerHTML.includes("共") && innerHTML.includes("条") || innerHTML.includes("Total") && innerHTML.includes("pieces")) {
33126
+ console.log("检查smardaten平台分页 共xx条 元素:", innerHTML);
33127
+ let scriptFunction = (appID, lang) => {
33128
+ let scriptNode = null;
33129
+ for (let node of element.childNodes) {
33130
+ // 检查是否为文本节点且包含"Total"
33131
+ if (node.tagName === "SPAN") {
33132
+ scriptNode = node;
33133
+ }
33134
+ }
33135
+ let scriptNodes = [{
33136
+ nodeType: Node.TEXT_NODE,
33137
+ key: 'PLATFORM_TOTAL'
33138
+ }, {
33139
+ nodeType: "SCRIPTNODE",
33140
+ node: scriptNode
33141
+ }, {
33142
+ nodeType: Node.TEXT_NODE,
33143
+ key: 'PLATFORM_PIECES'
33144
+ }];
33145
+ for (let i = 0; i < element.childNodes.length; i++) {
33146
+ let childNode = element.childNodes[i];
33147
+ if (childNode.nodeType === Node.TEXT_NODE) {
33148
+ element.removeChild(childNode);
33149
+ }
33150
+ }
33151
+ for (let i = 0; i < scriptNodes.length; i++) {
33152
+ let scriptNodeItem = scriptNodes[i];
33153
+ if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
33154
+ let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
33155
+ element.appendChild(textNode);
33156
+ }
33157
+ if (scriptNodeItem.nodeType === "SCRIPTNODE") {
33158
+ element.appendChild(scriptNodeItem.node);
33159
+ }
33160
+ }
33161
+ };
33162
+ let tempHTMLMatch = {
33163
+ isScriptOldValue: true,
33164
+ scriptFunction: scriptFunction
33165
+ };
33166
+ checkResult.result = true;
33167
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33168
+ return checkResult;
33169
+ }
33170
+ }
33171
+ // 检查分页组件 跳至xx页
33172
+ if (classes.contains("ant-pagination-options-quick-jumper")) {
33173
+ let innerHTML = element.innerHTML;
33174
+ if (innerHTML.includes("跳至") && innerHTML.includes("页") || innerHTML.includes("Go to") && innerHTML.includes("Page")) {
33175
+ console.log("检查smardaten平台分页 跳至xx页 元素:", innerHTML);
33176
+ let scriptFunction = (appID, lang) => {
33177
+ let scriptNode = null;
33178
+ for (let node of element.childNodes) {
33179
+ // 检查是否为文本节点且包含"Total"
33180
+ if (node.tagName === "INPUT") {
33181
+ scriptNode = node;
33182
+ }
33183
+ }
33184
+ let scriptNodes = [{
33185
+ nodeType: Node.TEXT_NODE,
33186
+ key: 'PLATFORM_JUNPTO'
33187
+ }, {
33188
+ nodeType: "SCRIPTNODE",
33189
+ node: scriptNode
33190
+ }, {
33191
+ nodeType: Node.TEXT_NODE,
33192
+ key: 'PLATFORM_PAGE'
33193
+ }];
33194
+ for (let i = 0; i < element.childNodes.length; i++) {
33195
+ let childNode = element.childNodes[i];
33196
+ if (childNode.nodeType === Node.TEXT_NODE) {
33197
+ element.removeChild(childNode);
33198
+ }
33199
+ }
33200
+ for (let i = 0; i < scriptNodes.length; i++) {
33201
+ let scriptNodeItem = scriptNodes[i];
33202
+ if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
33203
+ let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
33204
+ element.appendChild(textNode);
33205
+ }
33206
+ if (scriptNodeItem.nodeType === "SCRIPTNODE") {
33207
+ element.appendChild(scriptNodeItem.node);
33208
+ }
33209
+ }
33210
+ };
33211
+ let tempHTMLMatch = {
33212
+ isScriptOldValue: true,
33213
+ scriptFunction: scriptFunction
33214
+ };
33215
+ checkResult.result = true;
33216
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33217
+ return checkResult;
33218
+ }
33219
+ }
33220
+ // 检查每页xx条
33221
+ if (classes.contains("ant-select-selection-item") || classes.contains("ant-select-item-option-content")) {
33222
+ let innerHTML = element.innerHTML;
33223
+ console.log("检查smardaten平台分页 每页xx条 元素:", innerHTML);
33224
+ if (innerHTML.includes("/") && innerHTML.includes("page") || innerHTML.includes("/") && innerHTML.includes("条") && innerHTML.includes("页")) {
33225
+ let oldValue = element.innerHTML;
33226
+ if (innerHTML.includes("page")) {
33227
+ oldValue = oldValue.replace('page', '$L{PLATFORM_PAGE}');
33228
+ }
33229
+ if (innerHTML.includes("页")) {
33230
+ oldValue = oldValue.replace('页', '$L{PLATFORM_PAGE}');
33231
+ }
33232
+ if (innerHTML.includes("条")) {
33233
+ oldValue = oldValue.replace('条', '$L{PLATFORM_PIECES}');
33234
+ }
33235
+ let tempHTMLMatch = {
33236
+ oldValue: oldValue
33237
+ };
33238
+ checkResult.result = true;
33239
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33240
+ return checkResult;
33241
+ }
33242
+ }
33243
+ // 检查删除确认对话框标题
33244
+ if (classes.contains("ant-popover-message-title")) {
33245
+ let innerHTML = element.innerHTML;
33246
+ if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
33247
+ console.log("检查smardaten平台删除提问对话框:", innerHTML);
33248
+ let tempHTMLMatch = {
33249
+ oldValue: '$L{PLATFORM_DELETE_CONFIRM_TITLE}'
33250
+ };
33251
+ checkResult.result = true;
33252
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33253
+ return checkResult;
33254
+ }
33255
+ }
33256
+ // 检查删除确认对话框按钮 取消 确认
33257
+ if (classes.contains("ant-btn-sm")) {
33258
+ let innerHTML = element.innerHTML;
33259
+ if (innerHTML.includes("Cancel") || innerHTML.includes("取消")) {
33260
+ console.log("检查smardaten平台 Tip提问取消删除按钮:", innerHTML);
33261
+ let tempHTMLMatch = {
33262
+ oldValue: '$L{PLATFORM_CANCEL}'
33263
+ };
33264
+ checkResult.result = true;
33265
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33266
+ return checkResult;
33267
+ }
33268
+ if (innerHTML.includes("确认") || innerHTML.includes("OK")) {
33269
+ console.log("检查smardaten平台 Tip提问确认删除按钮:", innerHTML);
33270
+ let tempHTMLMatch = {
33271
+ oldValue: '$L{PLATFORM_OK}'
33272
+ };
33273
+ checkResult.result = true;
33274
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33275
+ return checkResult;
33276
+ }
33277
+ }
33278
+ return checkResult;
33279
+ };
33280
+ ;// ./src/api/smardaten_i18n/catalog_i18n.js
33281
+
33282
+ const catalog_i18n_check = element => {
33283
+ const checkResult = {
33284
+ result: false,
33285
+ innerHTMLMatch: null
33286
+ };
33287
+ const classes = element.classList;
33288
+ // 检查目录列表 名称 列
33289
+ if (classes.contains("catalog_name_content")) {
33290
+ let innerHTML = element.innerHTML;
33291
+ let oldValue = innerHTML;
33292
+ console.log("检查smardaten平台目录列表 元素:", innerHTML);
33293
+ let scriptFunction = (appID, lang) => {
33294
+ for (let i = 0; i < element.childNodes.length; i++) {
33295
+ let scriptNodeItem = element.childNodes[i];
33296
+ if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
33297
+ let text = element.getAttribute("oldValue");
33298
+ let isTextMatch = checkTextFormat(text);
33299
+ if (!isTextMatch) {
33300
+ element.appendChild(scriptNodeItem);
33301
+ } else {
33302
+ element.removeChild(scriptNodeItem);
33303
+ let key = isTextMatch.key;
33304
+ let textNode = document.createTextNode(i18n(key, appID, lang) || key);
33305
+ element.appendChild(textNode);
33306
+ }
33307
+ } else {
33308
+ element.appendChild(scriptNodeItem);
33309
+ }
33310
+ }
33311
+ };
33312
+ let tempHTMLMatch = {
33313
+ oldValue: oldValue,
33314
+ isScriptOldValue: true,
33315
+ scriptFunction: scriptFunction
33316
+ };
33317
+ checkResult.result = true;
33318
+ checkResult.innerHTMLMatch = tempHTMLMatch;
33319
+ return checkResult;
33320
+ }
33321
+ return checkResult;
33322
+ };
33089
33323
  ;// ./src/api/i18n.js
33090
33324
 
33091
33325
 
33092
33326
 
33093
33327
 
33094
33328
 
33329
+
33330
+
33331
+
33095
33332
  const getLanguages = async appID => {
33096
33333
  let queryData = {
33097
33334
  param: {
@@ -33151,7 +33388,49 @@ function generateUniqueId() {
33151
33388
  return `i18n_${Date.now()}_${window.idCounter++}`;
33152
33389
  }
33153
33390
 
33154
- // 处理单个DOM元素的函数
33391
+ /**
33392
+ * 检查平台特定元素并返回匹配结果
33393
+ * @param {*} element
33394
+ * @returns
33395
+ */
33396
+ function checkPlatformElement(element) {
33397
+ const checkResult = {
33398
+ result: false,
33399
+ innerHTMLMatch: null
33400
+ };
33401
+ let checkArr = [check, catalog_i18n_check];
33402
+ for (let i = 0; i < checkArr.length; i++) {
33403
+ let checkFunc = checkArr[i];
33404
+ let checkResult = checkFunc(element);
33405
+ if (checkResult.result) {
33406
+ return checkResult;
33407
+ }
33408
+ }
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;
33431
+ }
33432
+
33433
+ // 处理DOM元素的函数
33155
33434
  function processElement(element) {
33156
33435
  if (element.nodeType != 1) {
33157
33436
  return false;
@@ -33163,71 +33442,71 @@ function processElement(element) {
33163
33442
  for (let i = 0; i < children.length; i++) {
33164
33443
  processElement(children[i]);
33165
33444
  }
33166
- // 检查是否是input元素
33167
- const isButtonElement = element.tagName === "BUTTON";
33168
- if (!isButtonElement) {
33445
+
33446
+ // 检查父亲性质节点是否需要被过滤
33447
+ const isParentNodeNeedFilter = checkParantNodeNeedFiller(element);
33448
+ if (isParentNodeNeedFilter) {
33169
33449
  return false;
33170
33450
  }
33171
33451
  }
33172
33452
  // element.setAttribute("i18nProcessed", "true"); // 标记元素已被处理
33173
- // 检查是否是input元素
33174
- const isInputElement = element.tagName === "INPUT";
33175
33453
  // 检查placeholder是否匹配
33176
33454
  const placeholder = element.getAttribute("placeholder") || element.placeholder;
33177
- const placeholderMatch = isInputElement && placeholder ? checkTextFormat(placeholder) : null;
33178
-
33179
- // 检查value是否匹配(仅对按钮类型的input)
33180
- const value = element.getAttribute("value") || element.value;
33181
- const valueMatch = isInputElement && value ? checkTextFormat(value) : null;
33455
+ const placeholderMatch = placeholder ? checkTextFormat(placeholder) : null;
33456
+ const title = element.getAttribute("title") || element.title;
33457
+ const titleMatch = title ? checkTextFormat(title) : null;
33182
33458
 
33183
33459
  // 检查innerHTML是否匹配(仅对没有子元素的元素)
33184
33460
  let innerHTMLMatch = null;
33185
- // if (!hasChildren) {
33186
33461
  const innerHTML = element.innerHTML;
33187
33462
  innerHTMLMatch = checkTextFormat(innerHTML);
33188
- // }
33463
+
33464
+ //检查是否是smardaten平台元素
33465
+ const checkResult = checkPlatformElement(element);
33466
+ if (checkResult.result) {
33467
+ innerHTMLMatch = checkResult.innerHTMLMatch;
33468
+ }
33189
33469
 
33190
33470
  // 如果没有匹配的内容,则不处理
33191
- if (!placeholderMatch && !valueMatch && !innerHTMLMatch) {
33471
+ if (!placeholderMatch && !innerHTMLMatch && !checkResult.result && !titleMatch) {
33192
33472
  return false;
33193
33473
  }
33194
- const elementId = generateUniqueId();
33474
+ let elementId = element.getAttribute("localDomID");
33475
+ if (!elementId) {
33476
+ elementId = generateUniqueId();
33477
+ }
33195
33478
  element.setAttribute("localDomID", elementId);
33196
- console.log("处理元素:", element, {
33197
- placeholderMatch,
33198
- valueMatch,
33199
- innerHTMLMatch
33200
- });
33479
+
33480
+ // console.log("处理元素:", element, {
33481
+ // placeholderMatch,
33482
+ // valueMatch,
33483
+ // innerHTMLMatch,
33484
+ // });
33201
33485
  // 处理placeholder
33202
33486
  if (placeholderMatch) {
33203
- element.setAttribute("localPlaceholderKey", placeholderMatch.key);
33204
33487
  element.setAttribute("oldPlaceholderValue", placeholder);
33205
33488
  }
33206
-
33207
- // 处理value
33208
- if (valueMatch) {
33209
- element.setAttribute("localValueKey", valueMatch.key);
33210
- element.setAttribute("oldValueValue", value);
33489
+ if (titleMatch) {
33490
+ element.setAttribute("oldTitleValue", title);
33211
33491
  }
33212
33492
 
33213
33493
  // 处理innerHTML(仅对没有子元素的元素)
33214
- if (innerHTMLMatch) {
33215
- element.setAttribute("localKey", innerHTMLMatch.key);
33494
+ if (!hasChildren && innerHTMLMatch) {
33216
33495
  element.setAttribute("oldValue", element.innerHTML);
33217
33496
  }
33497
+ if (checkResult.result) {
33498
+ element.setAttribute("oldValue", innerHTMLMatch.oldValue);
33499
+ }
33218
33500
 
33219
33501
  // 添加到Map缓存
33220
33502
  window.i18nElementsMap.set(elementId, {
33221
33503
  dom: element,
33222
33504
  id: elementId,
33223
- key: innerHTMLMatch ? innerHTMLMatch.key : null,
33224
- placeholderKey: placeholderMatch ? placeholderMatch.key : null,
33225
- valueKey: valueMatch ? valueMatch.key : null,
33226
33505
  oldValue: innerHTMLMatch ? element.innerHTML : null,
33227
33506
  oldPlaceholderValue: placeholderMatch ? placeholder : null,
33228
- oldValueValue: valueMatch ? value : null,
33229
- isInputElement: isInputElement
33230
- // hasChildren: hasChildren,
33507
+ oldTitleValue: titleMatch ? title : null,
33508
+ isScriptOldValue: innerHTMLMatch ? innerHTMLMatch.isScriptOldValue || false : false,
33509
+ scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null
33231
33510
  });
33232
33511
  applyTranslation(element);
33233
33512
  return true;
@@ -33262,10 +33541,9 @@ const applyTranslation = async element => {
33262
33541
  const cachedItem = window.i18nElementsMap.get(elementId);
33263
33542
  if (!cachedItem) return;
33264
33543
  // 处理placeholder(如果是input元素)
33265
- if (cachedItem.isInputElement && cachedItem.placeholderKey) {
33266
- const placeholderKey = element.getAttribute("localPlaceholderKey");
33544
+ if (cachedItem.oldPlaceholderValue) {
33267
33545
  const oldPlaceholderValue = element.getAttribute("oldPlaceholderValue");
33268
- if (placeholderKey && oldPlaceholderValue) {
33546
+ if (oldPlaceholderValue) {
33269
33547
  // 创建正则表达式匹配所有 $L{...} 格式
33270
33548
  const regex = /\$L\{([^}]+)\}/g;
33271
33549
  // 替换所有 $L{...} 占位符为翻译文本
@@ -33281,50 +33559,47 @@ const applyTranslation = async element => {
33281
33559
  element.setAttribute("placeholder", newPlaceholderValue);
33282
33560
  }
33283
33561
  }
33284
-
33285
- // 处理value(如果是input元素)
33286
- if (cachedItem.isInputElement && cachedItem.valueKey) {
33287
- const valueKey = element.getAttribute("localValueKey");
33288
- const oldValueValue = element.getAttribute("oldValueValue");
33289
- if (valueKey && oldValueValue) {
33562
+ if (cachedItem.oldTitleValue) {
33563
+ const oldTitleValue = element.getAttribute("oldTitleValue");
33564
+ if (oldTitleValue) {
33290
33565
  // 创建正则表达式匹配所有 $L{...} 格式
33291
33566
  const regex = /\$L\{([^}]+)\}/g;
33292
-
33293
33567
  // 替换所有 $L{...} 占位符为翻译文本
33294
- let newValueValue = oldValueValue;
33568
+ let newTitleValue = oldTitleValue;
33295
33569
  let match;
33296
- while ((match = regex.exec(oldValueValue)) !== null) {
33570
+ while ((match = regex.exec(oldTitleValue)) !== null) {
33297
33571
  const fullMatch = match[0];
33298
- const valueKey = match[1];
33299
- const translation = i18n(valueKey, appID, lang);
33300
- newValueValue = newValueValue.replace(fullMatch, translation);
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);
33301
33577
  }
33302
-
33303
- // 更新元素的value属性
33304
- element.setAttribute("value", newValueValue);
33305
33578
  }
33306
33579
  }
33307
-
33308
- // 处理innerHTML
33309
- if (cachedItem.key) {
33310
- const key = element.getAttribute("localKey");
33311
- const oldValue = element.getAttribute("oldValue");
33312
- if (key && oldValue) {
33313
- // 创建正则表达式匹配所有 $L{...} 格式
33314
- const regex = /\$L\{([^}]+)\}/g;
33315
-
33316
- // 替换所有 $L{...} 占位符为翻译文本
33317
- let newValue = oldValue;
33318
- let match;
33319
- while ((match = regex.exec(oldValue)) !== null) {
33320
- const fullMatch = match[0];
33321
- const placeholderKey = match[1];
33322
- const translation = i18n(placeholderKey, appID, lang);
33323
- newValue = newValue.replace(fullMatch, translation);
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
+ });
33324
33602
  }
33325
-
33326
- // 更新元素的innerHTML
33327
- element.innerHTML = newValue;
33328
33603
  }
33329
33604
  }
33330
33605
  };
@@ -33334,8 +33609,7 @@ const initDomNodeI18NObserver = () => {
33334
33609
  } else {
33335
33610
  window.i18nElementsMap.clear();
33336
33611
  }
33337
- registerEventListener("IPORTAL_LANGUAGE_CHANGE_EVENT", async data => {
33338
- const lang = data.lang;
33612
+ registerEventListener("IPORTAL_LANGUAGE_CHANGE_EVENT", async lang => {
33339
33613
  console.log("语言切换事件触发,更新已处理元素的翻译:", lang);
33340
33614
  // 遍历Map,更新每个已处理元素的翻译
33341
33615
  for (const [elementId, item] of window.i18nElementsMap.entries()) {
@@ -33353,7 +33627,6 @@ const initDomNodeI18NObserver = () => {
33353
33627
  processElement(node);
33354
33628
  }
33355
33629
  }
33356
-
33357
33630
  // 节点移除
33358
33631
  if (mutation.removedNodes.length > 0) {
33359
33632
  for (let i = 0; i < mutation.removedNodes.length; i++) {
@@ -33361,6 +33634,16 @@ const initDomNodeI18NObserver = () => {
33361
33634
  unProcessElement(node);
33362
33635
  }
33363
33636
  }
33637
+ if (mutation.type === 'characterData') {
33638
+ // 处理文本变化
33639
+ // const oldValue = mutation.oldValue;
33640
+ const targetNode = mutation.target;
33641
+ // const newValue = targetNode.data;
33642
+ // 创建日志条目并显示
33643
+ // console.log(`文本修改: ${oldValue} → ${newValue}`);
33644
+ const parentElement = targetNode.parentNode;
33645
+ processElement(parentElement);
33646
+ }
33364
33647
  });
33365
33648
  });
33366
33649
 
@@ -33372,7 +33655,9 @@ const initDomNodeI18NObserver = () => {
33372
33655
  // 观察所有后代节点
33373
33656
  attributes: false,
33374
33657
  // 不观察属性变化
33375
- characterData: false // 不观察文本内容变化
33658
+ characterData: true,
33659
+ // 不观察文本内容变化
33660
+ characterDataOldValue: true
33376
33661
  };
33377
33662
  // 开始观察目标节点
33378
33663
  const targetNode = document.body;