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.
- package/dist/index.common.js +150 -130
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +150 -130
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +3 -3
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -33107,7 +33107,7 @@ const dify_extractFilenameFromUrl = url => {
|
|
|
33107
33107
|
};
|
|
33108
33108
|
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
|
|
33109
33109
|
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(9274);
|
|
33110
|
-
;// ./src/api/smardaten_i18n/table_i18n.js
|
|
33110
|
+
;// ./src/api/i18n/smardaten_i18n/table_i18n.js
|
|
33111
33111
|
|
|
33112
33112
|
const check = element => {
|
|
33113
33113
|
const checkResult = {
|
|
@@ -33137,6 +33137,19 @@ const check = element => {
|
|
|
33137
33137
|
return checkResult;
|
|
33138
33138
|
}
|
|
33139
33139
|
}
|
|
33140
|
+
// 检查分页组件 导出按钮
|
|
33141
|
+
if (classes.contains("export_menu")) {
|
|
33142
|
+
let innerHTML = element.innerHTML;
|
|
33143
|
+
if (innerHTML.includes("导出进度") || innerHTML.includes("Export progress")) {
|
|
33144
|
+
console.log("检查smardaten平台表格 导出按钮 元素:", innerHTML);
|
|
33145
|
+
let tempHTMLMatch = {
|
|
33146
|
+
oldValue: '$L{PLATFORM_EXPORT_ALL}'
|
|
33147
|
+
};
|
|
33148
|
+
checkResult.result = true;
|
|
33149
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33150
|
+
return checkResult;
|
|
33151
|
+
}
|
|
33152
|
+
}
|
|
33140
33153
|
// 检查分页组件
|
|
33141
33154
|
if (classes.contains("total_pag_num")) {
|
|
33142
33155
|
let innerHTML = element.innerHTML;
|
|
@@ -33178,7 +33191,7 @@ const check = element => {
|
|
|
33178
33191
|
}
|
|
33179
33192
|
};
|
|
33180
33193
|
let tempHTMLMatch = {
|
|
33181
|
-
|
|
33194
|
+
isScriptAction: true,
|
|
33182
33195
|
scriptFunction: scriptFunction
|
|
33183
33196
|
};
|
|
33184
33197
|
checkResult.result = true;
|
|
@@ -33227,7 +33240,7 @@ const check = element => {
|
|
|
33227
33240
|
}
|
|
33228
33241
|
};
|
|
33229
33242
|
let tempHTMLMatch = {
|
|
33230
|
-
|
|
33243
|
+
isScriptAction: true,
|
|
33231
33244
|
scriptFunction: scriptFunction
|
|
33232
33245
|
};
|
|
33233
33246
|
checkResult.result = true;
|
|
@@ -33295,7 +33308,7 @@ const check = element => {
|
|
|
33295
33308
|
}
|
|
33296
33309
|
return checkResult;
|
|
33297
33310
|
};
|
|
33298
|
-
;// ./src/api/smardaten_i18n/catalog_i18n.js
|
|
33311
|
+
;// ./src/api/i18n/smardaten_i18n/catalog_i18n.js
|
|
33299
33312
|
|
|
33300
33313
|
const catalog_i18n_check = element => {
|
|
33301
33314
|
const checkResult = {
|
|
@@ -33329,7 +33342,49 @@ const catalog_i18n_check = element => {
|
|
|
33329
33342
|
};
|
|
33330
33343
|
let tempHTMLMatch = {
|
|
33331
33344
|
oldValue: oldValue,
|
|
33332
|
-
|
|
33345
|
+
isScriptAction: true,
|
|
33346
|
+
scriptFunction: scriptFunction
|
|
33347
|
+
};
|
|
33348
|
+
checkResult.result = true;
|
|
33349
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33350
|
+
return checkResult;
|
|
33351
|
+
}
|
|
33352
|
+
return checkResult;
|
|
33353
|
+
};
|
|
33354
|
+
;// ./src/api/i18n/commom_i18n/common_i18n.js
|
|
33355
|
+
|
|
33356
|
+
const common_i18n_check = element => {
|
|
33357
|
+
const checkResult = {
|
|
33358
|
+
result: false,
|
|
33359
|
+
innerHTMLMatch: null
|
|
33360
|
+
};
|
|
33361
|
+
// 检查目录列表 名称 列
|
|
33362
|
+
if (element.tagName === 'BUTTON') {
|
|
33363
|
+
let innerHTML = element.innerHTML;
|
|
33364
|
+
let oldValue = innerHTML;
|
|
33365
|
+
console.log("检查 button 元素:", innerHTML);
|
|
33366
|
+
let scriptFunction = (appID, lang) => {
|
|
33367
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33368
|
+
let scriptNodeItem = element.childNodes[i];
|
|
33369
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33370
|
+
let text = element.getAttribute("oldValue");
|
|
33371
|
+
let isTextMatch = checkTextFormat(text);
|
|
33372
|
+
if (!isTextMatch) {
|
|
33373
|
+
element.appendChild(scriptNodeItem);
|
|
33374
|
+
} else {
|
|
33375
|
+
element.removeChild(scriptNodeItem);
|
|
33376
|
+
let key = isTextMatch.key;
|
|
33377
|
+
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
33378
|
+
element.appendChild(textNode);
|
|
33379
|
+
}
|
|
33380
|
+
} else {
|
|
33381
|
+
element.appendChild(scriptNodeItem);
|
|
33382
|
+
}
|
|
33383
|
+
}
|
|
33384
|
+
};
|
|
33385
|
+
let tempHTMLMatch = {
|
|
33386
|
+
oldValue: oldValue,
|
|
33387
|
+
isScriptAction: true,
|
|
33333
33388
|
scriptFunction: scriptFunction
|
|
33334
33389
|
};
|
|
33335
33390
|
checkResult.result = true;
|
|
@@ -33338,7 +33393,51 @@ const catalog_i18n_check = element => {
|
|
|
33338
33393
|
}
|
|
33339
33394
|
return checkResult;
|
|
33340
33395
|
};
|
|
33341
|
-
;// ./src/api/i18n.js
|
|
33396
|
+
;// ./src/api/i18n/commom_i18n/attribute_i18n.js
|
|
33397
|
+
|
|
33398
|
+
const attribute_i18n_check = element => {
|
|
33399
|
+
const checkResult = {
|
|
33400
|
+
result: false,
|
|
33401
|
+
innerHTMLMatch: null
|
|
33402
|
+
};
|
|
33403
|
+
const checkAttributes = ["placeholder", "title"];
|
|
33404
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
33405
|
+
let attr = checkAttributes[i];
|
|
33406
|
+
let attrValue = element.getAttribute(attr) || element[attr];
|
|
33407
|
+
const attrMatch = attrValue ? checkTextFormat(attrValue) : null;
|
|
33408
|
+
if (attrMatch) {
|
|
33409
|
+
console.log("检查元素属性 i18n 元素:", attr, attrValue);
|
|
33410
|
+
element.setAttribute(`old${attr}Value`, attrValue);
|
|
33411
|
+
checkResult.result = true;
|
|
33412
|
+
}
|
|
33413
|
+
}
|
|
33414
|
+
let scriptFunction = (appID, lang) => {
|
|
33415
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
33416
|
+
let attr = checkAttributes[i];
|
|
33417
|
+
const oldAttrValue = element.getAttribute(`old${attr}Value`);
|
|
33418
|
+
if (oldAttrValue) {
|
|
33419
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33420
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33421
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
33422
|
+
let newAttrValue = oldAttrValue;
|
|
33423
|
+
let match;
|
|
33424
|
+
while ((match = regex.exec(oldAttrValue)) !== null) {
|
|
33425
|
+
const fullMatch = match[0];
|
|
33426
|
+
const attrKey = match[1];
|
|
33427
|
+
const translation = i18n(attrKey, appID, lang);
|
|
33428
|
+
newAttrValue = newAttrValue.replace(fullMatch, translation);
|
|
33429
|
+
}
|
|
33430
|
+
// 更新元素的placeholder属性
|
|
33431
|
+
element.setAttribute(attr, newAttrValue);
|
|
33432
|
+
}
|
|
33433
|
+
}
|
|
33434
|
+
};
|
|
33435
|
+
checkResult.scriptFunction = scriptFunction;
|
|
33436
|
+
return checkResult;
|
|
33437
|
+
};
|
|
33438
|
+
;// ./src/api/i18n/i18n.js
|
|
33439
|
+
|
|
33440
|
+
|
|
33342
33441
|
|
|
33343
33442
|
|
|
33344
33443
|
|
|
@@ -33411,41 +33510,20 @@ function generateUniqueId() {
|
|
|
33411
33510
|
* @param {*} element
|
|
33412
33511
|
* @returns
|
|
33413
33512
|
*/
|
|
33414
|
-
function
|
|
33415
|
-
const
|
|
33513
|
+
function checkPlatformElementContent(element) {
|
|
33514
|
+
const checkContentResult = {
|
|
33416
33515
|
result: false,
|
|
33417
33516
|
innerHTMLMatch: null
|
|
33418
33517
|
};
|
|
33419
|
-
let checkArr = [check, catalog_i18n_check];
|
|
33518
|
+
let checkArr = [check, catalog_i18n_check, common_i18n_check];
|
|
33420
33519
|
for (let i = 0; i < checkArr.length; i++) {
|
|
33421
33520
|
let checkFunc = checkArr[i];
|
|
33422
|
-
let
|
|
33423
|
-
if (
|
|
33424
|
-
return
|
|
33521
|
+
let checkContentResult = checkFunc(element);
|
|
33522
|
+
if (checkContentResult.result) {
|
|
33523
|
+
return checkContentResult;
|
|
33425
33524
|
}
|
|
33426
33525
|
}
|
|
33427
|
-
return
|
|
33428
|
-
}
|
|
33429
|
-
function checkParantNodeNeedFiller(element) {
|
|
33430
|
-
const filterTags = ["BUTTON"];
|
|
33431
|
-
for (let tag of filterTags) {
|
|
33432
|
-
if (element.tagName === tag) {
|
|
33433
|
-
return false;
|
|
33434
|
-
}
|
|
33435
|
-
}
|
|
33436
|
-
//当为目录列表时catalog_name_content
|
|
33437
|
-
//当为表格单元格时ant-table-cell
|
|
33438
|
-
//当为分页总数时total_pag_num
|
|
33439
|
-
//当为分页每页条数选择时ant-pagination-options-quick-jumper
|
|
33440
|
-
//当为分页下拉选择时ant-select-selection-item
|
|
33441
|
-
//当为分页下拉选项时ant-select-item-option-content
|
|
33442
|
-
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"];
|
|
33443
|
-
for (let cls of classes) {
|
|
33444
|
-
if (element.classList.contains(cls)) {
|
|
33445
|
-
return false;
|
|
33446
|
-
}
|
|
33447
|
-
}
|
|
33448
|
-
return true;
|
|
33526
|
+
return checkContentResult;
|
|
33449
33527
|
}
|
|
33450
33528
|
|
|
33451
33529
|
// 处理DOM元素的函数
|
|
@@ -33460,33 +33538,32 @@ function processElement(element) {
|
|
|
33460
33538
|
for (let i = 0; i < children.length; i++) {
|
|
33461
33539
|
processElement(children[i]);
|
|
33462
33540
|
}
|
|
33463
|
-
|
|
33464
|
-
// 检查父亲性质节点是否需要被过滤
|
|
33465
|
-
const isParentNodeNeedFilter = checkParantNodeNeedFiller(element);
|
|
33466
|
-
if (isParentNodeNeedFilter) {
|
|
33467
|
-
return false;
|
|
33468
|
-
}
|
|
33469
33541
|
}
|
|
33470
|
-
// element.setAttribute("i18nProcessed", "true"); // 标记元素已被处理
|
|
33471
|
-
// 检查placeholder是否匹配
|
|
33472
|
-
const placeholder = element.getAttribute("placeholder") || element.placeholder;
|
|
33473
|
-
const placeholderMatch = placeholder ? checkTextFormat(placeholder) : null;
|
|
33474
|
-
const title = element.getAttribute("title") || element.title;
|
|
33475
|
-
const titleMatch = title ? checkTextFormat(title) : null;
|
|
33476
33542
|
|
|
33477
33543
|
// 检查innerHTML是否匹配(仅对没有子元素的元素)
|
|
33478
33544
|
let innerHTMLMatch = null;
|
|
33479
|
-
const
|
|
33480
|
-
|
|
33545
|
+
const attrCheckResult = attribute_i18n_check(element);
|
|
33546
|
+
if (attrCheckResult.result) {
|
|
33547
|
+
console.log("检查到属性匹配元素:", element);
|
|
33548
|
+
}
|
|
33481
33549
|
|
|
33482
33550
|
//检查是否是smardaten平台元素
|
|
33483
|
-
const
|
|
33484
|
-
if (
|
|
33485
|
-
innerHTMLMatch =
|
|
33551
|
+
const checkContentResult = checkPlatformElementContent(element);
|
|
33552
|
+
if (checkContentResult.result) {
|
|
33553
|
+
innerHTMLMatch = checkContentResult.innerHTMLMatch;
|
|
33554
|
+
element.setAttribute("oldValue", innerHTMLMatch.oldValue);
|
|
33555
|
+
} else {
|
|
33556
|
+
if (!hasChildren) {
|
|
33557
|
+
const innerHTML = element.innerHTML;
|
|
33558
|
+
innerHTMLMatch = checkTextFormat(innerHTML);
|
|
33559
|
+
if (innerHTMLMatch) {
|
|
33560
|
+
element.setAttribute("oldValue", element.innerHTML);
|
|
33561
|
+
}
|
|
33562
|
+
}
|
|
33486
33563
|
}
|
|
33487
33564
|
|
|
33488
33565
|
// 如果没有匹配的内容,则不处理
|
|
33489
|
-
if (!
|
|
33566
|
+
if (!innerHTMLMatch && !checkContentResult.result && !attrCheckResult.result) {
|
|
33490
33567
|
return false;
|
|
33491
33568
|
}
|
|
33492
33569
|
let elementId = element.getAttribute("localDomID");
|
|
@@ -33495,36 +33572,14 @@ function processElement(element) {
|
|
|
33495
33572
|
}
|
|
33496
33573
|
element.setAttribute("localDomID", elementId);
|
|
33497
33574
|
|
|
33498
|
-
// console.log("处理元素:", element, {
|
|
33499
|
-
// placeholderMatch,
|
|
33500
|
-
// valueMatch,
|
|
33501
|
-
// innerHTMLMatch,
|
|
33502
|
-
// });
|
|
33503
|
-
// 处理placeholder
|
|
33504
|
-
if (placeholderMatch) {
|
|
33505
|
-
element.setAttribute("oldPlaceholderValue", placeholder);
|
|
33506
|
-
}
|
|
33507
|
-
if (titleMatch) {
|
|
33508
|
-
element.setAttribute("oldTitleValue", title);
|
|
33509
|
-
}
|
|
33510
|
-
|
|
33511
|
-
// 处理innerHTML(仅对没有子元素的元素)
|
|
33512
|
-
if (!hasChildren && innerHTMLMatch) {
|
|
33513
|
-
element.setAttribute("oldValue", element.innerHTML);
|
|
33514
|
-
}
|
|
33515
|
-
if (checkResult.result) {
|
|
33516
|
-
element.setAttribute("oldValue", innerHTMLMatch.oldValue);
|
|
33517
|
-
}
|
|
33518
|
-
|
|
33519
33575
|
// 添加到Map缓存
|
|
33520
33576
|
window.i18nElementsMap.set(elementId, {
|
|
33521
33577
|
dom: element,
|
|
33522
33578
|
id: elementId,
|
|
33523
|
-
|
|
33524
|
-
|
|
33525
|
-
|
|
33526
|
-
|
|
33527
|
-
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null
|
|
33579
|
+
isScriptAction: innerHTMLMatch ? innerHTMLMatch.isScriptAction || false : false,
|
|
33580
|
+
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
|
|
33581
|
+
isAttibuteAction: attrCheckResult.result,
|
|
33582
|
+
attrFunction: attrCheckResult.scriptFunction || null
|
|
33528
33583
|
});
|
|
33529
33584
|
applyTranslation(element);
|
|
33530
33585
|
return true;
|
|
@@ -33558,66 +33613,31 @@ const applyTranslation = async element => {
|
|
|
33558
33613
|
const elementId = element.getAttribute("localDomID");
|
|
33559
33614
|
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
33560
33615
|
if (!cachedItem) return;
|
|
33561
|
-
//
|
|
33562
|
-
if (cachedItem.
|
|
33563
|
-
|
|
33564
|
-
|
|
33616
|
+
// 处理属性
|
|
33617
|
+
if (cachedItem.isAttibuteAction) {
|
|
33618
|
+
cachedItem.attrFunction(appID, lang);
|
|
33619
|
+
}
|
|
33620
|
+
// 处理innerHTML
|
|
33621
|
+
if (cachedItem.isScriptAction) {
|
|
33622
|
+
cachedItem.scriptFunction(appID, lang);
|
|
33623
|
+
} else {
|
|
33624
|
+
const oldValue = element.getAttribute("oldValue");
|
|
33625
|
+
if (oldValue) {
|
|
33565
33626
|
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33566
33627
|
const regex = /\$L\{([^}]+)\}/g;
|
|
33567
33628
|
// 替换所有 $L{...} 占位符为翻译文本
|
|
33568
|
-
let
|
|
33629
|
+
let newValue = oldValue;
|
|
33569
33630
|
let match;
|
|
33570
|
-
while ((match = regex.exec(
|
|
33631
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
33571
33632
|
const fullMatch = match[0];
|
|
33572
33633
|
const placeholderKey = match[1];
|
|
33573
33634
|
const translation = i18n(placeholderKey, appID, lang);
|
|
33574
|
-
|
|
33575
|
-
}
|
|
33576
|
-
// 更新元素的placeholder属性
|
|
33577
|
-
element.setAttribute("placeholder", newPlaceholderValue);
|
|
33578
|
-
}
|
|
33579
|
-
}
|
|
33580
|
-
if (cachedItem.oldTitleValue) {
|
|
33581
|
-
const oldTitleValue = element.getAttribute("oldTitleValue");
|
|
33582
|
-
if (oldTitleValue) {
|
|
33583
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33584
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
33585
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
33586
|
-
let newTitleValue = oldTitleValue;
|
|
33587
|
-
let match;
|
|
33588
|
-
while ((match = regex.exec(oldTitleValue)) !== null) {
|
|
33589
|
-
const fullMatch = match[0];
|
|
33590
|
-
const titleKey = match[1];
|
|
33591
|
-
const translation = i18n(titleKey, appID, lang);
|
|
33592
|
-
newTitleValue = newTitleValue.replace(fullMatch, translation);
|
|
33593
|
-
// 更新元素的title属性
|
|
33594
|
-
element.setAttribute("title", newTitleValue);
|
|
33595
|
-
}
|
|
33596
|
-
}
|
|
33597
|
-
}
|
|
33598
|
-
// console.log("更新innerHTML翻译:", element);
|
|
33599
|
-
if (cachedItem.isScriptOldValue) {
|
|
33600
|
-
cachedItem.scriptFunction(appID, lang);
|
|
33601
|
-
} else {
|
|
33602
|
-
if (cachedItem.oldValue) {
|
|
33603
|
-
const oldValue = element.getAttribute("oldValue");
|
|
33604
|
-
if (oldValue) {
|
|
33605
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33606
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
33607
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
33608
|
-
let newValue = oldValue;
|
|
33609
|
-
let match;
|
|
33610
|
-
while ((match = regex.exec(oldValue)) !== null) {
|
|
33611
|
-
const fullMatch = match[0];
|
|
33612
|
-
const placeholderKey = match[1];
|
|
33613
|
-
const translation = i18n(placeholderKey, appID, lang);
|
|
33614
|
-
newValue = newValue.replace(fullMatch, translation);
|
|
33615
|
-
}
|
|
33616
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_.nextTick)(() => {
|
|
33617
|
-
// 更新元素的innerHTML
|
|
33618
|
-
element.innerHTML = newValue;
|
|
33619
|
-
});
|
|
33635
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
33620
33636
|
}
|
|
33637
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_.nextTick)(() => {
|
|
33638
|
+
// 更新元素的innerHTML
|
|
33639
|
+
element.innerHTML = newValue;
|
|
33640
|
+
});
|
|
33621
33641
|
}
|
|
33622
33642
|
}
|
|
33623
33643
|
};
|