isdata-customer-sdk 0.1.97 → 0.1.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.common.js +357 -74
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +357 -74
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +4 -4
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -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,245 @@ const dify_extractFilenameFromUrl = url => {
|
|
|
33086
33087
|
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
33087
33088
|
}
|
|
33088
33089
|
};
|
|
33090
|
+
;// ./src/api/smardaten_i18n/table_i18n.js
|
|
33091
|
+
|
|
33092
|
+
const check = element => {
|
|
33093
|
+
const checkResult = {
|
|
33094
|
+
result: false,
|
|
33095
|
+
innerHTMLMatch: null
|
|
33096
|
+
};
|
|
33097
|
+
const classes = element.classList;
|
|
33098
|
+
// 检查表格头部 序号 和 操作 列
|
|
33099
|
+
if (classes.contains("ant-table-cell")) {
|
|
33100
|
+
let innerHTML = element.innerHTML;
|
|
33101
|
+
if (innerHTML.includes("序号") || innerHTML.includes("Serial No.")) {
|
|
33102
|
+
console.log("检查smardaten平台表格 序号 元素:", innerHTML);
|
|
33103
|
+
let tempHTMLMatch = {
|
|
33104
|
+
oldValue: '$L{PLATFORM_SERIAL_NO}'
|
|
33105
|
+
};
|
|
33106
|
+
checkResult.result = true;
|
|
33107
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33108
|
+
return checkResult;
|
|
33109
|
+
}
|
|
33110
|
+
if (innerHTML.includes("操作")) {
|
|
33111
|
+
console.log("检查smardaten平台表格 操作 元素:", innerHTML);
|
|
33112
|
+
let tempHTMLMatch = {
|
|
33113
|
+
oldValue: '$L{PLATFORM_OPERATE}'
|
|
33114
|
+
};
|
|
33115
|
+
checkResult.result = true;
|
|
33116
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33117
|
+
return checkResult;
|
|
33118
|
+
}
|
|
33119
|
+
}
|
|
33120
|
+
// 检查分页组件
|
|
33121
|
+
if (classes.contains("total_pag_num")) {
|
|
33122
|
+
let innerHTML = element.innerHTML;
|
|
33123
|
+
if (innerHTML.includes("共") && innerHTML.includes("条") || innerHTML.includes("Total") && innerHTML.includes("pieces")) {
|
|
33124
|
+
console.log("检查smardaten平台分页 共xx条 元素:", innerHTML);
|
|
33125
|
+
let scriptFunction = (appID, lang) => {
|
|
33126
|
+
let scriptNode = null;
|
|
33127
|
+
for (let node of element.childNodes) {
|
|
33128
|
+
// 检查是否为文本节点且包含"Total"
|
|
33129
|
+
if (node.tagName === "SPAN") {
|
|
33130
|
+
scriptNode = node;
|
|
33131
|
+
}
|
|
33132
|
+
}
|
|
33133
|
+
let scriptNodes = [{
|
|
33134
|
+
nodeType: Node.TEXT_NODE,
|
|
33135
|
+
key: 'PLATFORM_TOTAL'
|
|
33136
|
+
}, {
|
|
33137
|
+
nodeType: "SCRIPTNODE",
|
|
33138
|
+
node: scriptNode
|
|
33139
|
+
}, {
|
|
33140
|
+
nodeType: Node.TEXT_NODE,
|
|
33141
|
+
key: 'PLATFORM_PIECES'
|
|
33142
|
+
}];
|
|
33143
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33144
|
+
let childNode = element.childNodes[i];
|
|
33145
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
33146
|
+
element.removeChild(childNode);
|
|
33147
|
+
}
|
|
33148
|
+
}
|
|
33149
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
33150
|
+
let scriptNodeItem = scriptNodes[i];
|
|
33151
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33152
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
33153
|
+
element.appendChild(textNode);
|
|
33154
|
+
}
|
|
33155
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
33156
|
+
element.appendChild(scriptNodeItem.node);
|
|
33157
|
+
}
|
|
33158
|
+
}
|
|
33159
|
+
};
|
|
33160
|
+
let tempHTMLMatch = {
|
|
33161
|
+
isScriptOldValue: true,
|
|
33162
|
+
scriptFunction: scriptFunction
|
|
33163
|
+
};
|
|
33164
|
+
checkResult.result = true;
|
|
33165
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33166
|
+
return checkResult;
|
|
33167
|
+
}
|
|
33168
|
+
}
|
|
33169
|
+
// 检查分页组件 跳至xx页
|
|
33170
|
+
if (classes.contains("ant-pagination-options-quick-jumper")) {
|
|
33171
|
+
let innerHTML = element.innerHTML;
|
|
33172
|
+
if (innerHTML.includes("跳至") && innerHTML.includes("页") || innerHTML.includes("Go to") && innerHTML.includes("Page")) {
|
|
33173
|
+
console.log("检查smardaten平台分页 跳至xx页 元素:", innerHTML);
|
|
33174
|
+
let scriptFunction = (appID, lang) => {
|
|
33175
|
+
let scriptNode = null;
|
|
33176
|
+
for (let node of element.childNodes) {
|
|
33177
|
+
// 检查是否为文本节点且包含"Total"
|
|
33178
|
+
if (node.tagName === "INPUT") {
|
|
33179
|
+
scriptNode = node;
|
|
33180
|
+
}
|
|
33181
|
+
}
|
|
33182
|
+
let scriptNodes = [{
|
|
33183
|
+
nodeType: Node.TEXT_NODE,
|
|
33184
|
+
key: 'PLATFORM_JUNPTO'
|
|
33185
|
+
}, {
|
|
33186
|
+
nodeType: "SCRIPTNODE",
|
|
33187
|
+
node: scriptNode
|
|
33188
|
+
}, {
|
|
33189
|
+
nodeType: Node.TEXT_NODE,
|
|
33190
|
+
key: 'PLATFORM_PAGE'
|
|
33191
|
+
}];
|
|
33192
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33193
|
+
let childNode = element.childNodes[i];
|
|
33194
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
33195
|
+
element.removeChild(childNode);
|
|
33196
|
+
}
|
|
33197
|
+
}
|
|
33198
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
33199
|
+
let scriptNodeItem = scriptNodes[i];
|
|
33200
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33201
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
33202
|
+
element.appendChild(textNode);
|
|
33203
|
+
}
|
|
33204
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
33205
|
+
element.appendChild(scriptNodeItem.node);
|
|
33206
|
+
}
|
|
33207
|
+
}
|
|
33208
|
+
};
|
|
33209
|
+
let tempHTMLMatch = {
|
|
33210
|
+
isScriptOldValue: true,
|
|
33211
|
+
scriptFunction: scriptFunction
|
|
33212
|
+
};
|
|
33213
|
+
checkResult.result = true;
|
|
33214
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33215
|
+
return checkResult;
|
|
33216
|
+
}
|
|
33217
|
+
}
|
|
33218
|
+
// 检查每页xx条
|
|
33219
|
+
if (classes.contains("ant-select-selection-item") || classes.contains("ant-select-item-option-content")) {
|
|
33220
|
+
let innerHTML = element.innerHTML;
|
|
33221
|
+
console.log("检查smardaten平台分页 每页xx条 元素:", innerHTML);
|
|
33222
|
+
if (innerHTML.includes("/") && innerHTML.includes("page") || innerHTML.includes("/") && innerHTML.includes("条") && innerHTML.includes("页")) {
|
|
33223
|
+
let oldValue = element.innerHTML;
|
|
33224
|
+
if (innerHTML.includes("page")) {
|
|
33225
|
+
oldValue = oldValue.replace('page', '$L{PLATFORM_PAGE}');
|
|
33226
|
+
}
|
|
33227
|
+
if (innerHTML.includes("页")) {
|
|
33228
|
+
oldValue = oldValue.replace('页', '$L{PLATFORM_PAGE}');
|
|
33229
|
+
}
|
|
33230
|
+
if (innerHTML.includes("条")) {
|
|
33231
|
+
oldValue = oldValue.replace('条', '$L{PLATFORM_PIECES}');
|
|
33232
|
+
}
|
|
33233
|
+
let tempHTMLMatch = {
|
|
33234
|
+
oldValue: oldValue
|
|
33235
|
+
};
|
|
33236
|
+
checkResult.result = true;
|
|
33237
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33238
|
+
return checkResult;
|
|
33239
|
+
}
|
|
33240
|
+
}
|
|
33241
|
+
// 检查删除确认对话框标题
|
|
33242
|
+
if (classes.contains("ant-popover-message-title")) {
|
|
33243
|
+
let innerHTML = element.innerHTML;
|
|
33244
|
+
if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
|
|
33245
|
+
console.log("检查smardaten平台删除提问对话框:", innerHTML);
|
|
33246
|
+
let tempHTMLMatch = {
|
|
33247
|
+
oldValue: '$L{PLATFORM_DELETE_CONFIRM_TITLE}'
|
|
33248
|
+
};
|
|
33249
|
+
checkResult.result = true;
|
|
33250
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33251
|
+
return checkResult;
|
|
33252
|
+
}
|
|
33253
|
+
}
|
|
33254
|
+
// 检查删除确认对话框按钮 取消 确认
|
|
33255
|
+
if (classes.contains("ant-btn-sm")) {
|
|
33256
|
+
let innerHTML = element.innerHTML;
|
|
33257
|
+
if (innerHTML.includes("Cancel") || innerHTML.includes("取消")) {
|
|
33258
|
+
console.log("检查smardaten平台 Tip提问取消删除按钮:", innerHTML);
|
|
33259
|
+
let tempHTMLMatch = {
|
|
33260
|
+
oldValue: '$L{PLATFORM_CANCEL}'
|
|
33261
|
+
};
|
|
33262
|
+
checkResult.result = true;
|
|
33263
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33264
|
+
return checkResult;
|
|
33265
|
+
}
|
|
33266
|
+
if (innerHTML.includes("确认") || innerHTML.includes("OK")) {
|
|
33267
|
+
console.log("检查smardaten平台 Tip提问确认删除按钮:", innerHTML);
|
|
33268
|
+
let tempHTMLMatch = {
|
|
33269
|
+
oldValue: '$L{PLATFORM_OK}'
|
|
33270
|
+
};
|
|
33271
|
+
checkResult.result = true;
|
|
33272
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33273
|
+
return checkResult;
|
|
33274
|
+
}
|
|
33275
|
+
}
|
|
33276
|
+
return checkResult;
|
|
33277
|
+
};
|
|
33278
|
+
;// ./src/api/smardaten_i18n/catalog_i18n.js
|
|
33279
|
+
|
|
33280
|
+
const catalog_i18n_check = element => {
|
|
33281
|
+
const checkResult = {
|
|
33282
|
+
result: false,
|
|
33283
|
+
innerHTMLMatch: null
|
|
33284
|
+
};
|
|
33285
|
+
const classes = element.classList;
|
|
33286
|
+
// 检查目录列表 名称 列
|
|
33287
|
+
if (classes.contains("catalog_name_content")) {
|
|
33288
|
+
let innerHTML = element.innerHTML;
|
|
33289
|
+
let oldValue = innerHTML;
|
|
33290
|
+
console.log("检查smardaten平台目录列表 元素:", innerHTML);
|
|
33291
|
+
let scriptFunction = (appID, lang) => {
|
|
33292
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33293
|
+
let scriptNodeItem = element.childNodes[i];
|
|
33294
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33295
|
+
let text = element.getAttribute("oldValue");
|
|
33296
|
+
let isTextMatch = checkTextFormat(text);
|
|
33297
|
+
if (!isTextMatch) {
|
|
33298
|
+
element.appendChild(scriptNodeItem);
|
|
33299
|
+
} else {
|
|
33300
|
+
element.removeChild(scriptNodeItem);
|
|
33301
|
+
let key = isTextMatch.key;
|
|
33302
|
+
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
33303
|
+
element.appendChild(textNode);
|
|
33304
|
+
}
|
|
33305
|
+
} else {
|
|
33306
|
+
element.appendChild(scriptNodeItem);
|
|
33307
|
+
}
|
|
33308
|
+
}
|
|
33309
|
+
};
|
|
33310
|
+
let tempHTMLMatch = {
|
|
33311
|
+
oldValue: oldValue,
|
|
33312
|
+
isScriptOldValue: true,
|
|
33313
|
+
scriptFunction: scriptFunction
|
|
33314
|
+
};
|
|
33315
|
+
checkResult.result = true;
|
|
33316
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33317
|
+
return checkResult;
|
|
33318
|
+
}
|
|
33319
|
+
return checkResult;
|
|
33320
|
+
};
|
|
33089
33321
|
;// ./src/api/i18n.js
|
|
33090
33322
|
|
|
33091
33323
|
|
|
33092
33324
|
|
|
33093
33325
|
|
|
33094
33326
|
|
|
33327
|
+
|
|
33328
|
+
|
|
33095
33329
|
const getLanguages = async appID => {
|
|
33096
33330
|
let queryData = {
|
|
33097
33331
|
param: {
|
|
@@ -33151,7 +33385,49 @@ function generateUniqueId() {
|
|
|
33151
33385
|
return `i18n_${Date.now()}_${window.idCounter++}`;
|
|
33152
33386
|
}
|
|
33153
33387
|
|
|
33154
|
-
|
|
33388
|
+
/**
|
|
33389
|
+
* 检查平台特定元素并返回匹配结果
|
|
33390
|
+
* @param {*} element
|
|
33391
|
+
* @returns
|
|
33392
|
+
*/
|
|
33393
|
+
function checkPlatformElement(element) {
|
|
33394
|
+
const checkResult = {
|
|
33395
|
+
result: false,
|
|
33396
|
+
innerHTMLMatch: null
|
|
33397
|
+
};
|
|
33398
|
+
let checkArr = [check, catalog_i18n_check];
|
|
33399
|
+
for (let i = 0; i < checkArr.length; i++) {
|
|
33400
|
+
let checkFunc = checkArr[i];
|
|
33401
|
+
let checkResult = checkFunc(element);
|
|
33402
|
+
if (checkResult.result) {
|
|
33403
|
+
return checkResult;
|
|
33404
|
+
}
|
|
33405
|
+
}
|
|
33406
|
+
return checkResult;
|
|
33407
|
+
}
|
|
33408
|
+
function checkParantNodeNeedFiller(element) {
|
|
33409
|
+
const filterTags = ["BUTTON"];
|
|
33410
|
+
for (let tag of filterTags) {
|
|
33411
|
+
if (element.tagName === tag) {
|
|
33412
|
+
return false;
|
|
33413
|
+
}
|
|
33414
|
+
}
|
|
33415
|
+
//当为目录列表时catalog_name_content
|
|
33416
|
+
//当为表格单元格时ant-table-cell
|
|
33417
|
+
//当为分页总数时total_pag_num
|
|
33418
|
+
//当为分页每页条数选择时ant-pagination-options-quick-jumper
|
|
33419
|
+
//当为分页下拉选择时ant-select-selection-item
|
|
33420
|
+
//当为分页下拉选项时ant-select-item-option-content
|
|
33421
|
+
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"];
|
|
33422
|
+
for (let cls of classes) {
|
|
33423
|
+
if (element.classList.contains(cls)) {
|
|
33424
|
+
return false;
|
|
33425
|
+
}
|
|
33426
|
+
}
|
|
33427
|
+
return true;
|
|
33428
|
+
}
|
|
33429
|
+
|
|
33430
|
+
// 处理DOM元素的函数
|
|
33155
33431
|
function processElement(element) {
|
|
33156
33432
|
if (element.nodeType != 1) {
|
|
33157
33433
|
return false;
|
|
@@ -33163,71 +33439,71 @@ function processElement(element) {
|
|
|
33163
33439
|
for (let i = 0; i < children.length; i++) {
|
|
33164
33440
|
processElement(children[i]);
|
|
33165
33441
|
}
|
|
33166
|
-
|
|
33167
|
-
|
|
33168
|
-
|
|
33442
|
+
|
|
33443
|
+
// 检查父亲性质节点是否需要被过滤
|
|
33444
|
+
const isParentNodeNeedFilter = checkParantNodeNeedFiller(element);
|
|
33445
|
+
if (isParentNodeNeedFilter) {
|
|
33169
33446
|
return false;
|
|
33170
33447
|
}
|
|
33171
33448
|
}
|
|
33172
33449
|
// element.setAttribute("i18nProcessed", "true"); // 标记元素已被处理
|
|
33173
|
-
// 检查是否是input元素
|
|
33174
|
-
const isInputElement = element.tagName === "INPUT";
|
|
33175
33450
|
// 检查placeholder是否匹配
|
|
33176
33451
|
const placeholder = element.getAttribute("placeholder") || element.placeholder;
|
|
33177
|
-
const placeholderMatch =
|
|
33178
|
-
|
|
33179
|
-
|
|
33180
|
-
const value = element.getAttribute("value") || element.value;
|
|
33181
|
-
const valueMatch = isInputElement && value ? checkTextFormat(value) : null;
|
|
33452
|
+
const placeholderMatch = placeholder ? checkTextFormat(placeholder) : null;
|
|
33453
|
+
const title = element.getAttribute("title") || element.title;
|
|
33454
|
+
const titleMatch = title ? checkTextFormat(title) : null;
|
|
33182
33455
|
|
|
33183
33456
|
// 检查innerHTML是否匹配(仅对没有子元素的元素)
|
|
33184
33457
|
let innerHTMLMatch = null;
|
|
33185
|
-
// if (!hasChildren) {
|
|
33186
33458
|
const innerHTML = element.innerHTML;
|
|
33187
33459
|
innerHTMLMatch = checkTextFormat(innerHTML);
|
|
33188
|
-
|
|
33460
|
+
|
|
33461
|
+
//检查是否是smardaten平台元素
|
|
33462
|
+
const checkResult = checkPlatformElement(element);
|
|
33463
|
+
if (checkResult.result) {
|
|
33464
|
+
innerHTMLMatch = checkResult.innerHTMLMatch;
|
|
33465
|
+
}
|
|
33189
33466
|
|
|
33190
33467
|
// 如果没有匹配的内容,则不处理
|
|
33191
|
-
if (!placeholderMatch && !
|
|
33468
|
+
if (!placeholderMatch && !innerHTMLMatch && !checkResult.result && !titleMatch) {
|
|
33192
33469
|
return false;
|
|
33193
33470
|
}
|
|
33194
|
-
|
|
33471
|
+
let elementId = element.getAttribute("localDomID");
|
|
33472
|
+
if (!elementId) {
|
|
33473
|
+
elementId = generateUniqueId();
|
|
33474
|
+
}
|
|
33195
33475
|
element.setAttribute("localDomID", elementId);
|
|
33196
|
-
|
|
33197
|
-
|
|
33198
|
-
|
|
33199
|
-
|
|
33200
|
-
|
|
33476
|
+
|
|
33477
|
+
// console.log("处理元素:", element, {
|
|
33478
|
+
// placeholderMatch,
|
|
33479
|
+
// valueMatch,
|
|
33480
|
+
// innerHTMLMatch,
|
|
33481
|
+
// });
|
|
33201
33482
|
// 处理placeholder
|
|
33202
33483
|
if (placeholderMatch) {
|
|
33203
|
-
element.setAttribute("localPlaceholderKey", placeholderMatch.key);
|
|
33204
33484
|
element.setAttribute("oldPlaceholderValue", placeholder);
|
|
33205
33485
|
}
|
|
33206
|
-
|
|
33207
|
-
|
|
33208
|
-
if (valueMatch) {
|
|
33209
|
-
element.setAttribute("localValueKey", valueMatch.key);
|
|
33210
|
-
element.setAttribute("oldValueValue", value);
|
|
33486
|
+
if (titleMatch) {
|
|
33487
|
+
element.setAttribute("oldTitleValue", title);
|
|
33211
33488
|
}
|
|
33212
33489
|
|
|
33213
33490
|
// 处理innerHTML(仅对没有子元素的元素)
|
|
33214
|
-
if (innerHTMLMatch) {
|
|
33215
|
-
element.setAttribute("localKey", innerHTMLMatch.key);
|
|
33491
|
+
if (!hasChildren && innerHTMLMatch) {
|
|
33216
33492
|
element.setAttribute("oldValue", element.innerHTML);
|
|
33217
33493
|
}
|
|
33494
|
+
if (checkResult.result) {
|
|
33495
|
+
element.setAttribute("oldValue", innerHTMLMatch.oldValue);
|
|
33496
|
+
}
|
|
33218
33497
|
|
|
33219
33498
|
// 添加到Map缓存
|
|
33220
33499
|
window.i18nElementsMap.set(elementId, {
|
|
33221
33500
|
dom: element,
|
|
33222
33501
|
id: elementId,
|
|
33223
|
-
key: innerHTMLMatch ? innerHTMLMatch.key : null,
|
|
33224
|
-
placeholderKey: placeholderMatch ? placeholderMatch.key : null,
|
|
33225
|
-
valueKey: valueMatch ? valueMatch.key : null,
|
|
33226
33502
|
oldValue: innerHTMLMatch ? element.innerHTML : null,
|
|
33227
33503
|
oldPlaceholderValue: placeholderMatch ? placeholder : null,
|
|
33228
|
-
|
|
33229
|
-
|
|
33230
|
-
|
|
33504
|
+
oldTitleValue: titleMatch ? title : null,
|
|
33505
|
+
isScriptOldValue: innerHTMLMatch ? innerHTMLMatch.isScriptOldValue || false : false,
|
|
33506
|
+
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null
|
|
33231
33507
|
});
|
|
33232
33508
|
applyTranslation(element);
|
|
33233
33509
|
return true;
|
|
@@ -33262,10 +33538,9 @@ const applyTranslation = async element => {
|
|
|
33262
33538
|
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
33263
33539
|
if (!cachedItem) return;
|
|
33264
33540
|
// 处理placeholder(如果是input元素)
|
|
33265
|
-
if (cachedItem.
|
|
33266
|
-
const placeholderKey = element.getAttribute("localPlaceholderKey");
|
|
33541
|
+
if (cachedItem.oldPlaceholderValue) {
|
|
33267
33542
|
const oldPlaceholderValue = element.getAttribute("oldPlaceholderValue");
|
|
33268
|
-
if (
|
|
33543
|
+
if (oldPlaceholderValue) {
|
|
33269
33544
|
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33270
33545
|
const regex = /\$L\{([^}]+)\}/g;
|
|
33271
33546
|
// 替换所有 $L{...} 占位符为翻译文本
|
|
@@ -33281,50 +33556,47 @@ const applyTranslation = async element => {
|
|
|
33281
33556
|
element.setAttribute("placeholder", newPlaceholderValue);
|
|
33282
33557
|
}
|
|
33283
33558
|
}
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
const valueKey = element.getAttribute("localValueKey");
|
|
33288
|
-
const oldValueValue = element.getAttribute("oldValueValue");
|
|
33289
|
-
if (valueKey && oldValueValue) {
|
|
33559
|
+
if (cachedItem.oldTitleValue) {
|
|
33560
|
+
const oldTitleValue = element.getAttribute("oldTitleValue");
|
|
33561
|
+
if (oldTitleValue) {
|
|
33290
33562
|
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33291
33563
|
const regex = /\$L\{([^}]+)\}/g;
|
|
33292
|
-
|
|
33293
33564
|
// 替换所有 $L{...} 占位符为翻译文本
|
|
33294
|
-
let
|
|
33565
|
+
let newTitleValue = oldTitleValue;
|
|
33295
33566
|
let match;
|
|
33296
|
-
while ((match = regex.exec(
|
|
33567
|
+
while ((match = regex.exec(oldTitleValue)) !== null) {
|
|
33297
33568
|
const fullMatch = match[0];
|
|
33298
|
-
const
|
|
33299
|
-
const translation = i18n(
|
|
33300
|
-
|
|
33569
|
+
const titleKey = match[1];
|
|
33570
|
+
const translation = i18n(titleKey, appID, lang);
|
|
33571
|
+
newTitleValue = newTitleValue.replace(fullMatch, translation);
|
|
33572
|
+
// 更新元素的title属性
|
|
33573
|
+
element.setAttribute("title", newTitleValue);
|
|
33301
33574
|
}
|
|
33302
|
-
|
|
33303
|
-
// 更新元素的value属性
|
|
33304
|
-
element.setAttribute("value", newValueValue);
|
|
33305
33575
|
}
|
|
33306
33576
|
}
|
|
33307
|
-
|
|
33308
|
-
|
|
33309
|
-
|
|
33310
|
-
|
|
33311
|
-
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
|
|
33316
|
-
|
|
33317
|
-
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
|
|
33323
|
-
|
|
33577
|
+
// console.log("更新innerHTML翻译:", element);
|
|
33578
|
+
if (cachedItem.isScriptOldValue) {
|
|
33579
|
+
cachedItem.scriptFunction(appID, lang);
|
|
33580
|
+
} else {
|
|
33581
|
+
if (cachedItem.oldValue) {
|
|
33582
|
+
const oldValue = element.getAttribute("oldValue");
|
|
33583
|
+
if (oldValue) {
|
|
33584
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33585
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33586
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
33587
|
+
let newValue = oldValue;
|
|
33588
|
+
let match;
|
|
33589
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
33590
|
+
const fullMatch = match[0];
|
|
33591
|
+
const placeholderKey = match[1];
|
|
33592
|
+
const translation = i18n(placeholderKey, appID, lang);
|
|
33593
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
33594
|
+
}
|
|
33595
|
+
nextTick(() => {
|
|
33596
|
+
// 更新元素的innerHTML
|
|
33597
|
+
element.innerHTML = newValue;
|
|
33598
|
+
});
|
|
33324
33599
|
}
|
|
33325
|
-
|
|
33326
|
-
// 更新元素的innerHTML
|
|
33327
|
-
element.innerHTML = newValue;
|
|
33328
33600
|
}
|
|
33329
33601
|
}
|
|
33330
33602
|
};
|
|
@@ -33352,7 +33624,6 @@ const initDomNodeI18NObserver = () => {
|
|
|
33352
33624
|
processElement(node);
|
|
33353
33625
|
}
|
|
33354
33626
|
}
|
|
33355
|
-
|
|
33356
33627
|
// 节点移除
|
|
33357
33628
|
if (mutation.removedNodes.length > 0) {
|
|
33358
33629
|
for (let i = 0; i < mutation.removedNodes.length; i++) {
|
|
@@ -33360,6 +33631,16 @@ const initDomNodeI18NObserver = () => {
|
|
|
33360
33631
|
unProcessElement(node);
|
|
33361
33632
|
}
|
|
33362
33633
|
}
|
|
33634
|
+
if (mutation.type === 'characterData') {
|
|
33635
|
+
// 处理文本变化
|
|
33636
|
+
// const oldValue = mutation.oldValue;
|
|
33637
|
+
const targetNode = mutation.target;
|
|
33638
|
+
// const newValue = targetNode.data;
|
|
33639
|
+
// 创建日志条目并显示
|
|
33640
|
+
// console.log(`文本修改: ${oldValue} → ${newValue}`);
|
|
33641
|
+
const parentElement = targetNode.parentNode;
|
|
33642
|
+
processElement(parentElement);
|
|
33643
|
+
}
|
|
33363
33644
|
});
|
|
33364
33645
|
});
|
|
33365
33646
|
|
|
@@ -33371,7 +33652,9 @@ const initDomNodeI18NObserver = () => {
|
|
|
33371
33652
|
// 观察所有后代节点
|
|
33372
33653
|
attributes: false,
|
|
33373
33654
|
// 不观察属性变化
|
|
33374
|
-
characterData:
|
|
33655
|
+
characterData: true,
|
|
33656
|
+
// 不观察文本内容变化
|
|
33657
|
+
characterDataOldValue: true
|
|
33375
33658
|
};
|
|
33376
33659
|
// 开始观察目标节点
|
|
33377
33660
|
const targetNode = document.body;
|