isdata-customer-sdk 0.2.31 → 0.2.32
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 +1847 -1840
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +1847 -1840
- 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.common.js
CHANGED
|
@@ -29612,6 +29612,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29612
29612
|
getUserID: function() { return /* reexport */ getUserID; },
|
|
29613
29613
|
hasListener: function() { return /* reexport */ hasListener; },
|
|
29614
29614
|
i18n: function() { return /* reexport */ i18n; },
|
|
29615
|
+
i18nText: function() { return /* reexport */ i18nText; },
|
|
29615
29616
|
initDomNodeI18NObserver: function() { return /* reexport */ initDomNodeI18NObserver; },
|
|
29616
29617
|
initDomNodeViewObserver: function() { return /* reexport */ initDomNodeViewObserver; },
|
|
29617
29618
|
initEventCenter: function() { return /* reexport */ initEventCenter; },
|
|
@@ -32410,977 +32411,553 @@ const getIntegrateAppInfoByID = async appID => {
|
|
|
32410
32411
|
// EXTERNAL MODULE: ./node_modules/crypto-js/index.js
|
|
32411
32412
|
var crypto_js = __webpack_require__(1396);
|
|
32412
32413
|
var crypto_js_default = /*#__PURE__*/__webpack_require__.n(crypto_js);
|
|
32413
|
-
;//
|
|
32414
|
-
|
|
32415
|
-
|
|
32416
|
-
|
|
32417
|
-
|
|
32418
|
-
|
|
32419
|
-
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
|
|
32424
|
-
|
|
32425
|
-
}
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
|
|
32429
|
-
|
|
32430
|
-
|
|
32431
|
-
|
|
32432
|
-
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32436
|
-
|
|
32437
|
-
let resultCode = response.code;
|
|
32438
|
-
if (resultCode == "10110020") {
|
|
32439
|
-
window.sessionStorage.clear();
|
|
32440
|
-
return {
|
|
32441
|
-
code: resultCode,
|
|
32442
|
-
message: `$L{${response.message}}`
|
|
32443
|
-
};
|
|
32444
|
-
} else {
|
|
32445
|
-
return {
|
|
32446
|
-
code: resultCode,
|
|
32447
|
-
message: `$L{${response.message}}`
|
|
32448
|
-
};
|
|
32449
|
-
}
|
|
32450
|
-
};
|
|
32451
|
-
|
|
32452
|
-
/**
|
|
32453
|
-
* 解密
|
|
32454
|
-
*/
|
|
32455
|
-
const decrypt = async decryptStr => {
|
|
32456
|
-
let secretKey = await getKey();
|
|
32457
|
-
const decrypted = crypto_js_default().AES.decrypt(decryptStr, secretKey).toString((crypto_js_default()).enc.Utf8);
|
|
32458
|
-
return decrypted;
|
|
32459
|
-
};
|
|
32460
|
-
|
|
32461
|
-
/**
|
|
32462
|
-
* 解密
|
|
32463
|
-
*/
|
|
32464
|
-
const encrypt = async decryptStr => {
|
|
32465
|
-
let secretKey = await getKey();
|
|
32466
|
-
const encrypted = crypto_js_default().AES.encrypt(decryptStr, secretKey).toString();
|
|
32467
|
-
return encrypted;
|
|
32468
|
-
};
|
|
32469
|
-
|
|
32470
|
-
/**
|
|
32471
|
-
* 切换门户登录
|
|
32472
|
-
*/
|
|
32473
|
-
const switchPortalLogin = async (data, appid, endside_type) => {
|
|
32474
|
-
let old_key = window.sessionStorage.getItem("iportal_login_user_key");
|
|
32475
|
-
old_key = await decrypt(old_key);
|
|
32476
|
-
data.password = old_key;
|
|
32477
|
-
let resultData = await logoutAccount(endside_type);
|
|
32478
|
-
let resultCode = resultData.code;
|
|
32479
|
-
let message = resultData.message;
|
|
32480
|
-
//退出登录成功
|
|
32481
|
-
if (resultCode == "10110020") {
|
|
32482
|
-
let loginResult = await loginAccount(data, appid);
|
|
32483
|
-
return loginResult;
|
|
32484
|
-
} else {
|
|
32485
|
-
return {
|
|
32486
|
-
code: resultCode,
|
|
32487
|
-
message: `$L{${message}}`
|
|
32488
|
-
};
|
|
32489
|
-
}
|
|
32490
|
-
};
|
|
32491
|
-
const getUserID = async (acccountName, old_key, group_id) => {
|
|
32492
|
-
let queryData = {
|
|
32493
|
-
param: {
|
|
32494
|
-
accountName: acccountName,
|
|
32495
|
-
group_id: group_id,
|
|
32496
|
-
account_key: old_key
|
|
32497
|
-
}
|
|
32498
|
-
};
|
|
32499
|
-
let result = await request.post(`/dataservice/rest/orchestration/getUserID`, queryData);
|
|
32500
|
-
let persion_id = result.data.persion_id;
|
|
32501
|
-
return persion_id;
|
|
32502
|
-
};
|
|
32503
|
-
|
|
32504
|
-
/**
|
|
32505
|
-
* 登录账号
|
|
32506
|
-
* @param data 登录数据
|
|
32507
|
-
* @param appid 应用ID
|
|
32508
|
-
*
|
|
32509
|
-
* @description
|
|
32510
|
-
* 登录时需要传入验证码(authPicCode)和应用ID(dataappId),
|
|
32511
|
-
* mobileOrWeb参数用于区分是移动端还是网页端登录。
|
|
32512
|
-
*
|
|
32513
|
-
* @returns
|
|
32514
|
-
*/
|
|
32515
|
-
const loginAccount = async (data, appid) => {
|
|
32516
|
-
let result = await getLoginPortalAccountKey(data.account_view, data.groupid);
|
|
32517
|
-
let code = result.data.code;
|
|
32518
|
-
//获取key成功
|
|
32519
|
-
if (code == 10001) {
|
|
32520
|
-
//保存的真正一级密码
|
|
32521
|
-
let pwd_code = result.data.codeData.key;
|
|
32522
|
-
//缓存一级密码
|
|
32523
|
-
let old_key = pwd_code;
|
|
32524
|
-
//保存的正则2级密码
|
|
32525
|
-
let key_code = result.data.codeData.code;
|
|
32526
|
-
//反向解析一级密码
|
|
32527
|
-
pwd_code = await decrypt(pwd_code);
|
|
32528
|
-
//反向解析2级密码
|
|
32529
|
-
key_code = await decrypt(key_code);
|
|
32530
|
-
//密码匹配
|
|
32531
|
-
if (pwd_code == data.password) {
|
|
32532
|
-
//平台正向加密2级密码
|
|
32533
|
-
pwd_code = window.appSdk.Encrypt(key_code);
|
|
32534
|
-
data.password = pwd_code;
|
|
32535
|
-
result = await request.post(`/system/authority/loginAccount4Application?authPicCode=${data.imageCode}&dataappId=${appid}&mobileOrWeb=web`, data);
|
|
32536
|
-
let response = JSON.parse(result.request.response);
|
|
32537
|
-
code = response.code;
|
|
32538
|
-
//登录平台成功
|
|
32539
|
-
if (code == 10110004) {
|
|
32540
|
-
let id = await getUserID(data.account_view, old_key, data.groupid);
|
|
32541
|
-
// 初始化解析器
|
|
32542
|
-
const parser = new UAParser();
|
|
32543
|
-
// 获取浏览器信息
|
|
32544
|
-
const browser = parser.getBrowser();
|
|
32545
|
-
let timestamp = new Date().getTime();
|
|
32546
|
-
let clientID = browser.name + "_" + browser.version + "_" + timestamp;
|
|
32547
|
-
window.sessionStorage.setItem("iportal_login_user_id", id);
|
|
32548
|
-
window.sessionStorage.setItem("iportal_group_id", data.groupid);
|
|
32549
|
-
window.sessionStorage.setItem("iportal_login_user_key", old_key);
|
|
32550
|
-
window.sessionStorage.setItem("iportal_client_id", clientID);
|
|
32551
|
-
window.sessionStorage.setItem("iportal_app_id", appid);
|
|
32552
|
-
return {
|
|
32553
|
-
code: code
|
|
32554
|
-
};
|
|
32555
|
-
} else {
|
|
32556
|
-
return {
|
|
32557
|
-
code: code,
|
|
32558
|
-
message: `$L{${response.message}}`
|
|
32559
|
-
};
|
|
32560
|
-
}
|
|
32561
|
-
} else {
|
|
32562
|
-
return {
|
|
32563
|
-
code: code,
|
|
32564
|
-
message: "$L{账户密码错误}!"
|
|
32565
|
-
};
|
|
32566
|
-
}
|
|
32567
|
-
}
|
|
32568
|
-
return {
|
|
32569
|
-
code: code,
|
|
32570
|
-
message: `$L{${result.data.message}}`
|
|
32571
|
-
};
|
|
32572
|
-
};
|
|
32573
|
-
|
|
32574
|
-
/**
|
|
32575
|
-
* 获取密钥
|
|
32576
|
-
* @returns
|
|
32577
|
-
*/
|
|
32578
|
-
const getKey = async () => {
|
|
32579
|
-
let queryData = {
|
|
32580
|
-
param: {}
|
|
32581
|
-
};
|
|
32582
|
-
let resultData = await request.post(`/dataservice/rest/orchestration/getKey`, queryData);
|
|
32583
|
-
let key = resultData.data.key;
|
|
32584
|
-
return key;
|
|
32585
|
-
};
|
|
32586
|
-
;// ./src/api/utils.js
|
|
32587
|
-
|
|
32588
|
-
|
|
32589
|
-
|
|
32590
|
-
|
|
32591
|
-
/**
|
|
32592
|
-
* 查询资产
|
|
32593
|
-
* @param id 资产ID
|
|
32594
|
-
*
|
|
32595
|
-
*/
|
|
32596
|
-
const queryAssetById = (id, count = 200) => request.post(`/asset/getAssetData?asset_id=${id}&count=${count}`, {
|
|
32597
|
-
filters: []
|
|
32598
|
-
});
|
|
32599
|
-
|
|
32600
|
-
/**
|
|
32601
|
-
* 获取URL参数值
|
|
32602
|
-
* @param {} eventName
|
|
32603
|
-
* @param {*} actionFun
|
|
32604
|
-
*/
|
|
32605
|
-
const getUrlParamValue = (urlStr, paramName) => {
|
|
32606
|
-
try {
|
|
32607
|
-
const url = new URL(urlStr);
|
|
32608
|
-
const value = url.searchParams.get(paramName);
|
|
32609
|
-
// 如果参数值包含#,则只返回#之前的部分
|
|
32610
|
-
if (value && value.indexOf("#") !== -1) {
|
|
32611
|
-
return value.split("#")[0];
|
|
32612
|
-
}
|
|
32613
|
-
return value;
|
|
32614
|
-
} catch (err) {
|
|
32615
|
-
console.error("URL 格式错误:", err);
|
|
32616
|
-
return "";
|
|
32617
|
-
}
|
|
32618
|
-
};
|
|
32619
|
-
|
|
32620
|
-
/**
|
|
32621
|
-
* 通过 URL 创建 File 对象
|
|
32622
|
-
* @param {string} url - 文件的网络 URL
|
|
32623
|
-
* @param {string} [filename] - 自定义文件名(可选,不传则从 URL 提取)
|
|
32624
|
-
* @returns {Promise<File>} - 返回 Promise 解析为 File 对象
|
|
32625
|
-
*/
|
|
32626
|
-
const createFileFromUrl = async (url, filename) => {
|
|
32627
|
-
try {
|
|
32628
|
-
// 1. 发起网络请求获取文件
|
|
32629
|
-
const response = await fetch(url);
|
|
32630
|
-
if (!response.ok) {
|
|
32631
|
-
throw new Error(`网络请求失败: ${response.status} ${response.statusText}`);
|
|
32632
|
-
}
|
|
32633
|
-
|
|
32634
|
-
// 2. 将响应转换为 Blob(保留原始 MIME 类型)
|
|
32635
|
-
const blob = await response.blob();
|
|
32636
|
-
|
|
32637
|
-
// 3. 确定文件名(若未自定义则从 URL 提取)
|
|
32638
|
-
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
32639
|
-
|
|
32640
|
-
// 4. 构造 File 对象(Blob + 文件名 + 类型)
|
|
32641
|
-
return new File([blob], finalFilename, {
|
|
32642
|
-
type: blob.type,
|
|
32643
|
-
// 使用 Blob 的 MIME 类型(如 image/png)
|
|
32644
|
-
lastModified: Date.now() // 可选:设置最后修改时间
|
|
32645
|
-
});
|
|
32646
|
-
} catch (error) {
|
|
32647
|
-
console.error("创建 File 失败:", error);
|
|
32648
|
-
throw error;
|
|
32649
|
-
}
|
|
32650
|
-
};
|
|
32651
|
-
|
|
32652
|
-
/**
|
|
32653
|
-
* 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
|
|
32654
|
-
* @param {string} url - 文件 URL
|
|
32655
|
-
* @returns {string} - 提取的文件名
|
|
32656
|
-
*/
|
|
32657
|
-
const extractFilenameFromUrl = url => {
|
|
32658
|
-
try {
|
|
32659
|
-
const urlObj = new URL(url);
|
|
32660
|
-
// 从路径中获取最后一个部分(文件名)
|
|
32661
|
-
return urlObj.pathname.split("/").pop() || "downloaded_file";
|
|
32662
|
-
} catch (e) {
|
|
32663
|
-
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
32664
|
-
}
|
|
32665
|
-
};
|
|
32666
|
-
|
|
32667
|
-
/**
|
|
32668
|
-
* 提取数组中不在另一个数组中的元素
|
|
32669
|
-
* @param {*} oldItems 基础比较数组
|
|
32670
|
-
* @param {*} newItems 被提取检测的数组
|
|
32671
|
-
* @returns
|
|
32672
|
-
*/
|
|
32673
|
-
const extractNewItems = (oldItems, newItems) => {
|
|
32674
|
-
return oldItems.filter(item => !newItems.includes(item));
|
|
32675
|
-
};
|
|
32676
|
-
|
|
32677
|
-
/**
|
|
32678
|
-
* 获取远程文件大小(单位:字节)
|
|
32679
|
-
* @param {string} url - 文件的URL地址
|
|
32680
|
-
* @returns {Promise<number>} 文件大小(字节),失败时返回-1
|
|
32681
|
-
*/
|
|
32682
|
-
const getFileSize = async url => {
|
|
32683
|
-
try {
|
|
32684
|
-
// 发送HEAD请求(不下载文件内容)
|
|
32685
|
-
const response = await fetch(url, {
|
|
32686
|
-
method: "GET",
|
|
32687
|
-
headers: {
|
|
32688
|
-
Range: "bytes=0-0"
|
|
32689
|
-
} // 仅请求第 1 个字节
|
|
32690
|
-
});
|
|
32691
|
-
if (response.status !== 206) throw new Error("不支持 Range 请求");
|
|
32692
|
-
const contentRange = response.headers.get("Content-Range");
|
|
32693
|
-
const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
|
|
32694
|
-
return totalSize ? parseInt(totalSize, 10) : -1;
|
|
32695
|
-
} catch (error) {
|
|
32696
|
-
console.error("获取文件大小失败:", error);
|
|
32697
|
-
return -1; // 返回-1表示失败
|
|
32698
|
-
}
|
|
32699
|
-
};
|
|
32700
|
-
// 获取i18n key
|
|
32701
|
-
const getI18nKey = text => {
|
|
32702
|
-
// 正则表达式匹配 $L{...} 格式
|
|
32703
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
32704
|
-
let match = regex.exec(text);
|
|
32705
|
-
if (!match) return text;
|
|
32706
|
-
let key = match[1];
|
|
32707
|
-
return key;
|
|
32708
|
-
};
|
|
32709
|
-
|
|
32710
|
-
// 查找最近的具有指定 class 的祖先节点
|
|
32711
|
-
const findClosestAncestorByClass = (element, className) => {
|
|
32712
|
-
let currentElement = element;
|
|
32713
|
-
while (currentElement) {
|
|
32714
|
-
// 检查当前元素是否包含目标 class
|
|
32715
|
-
if (currentElement.classList && currentElement.classList.contains(className)) {
|
|
32716
|
-
return currentElement;
|
|
32717
|
-
}
|
|
32718
|
-
// 向上遍历父节点
|
|
32719
|
-
currentElement = currentElement.parentElement;
|
|
32720
|
-
}
|
|
32721
|
-
// 未找到匹配的祖先节点
|
|
32722
|
-
return null;
|
|
32723
|
-
};
|
|
32724
|
-
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
|
|
32725
|
-
var es_iterator_some = __webpack_require__(3579);
|
|
32726
|
-
;// ./src/api/iframe.js
|
|
32727
|
-
|
|
32728
|
-
|
|
32729
|
-
|
|
32730
|
-
const addWindowTrustedOrigin = origin => {
|
|
32731
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32732
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32733
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS.includes(origin)) {
|
|
32734
|
-
SDATA_WINDOW_TRUSTED_ORIGINS.push(origin);
|
|
32735
|
-
}
|
|
32736
|
-
};
|
|
32737
|
-
const removeWindowTrustedOrigin = origin => {
|
|
32738
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32739
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32740
|
-
let index = SDATA_WINDOW_TRUSTED_ORIGINS.indexOf(origin); // 查找元素在数组中的索引
|
|
32741
|
-
if (index > -1) {
|
|
32742
|
-
SDATA_WINDOW_TRUSTED_ORIGINS.splice(index, 1); // 删除元素
|
|
32743
|
-
}
|
|
32744
|
-
};
|
|
32745
|
-
const addEventAction = (eventKey, eventAction) => {
|
|
32746
|
-
let sdataEventActions = window.sdataEventActions;
|
|
32747
|
-
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32748
|
-
window.sdataEventActions[eventKey] = eventAction;
|
|
32749
|
-
};
|
|
32750
|
-
const removeEventAction = eventKey => {
|
|
32751
|
-
let sdataEventActions = window.sdataEventActions;
|
|
32752
|
-
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32753
|
-
delete window.sdataEventActions[eventKey];
|
|
32754
|
-
};
|
|
32755
|
-
const initFrameWindowListener = () => {
|
|
32756
|
-
if (window.isFrameWindowInited) return;
|
|
32757
|
-
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
32758
|
-
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
32759
|
-
let sdataEventActions = window.sdataEventActions;
|
|
32760
|
-
if (!sdataEventActions) window.sdataEventActions = {};
|
|
32761
|
-
// 监听主页面的消息
|
|
32762
|
-
window.addEventListener("message", async event => {
|
|
32763
|
-
// 步骤1:验证来源是否在白名单中
|
|
32764
|
-
const isTrusted = window.SDATA_WINDOW_TRUSTED_ORIGINS.some(origin => event.origin === origin || new RegExp(origin).test(event.origin));
|
|
32765
|
-
if (!isTrusted) {
|
|
32766
|
-
console.log("拒绝非可信源消息:", event.origin);
|
|
32767
|
-
return; // 直接终止处理
|
|
32414
|
+
;// external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
|
|
32415
|
+
var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
|
|
32416
|
+
;// ./src/api/i18n/smardaten_i18n/table_i18n.js
|
|
32417
|
+
|
|
32418
|
+
const check = element => {
|
|
32419
|
+
const checkResult = {
|
|
32420
|
+
result: false,
|
|
32421
|
+
innerHTMLMatch: null
|
|
32422
|
+
};
|
|
32423
|
+
const classes = element.classList;
|
|
32424
|
+
if (!classes) {
|
|
32425
|
+
return checkResult;
|
|
32426
|
+
}
|
|
32427
|
+
// 检查表格头部 序号 和 操作 列
|
|
32428
|
+
if (classes.contains("ant-table-cell")) {
|
|
32429
|
+
let innerHTML = element.innerHTML;
|
|
32430
|
+
if (innerHTML.includes("序号") || innerHTML.includes("Serial No.")) {
|
|
32431
|
+
// console.log("检查smardaten平台表格 序号 元素:",innerHTML);
|
|
32432
|
+
let tempHTMLMatch = {
|
|
32433
|
+
oldValue: '$L{序号}'
|
|
32434
|
+
};
|
|
32435
|
+
checkResult.result = true;
|
|
32436
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32437
|
+
return checkResult;
|
|
32768
32438
|
}
|
|
32769
|
-
|
|
32770
|
-
|
|
32771
|
-
|
|
32772
|
-
|
|
32773
|
-
if (eventKey === "sdata_alllife_event_response") {
|
|
32774
|
-
let eventOperateKey = event.data.eventOperateKey;
|
|
32775
|
-
let eventAction = window.sdataEventActions[eventOperateKey];
|
|
32776
|
-
//删除缓存方法
|
|
32777
|
-
delete window.sdataEventActions[eventOperateKey];
|
|
32778
|
-
if (eventAction) await eventAction(event.data.data, event);
|
|
32779
|
-
} else {
|
|
32780
|
-
let eventAction = window.sdataEventActions[eventKey];
|
|
32781
|
-
let responseData = {
|
|
32782
|
-
eventKey: "sdata_alllife_event_response",
|
|
32783
|
-
eventOperateKey: event.data.eventOperateKey,
|
|
32784
|
-
data: {}
|
|
32439
|
+
if (innerHTML.includes("操作")) {
|
|
32440
|
+
// console.log("检查smardaten平台表格 操作 元素:",innerHTML);
|
|
32441
|
+
let tempHTMLMatch = {
|
|
32442
|
+
oldValue: '$L{操作}'
|
|
32785
32443
|
};
|
|
32786
|
-
|
|
32787
|
-
|
|
32788
|
-
|
|
32789
|
-
}
|
|
32790
|
-
event.source.postMessage(responseData, eventSourceKey);
|
|
32444
|
+
checkResult.result = true;
|
|
32445
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32446
|
+
return checkResult;
|
|
32791
32447
|
}
|
|
32792
|
-
});
|
|
32793
|
-
window.isFrameWindowInited = true;
|
|
32794
|
-
};
|
|
32795
|
-
const sendWindowMessage = async (targetWindow, originKey, eventKey, data, callback) => {
|
|
32796
|
-
let timestamp = new Date().getTime();
|
|
32797
|
-
let randomNum = Math.floor(Math.random() * 10000) + 1;
|
|
32798
|
-
let eventOperateKey = `${eventKey}_${timestamp}_${randomNum}`;
|
|
32799
|
-
addEventAction(eventOperateKey, callback);
|
|
32800
|
-
let postData = {
|
|
32801
|
-
eventOperateKey: eventOperateKey,
|
|
32802
|
-
eventKey: eventKey,
|
|
32803
|
-
data: data
|
|
32804
|
-
};
|
|
32805
|
-
targetWindow.postMessage(postData, originKey);
|
|
32806
|
-
};
|
|
32807
|
-
;// ./src/api/chat/ChatClientMgr.js
|
|
32808
|
-
|
|
32809
|
-
|
|
32810
|
-
|
|
32811
|
-
class ChatClientMgr {
|
|
32812
|
-
constructor(params, handler) {
|
|
32813
|
-
this.handler = handler;
|
|
32814
|
-
this.actionKey = params.actionKey;
|
|
32815
|
-
this.appSKID = params.appSKID;
|
|
32816
|
-
this.imType = params.imType;
|
|
32817
|
-
this.groupID = params.groupID;
|
|
32818
|
-
this.userID = params.userID;
|
|
32819
|
-
this.chatType = params.chatType || 0;
|
|
32820
|
-
this.singleChatID = params.singleChatID || "";
|
|
32821
|
-
this.customParams = params.customParams || {};
|
|
32822
|
-
this.chartOrigin = params.chartOrigin;
|
|
32823
|
-
// console.log("ChatClientMgr init:", this.actionKey);
|
|
32824
|
-
}
|
|
32825
|
-
makeKey(key) {
|
|
32826
|
-
return `${key}-${this.actionKey}`;
|
|
32827
32448
|
}
|
|
32828
|
-
|
|
32829
|
-
|
|
32830
|
-
|
|
32831
|
-
|
|
32832
|
-
|
|
32833
|
-
|
|
32834
|
-
|
|
32835
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_portal_user_sig`), async data => {
|
|
32836
|
-
let userID = data.userID;
|
|
32837
|
-
let platType = data.im_type;
|
|
32838
|
-
let groupID = data.group_id;
|
|
32839
|
-
return await this.handler.getPortalUserSig(userID, platType, groupID);
|
|
32840
|
-
});
|
|
32841
|
-
this.handler.addChatListener(this.makeKey(`sdata_add_im_mapping`), async data => {
|
|
32842
|
-
let userID = data.userID;
|
|
32843
|
-
let platType = data.im_type;
|
|
32844
|
-
let userSig = data.userSig;
|
|
32845
|
-
return await this.handler.addIMMapping(userID, platType, userSig, this.groupID);
|
|
32846
|
-
});
|
|
32847
|
-
this.handler.addChatListener(this.makeKey(`sdata_update_im_mapping`), async data => {
|
|
32848
|
-
return await this.handler.updateIMMapping(data);
|
|
32849
|
-
});
|
|
32850
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_users_by_group_id`), async data => {
|
|
32851
|
-
return await this.handler.getAllUserInfosByGroupID(data);
|
|
32852
|
-
});
|
|
32853
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_dpts_by_group_id`), async data => {
|
|
32854
|
-
return await this.handler.getChildrenOfficeInfosByID(data);
|
|
32855
|
-
});
|
|
32856
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_project_dpts_by_user_group_id`), async data => {
|
|
32857
|
-
return await this.handler.getPojectDptsByUserAndGroupID(data);
|
|
32858
|
-
});
|
|
32859
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_ai_robot_infos`), async data => {
|
|
32860
|
-
let groupID = data.groupID;
|
|
32861
|
-
let userID = data.userID;
|
|
32862
|
-
if (this.userID == userID && this.groupID == groupID) {
|
|
32863
|
-
return this.getAIRobotInfos();
|
|
32864
|
-
}
|
|
32865
|
-
return [];
|
|
32866
|
-
});
|
|
32867
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_test_user_sig`), async data => {
|
|
32868
|
-
let sdkAppID = data.SDKAppID;
|
|
32869
|
-
let userID = data.userID;
|
|
32870
|
-
let sigIDObject = await this.handler.genTestUserSig({
|
|
32871
|
-
SDKAppID: sdkAppID,
|
|
32872
|
-
userID: userID
|
|
32873
|
-
});
|
|
32874
|
-
let sigID = sigIDObject.userSig;
|
|
32875
|
-
return sigID;
|
|
32876
|
-
});
|
|
32877
|
-
this.handler.addChatListener(this.makeKey(`sdata_send_message_to_chat_server`), async (data, event) => {
|
|
32878
|
-
let message = data.message;
|
|
32879
|
-
let robotID = message.from;
|
|
32880
|
-
let result = await this.sendMessageToChatServer(robotID, message);
|
|
32881
|
-
return result;
|
|
32882
|
-
});
|
|
32883
|
-
this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
|
|
32884
|
-
return this.handler.closeWindow();
|
|
32885
|
-
});
|
|
32886
|
-
this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
|
|
32887
|
-
return this.handler.getPortalDocmentInfo(data);
|
|
32888
|
-
});
|
|
32889
|
-
this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
|
|
32890
|
-
return this.handler.onAIAgentEvent(data, event);
|
|
32891
|
-
});
|
|
32892
|
-
this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
|
|
32893
|
-
console.log("recive chat regist event data:", data);
|
|
32894
|
-
this.appSKID = data.appid;
|
|
32895
|
-
this.imType = data.im_type;
|
|
32896
|
-
await this.initChatAIs();
|
|
32897
|
-
let charParams = {
|
|
32898
|
-
type: this.getChatTypeKey(this.chatType),
|
|
32899
|
-
singleChatID: this.singleChatID,
|
|
32900
|
-
customParams: this.customParams
|
|
32449
|
+
// 检查分页组件 导出按钮
|
|
32450
|
+
if (classes.contains("export_menu")) {
|
|
32451
|
+
let innerHTML = element.innerHTML;
|
|
32452
|
+
if (innerHTML.includes("导出进度") || innerHTML.includes("Export progress")) {
|
|
32453
|
+
// console.log("检查smardaten平台表格 导出按钮 元素:",innerHTML);
|
|
32454
|
+
let tempHTMLMatch = {
|
|
32455
|
+
oldValue: '$L{导出进度}'
|
|
32901
32456
|
};
|
|
32902
|
-
|
|
32903
|
-
|
|
32904
|
-
|
|
32905
|
-
this.handler.onChatInitFinished();
|
|
32906
|
-
}
|
|
32907
|
-
});
|
|
32908
|
-
});
|
|
32909
|
-
}
|
|
32910
|
-
getChatTypeKey(type) {
|
|
32911
|
-
switch (type) {
|
|
32912
|
-
case 0:
|
|
32913
|
-
return "IM_MULTIPLE_MODE";
|
|
32914
|
-
case 1:
|
|
32915
|
-
return "IM_SINGLE_MODE";
|
|
32916
|
-
case 2:
|
|
32917
|
-
return "IM_EMBED_MODE";
|
|
32918
|
-
case 3:
|
|
32919
|
-
return "IM_MOBILE_MULTIPLE_EMBED_MODE";
|
|
32920
|
-
case 4:
|
|
32921
|
-
return "IM_MOBILE_SINGLE_EMBED_MODE";
|
|
32922
|
-
default:
|
|
32923
|
-
return "IM_MULTIPLE_MODE";
|
|
32457
|
+
checkResult.result = true;
|
|
32458
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32459
|
+
return checkResult;
|
|
32924
32460
|
}
|
|
32925
32461
|
}
|
|
32926
|
-
|
|
32927
|
-
|
|
32928
|
-
|
|
32929
|
-
|
|
32930
|
-
|
|
32931
|
-
|
|
32932
|
-
|
|
32933
|
-
|
|
32934
|
-
|
|
32935
|
-
|
|
32936
|
-
|
|
32937
|
-
|
|
32938
|
-
storage: {
|
|
32939
|
-
enable: true // 启用存储(可选,根据需求)
|
|
32462
|
+
// 检查分页组件
|
|
32463
|
+
if (classes.contains("total_pag_num")) {
|
|
32464
|
+
let innerHTML = element.innerHTML;
|
|
32465
|
+
if (innerHTML.includes("共") && innerHTML.includes("条") || innerHTML.includes("Total") && innerHTML.includes("pieces")) {
|
|
32466
|
+
// console.log("检查smardaten平台分页 共xx条 元素:",innerHTML);
|
|
32467
|
+
let scriptFunction = (appID, lang) => {
|
|
32468
|
+
let scriptNode = null;
|
|
32469
|
+
for (let node of element.childNodes) {
|
|
32470
|
+
// 检查是否为文本节点且包含"Total"
|
|
32471
|
+
if (node.tagName === "SPAN") {
|
|
32472
|
+
scriptNode = node;
|
|
32473
|
+
}
|
|
32940
32474
|
}
|
|
32941
|
-
|
|
32942
|
-
|
|
32943
|
-
|
|
32944
|
-
|
|
32945
|
-
|
|
32946
|
-
|
|
32947
|
-
|
|
32948
|
-
|
|
32949
|
-
|
|
32950
|
-
|
|
32951
|
-
|
|
32952
|
-
|
|
32953
|
-
|
|
32954
|
-
|
|
32955
|
-
|
|
32956
|
-
|
|
32957
|
-
|
|
32958
|
-
let
|
|
32959
|
-
if (
|
|
32960
|
-
|
|
32475
|
+
let scriptNodes = [{
|
|
32476
|
+
nodeType: Node.TEXT_NODE,
|
|
32477
|
+
key: '共'
|
|
32478
|
+
}, {
|
|
32479
|
+
nodeType: "SCRIPTNODE",
|
|
32480
|
+
node: scriptNode
|
|
32481
|
+
}, {
|
|
32482
|
+
nodeType: Node.TEXT_NODE,
|
|
32483
|
+
key: '条'
|
|
32484
|
+
}];
|
|
32485
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32486
|
+
let childNode = element.childNodes[i];
|
|
32487
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
32488
|
+
element.removeChild(childNode);
|
|
32489
|
+
}
|
|
32490
|
+
}
|
|
32491
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
32492
|
+
let scriptNodeItem = scriptNodes[i];
|
|
32493
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32494
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
32495
|
+
element.appendChild(textNode);
|
|
32496
|
+
}
|
|
32497
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
32498
|
+
element.appendChild(scriptNodeItem.node);
|
|
32961
32499
|
}
|
|
32962
|
-
robot.userSig = userSig;
|
|
32963
|
-
this.chatAIClient.charAIs[robotKey] = {
|
|
32964
|
-
robot: robot,
|
|
32965
|
-
messageCache: []
|
|
32966
|
-
};
|
|
32967
32500
|
}
|
|
32968
|
-
});
|
|
32969
|
-
}
|
|
32970
|
-
}
|
|
32971
|
-
async generateUserSigAndUpdate(robotKey) {
|
|
32972
|
-
let sigIDObject = await this.handler.genTestUserSig({
|
|
32973
|
-
SDKAppID: this.appSKID,
|
|
32974
|
-
userID: robotKey
|
|
32975
|
-
});
|
|
32976
|
-
let userSig = sigIDObject.userSig;
|
|
32977
|
-
if (userSig) {
|
|
32978
|
-
await this.chatAIClient.login({
|
|
32979
|
-
userID: robotKey,
|
|
32980
|
-
userSig: userSig
|
|
32981
|
-
});
|
|
32982
|
-
await this.chatAIClient.logout();
|
|
32983
|
-
let data = {
|
|
32984
|
-
userID: robotKey,
|
|
32985
|
-
userSig: userSig,
|
|
32986
|
-
im_type: this.imType,
|
|
32987
|
-
group_id: this.groupID
|
|
32988
32501
|
};
|
|
32989
|
-
|
|
32502
|
+
let tempHTMLMatch = {
|
|
32503
|
+
isScriptAction: true,
|
|
32504
|
+
scriptFunction: scriptFunction
|
|
32505
|
+
};
|
|
32506
|
+
checkResult.result = true;
|
|
32507
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32508
|
+
return checkResult;
|
|
32990
32509
|
}
|
|
32991
|
-
return userSig;
|
|
32992
32510
|
}
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
32997
|
-
|
|
32998
|
-
|
|
32999
|
-
|
|
33000
|
-
|
|
33001
|
-
|
|
33002
|
-
|
|
33003
|
-
|
|
33004
|
-
|
|
33005
|
-
|
|
32511
|
+
// 检查分页组件 跳至xx页
|
|
32512
|
+
if (classes.contains("ant-pagination-options-quick-jumper")) {
|
|
32513
|
+
let innerHTML = element.innerHTML;
|
|
32514
|
+
if (innerHTML.includes("跳至") && innerHTML.includes("页") || innerHTML.includes("Go to") && innerHTML.includes("Page")) {
|
|
32515
|
+
// console.log("检查smardaten平台分页 跳至xx页 元素:",innerHTML);
|
|
32516
|
+
let scriptFunction = (appID, lang) => {
|
|
32517
|
+
let scriptNode = null;
|
|
32518
|
+
for (let node of element.childNodes) {
|
|
32519
|
+
// 检查是否为文本节点且包含"Total"
|
|
32520
|
+
if (node.tagName === "INPUT") {
|
|
32521
|
+
scriptNode = node;
|
|
32522
|
+
}
|
|
32523
|
+
}
|
|
32524
|
+
let scriptNodes = [{
|
|
32525
|
+
nodeType: Node.TEXT_NODE,
|
|
32526
|
+
key: '跳至'
|
|
32527
|
+
}, {
|
|
32528
|
+
nodeType: "SCRIPTNODE",
|
|
32529
|
+
node: scriptNode
|
|
32530
|
+
}, {
|
|
32531
|
+
nodeType: Node.TEXT_NODE,
|
|
32532
|
+
key: '页'
|
|
32533
|
+
}];
|
|
32534
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32535
|
+
let childNode = element.childNodes[i];
|
|
32536
|
+
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
32537
|
+
element.removeChild(childNode);
|
|
32538
|
+
}
|
|
32539
|
+
}
|
|
32540
|
+
for (let i = 0; i < scriptNodes.length; i++) {
|
|
32541
|
+
let scriptNodeItem = scriptNodes[i];
|
|
32542
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32543
|
+
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
32544
|
+
element.appendChild(textNode);
|
|
32545
|
+
}
|
|
32546
|
+
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
32547
|
+
element.appendChild(scriptNodeItem.node);
|
|
32548
|
+
}
|
|
32549
|
+
}
|
|
32550
|
+
};
|
|
32551
|
+
let tempHTMLMatch = {
|
|
32552
|
+
isScriptAction: true,
|
|
32553
|
+
scriptFunction: scriptFunction
|
|
32554
|
+
};
|
|
32555
|
+
checkResult.result = true;
|
|
32556
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32557
|
+
return checkResult;
|
|
33006
32558
|
}
|
|
33007
|
-
return userSig;
|
|
33008
32559
|
}
|
|
33009
|
-
|
|
33010
|
-
|
|
33011
|
-
let
|
|
33012
|
-
console.log(
|
|
33013
|
-
if (
|
|
33014
|
-
let
|
|
33015
|
-
|
|
33016
|
-
|
|
33017
|
-
if (messages && messages.length > 0) {
|
|
33018
|
-
const newMessages = [...messages];
|
|
33019
|
-
messages.splice(0, messages.length);
|
|
33020
|
-
newMessages.forEach(message => {
|
|
33021
|
-
console.log(`[AI chat] ${robotInfo.name}发送缓存消息:`, message);
|
|
33022
|
-
this.sendMessageToChatServer(robotID, message);
|
|
33023
|
-
});
|
|
32560
|
+
// 检查每页xx条
|
|
32561
|
+
if (classes.contains("ant-select-selection-item") || classes.contains("ant-select-item-option-content")) {
|
|
32562
|
+
let innerHTML = element.innerHTML;
|
|
32563
|
+
// console.log("检查smardaten平台分页 每页xx条 元素:",innerHTML);
|
|
32564
|
+
if (innerHTML.includes("/") && innerHTML.includes("page") || innerHTML.includes("/") && innerHTML.includes("条") && innerHTML.includes("页")) {
|
|
32565
|
+
let oldValue = element.innerHTML;
|
|
32566
|
+
if (innerHTML.includes("page")) {
|
|
32567
|
+
oldValue = oldValue.replace('page', '$L{页}');
|
|
33024
32568
|
}
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
getAIRobotInfos() {
|
|
33028
|
-
let resultRobots = [];
|
|
33029
|
-
for (let key in this.chatAIClient.charAIs) {
|
|
33030
|
-
resultRobots.push(this.chatAIClient.charAIs[key].robot);
|
|
33031
|
-
}
|
|
33032
|
-
return resultRobots;
|
|
33033
|
-
}
|
|
33034
|
-
getAIRobotInfoByID(robotID) {
|
|
33035
|
-
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].robot : null;
|
|
33036
|
-
}
|
|
33037
|
-
getAIRobotCacheMessagesByID(robotID) {
|
|
33038
|
-
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].messageCache : [];
|
|
33039
|
-
}
|
|
33040
|
-
async sendMessageToChatServer(robotID, messageOption) {
|
|
33041
|
-
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
33042
|
-
if (this.chatAIClient.lastRobotID != robotID) {
|
|
33043
|
-
console.log(`[AI chat]需要新机器人回答,切换到新机器人${robotInfo.name}`);
|
|
33044
|
-
if (this.chatAIClient.lastRobotID) {
|
|
33045
|
-
await this.chatAIClient.logout();
|
|
32569
|
+
if (innerHTML.includes("页")) {
|
|
32570
|
+
oldValue = oldValue.replace('页', '$L{页}');
|
|
33046
32571
|
}
|
|
33047
|
-
|
|
33048
|
-
|
|
33049
|
-
userID: robotID,
|
|
33050
|
-
userSig: robotInfo.userSig
|
|
33051
|
-
});
|
|
33052
|
-
} catch (err) {
|
|
33053
|
-
console.log(`[AI chat]${robotInfo.name}登录失败`, err);
|
|
33054
|
-
let code = err.code;
|
|
33055
|
-
if (code == 70001) {
|
|
33056
|
-
console.log(`[AI chat]${robotInfo.name}UserSig过期,重新生成userSig`);
|
|
33057
|
-
let newUserSig = await this.generateUserSigAndUpdate(robotID);
|
|
33058
|
-
try {
|
|
33059
|
-
await this.chatAIClient.login({
|
|
33060
|
-
userID: robotID,
|
|
33061
|
-
userSig: newUserSig
|
|
33062
|
-
});
|
|
33063
|
-
this.sendMessageToChatServer(robotID, messageOption);
|
|
33064
|
-
return;
|
|
33065
|
-
} catch (err) {
|
|
33066
|
-
console.log(`[AI chat]${robotInfo.name}重新登录失败`, err);
|
|
33067
|
-
return;
|
|
33068
|
-
}
|
|
33069
|
-
}
|
|
32572
|
+
if (innerHTML.includes("条")) {
|
|
32573
|
+
oldValue = oldValue.replace('条', '$L{条}');
|
|
33070
32574
|
}
|
|
33071
|
-
|
|
33072
|
-
|
|
33073
|
-
|
|
33074
|
-
|
|
33075
|
-
|
|
33076
|
-
|
|
33077
|
-
}, err => {
|
|
33078
|
-
console.log(`[AI chat]${robotInfo.name}发送失败`, err);
|
|
33079
|
-
});
|
|
33080
|
-
} else {
|
|
33081
|
-
let messageCache = this.getAIRobotCacheMessagesByID(robotID);
|
|
33082
|
-
messageCache.push(messageOption);
|
|
33083
|
-
console.log(`[AI chat]${robotInfo.name}未就绪,缓存后消息:`, messageCache);
|
|
32575
|
+
let tempHTMLMatch = {
|
|
32576
|
+
oldValue: oldValue
|
|
32577
|
+
};
|
|
32578
|
+
checkResult.result = true;
|
|
32579
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32580
|
+
return checkResult;
|
|
33084
32581
|
}
|
|
33085
32582
|
}
|
|
33086
|
-
|
|
33087
|
-
|
|
33088
|
-
let
|
|
33089
|
-
|
|
33090
|
-
|
|
33091
|
-
|
|
33092
|
-
|
|
33093
|
-
|
|
33094
|
-
|
|
33095
|
-
|
|
33096
|
-
|
|
33097
|
-
case "TIMVideoFileElem":
|
|
33098
|
-
break;
|
|
33099
|
-
case "TIMFileElem":
|
|
33100
|
-
break;
|
|
33101
|
-
default:
|
|
33102
|
-
break;
|
|
32583
|
+
// 检查删除确认对话框标题
|
|
32584
|
+
if (classes.contains("ant-popover-message-title")) {
|
|
32585
|
+
let innerHTML = element.innerHTML;
|
|
32586
|
+
if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
|
|
32587
|
+
// console.log("检查smardaten平台删除提问对话框:",innerHTML);
|
|
32588
|
+
let tempHTMLMatch = {
|
|
32589
|
+
oldValue: '$L{操作确认:删除?}'
|
|
32590
|
+
};
|
|
32591
|
+
checkResult.result = true;
|
|
32592
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32593
|
+
return checkResult;
|
|
33103
32594
|
}
|
|
33104
|
-
let cloudCustomData = message.cloudCustomData || {};
|
|
33105
|
-
let conversation_id = cloudCustomData.conversation_id || "";
|
|
33106
|
-
let params = {
|
|
33107
|
-
prompt: prompt,
|
|
33108
|
-
params: param || {},
|
|
33109
|
-
robotKey: robotInfo.password,
|
|
33110
|
-
conversation_id: conversation_id || "",
|
|
33111
|
-
userID: message.from || ""
|
|
33112
|
-
};
|
|
33113
|
-
return params;
|
|
33114
32595
|
}
|
|
33115
|
-
|
|
33116
|
-
|
|
32596
|
+
// 检查删除确认对话框按钮 取消 确认
|
|
32597
|
+
if (classes.contains("ant-btn")) {
|
|
32598
|
+
let innerHTML = element.innerHTML;
|
|
32599
|
+
if (innerHTML.includes("Cancel") || innerHTML.includes("取消")) {
|
|
32600
|
+
// console.log("检查smardaten平台 Tip提问取消删除按钮:",innerHTML);
|
|
32601
|
+
let tempHTMLMatch = {
|
|
32602
|
+
oldValue: '$L{取消}'
|
|
32603
|
+
};
|
|
32604
|
+
checkResult.result = true;
|
|
32605
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32606
|
+
return checkResult;
|
|
32607
|
+
}
|
|
32608
|
+
if (innerHTML.includes("确定") || innerHTML.includes("OK")) {
|
|
32609
|
+
// console.log("检查smardaten平台 Tip提问确认删除按钮:",innerHTML);
|
|
32610
|
+
let tempHTMLMatch = {
|
|
32611
|
+
oldValue: '$L{确定}'
|
|
32612
|
+
};
|
|
32613
|
+
checkResult.result = true;
|
|
32614
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32615
|
+
return checkResult;
|
|
32616
|
+
}
|
|
33117
32617
|
}
|
|
33118
|
-
|
|
33119
|
-
|
|
33120
|
-
|
|
33121
|
-
|
|
33122
|
-
|
|
32618
|
+
return checkResult;
|
|
32619
|
+
};
|
|
32620
|
+
;// ./src/api/i18n/smardaten_i18n/catalog_i18n.js
|
|
33123
32621
|
|
|
33124
|
-
const
|
|
33125
|
-
|
|
33126
|
-
|
|
33127
|
-
|
|
33128
|
-
"groupID": groupID
|
|
33129
|
-
}
|
|
32622
|
+
const catalog_i18n_check = element => {
|
|
32623
|
+
const checkResult = {
|
|
32624
|
+
result: false,
|
|
32625
|
+
innerHTMLMatch: null
|
|
33130
32626
|
};
|
|
33131
|
-
|
|
33132
|
-
|
|
33133
|
-
|
|
33134
|
-
}
|
|
33135
|
-
|
|
33136
|
-
let
|
|
33137
|
-
|
|
33138
|
-
|
|
33139
|
-
|
|
33140
|
-
|
|
33141
|
-
|
|
33142
|
-
|
|
33143
|
-
|
|
33144
|
-
|
|
33145
|
-
|
|
33146
|
-
|
|
33147
|
-
|
|
33148
|
-
|
|
33149
|
-
|
|
33150
|
-
|
|
33151
|
-
|
|
33152
|
-
|
|
33153
|
-
|
|
33154
|
-
|
|
33155
|
-
|
|
33156
|
-
|
|
33157
|
-
|
|
33158
|
-
|
|
33159
|
-
getPortalAccessToken: async data => {
|
|
33160
|
-
let appKey = data.appKey;
|
|
33161
|
-
let appSecret = data.appSecret;
|
|
33162
|
-
return getPortalAccessToken(appKey, appSecret);
|
|
33163
|
-
},
|
|
33164
|
-
getPortalUserInfo: async data => {
|
|
33165
|
-
let code = data.code;
|
|
33166
|
-
let access_token = data.access_token;
|
|
33167
|
-
return getPortalUserInfo(code, access_token);
|
|
33168
|
-
},
|
|
33169
|
-
getAllUserInfosByGroupID: async data => {
|
|
33170
|
-
let groupID = data.groupID;
|
|
33171
|
-
return getAllUserInfosByGroupID(groupID);
|
|
33172
|
-
},
|
|
33173
|
-
getChildrenOfficeInfosByID: async data => {
|
|
33174
|
-
let groupID = data.groupID;
|
|
33175
|
-
return getChildrenOfficeInfosByID(groupID);
|
|
33176
|
-
},
|
|
33177
|
-
getPojectDptsByUserAndGroupID: async data => {
|
|
33178
|
-
let groupID = data.groupID;
|
|
33179
|
-
let userID = data.userID;
|
|
33180
|
-
return getPojectDptsByUserAndGroupID(userID, groupID);
|
|
33181
|
-
},
|
|
33182
|
-
closeWindow: () => {
|
|
33183
|
-
// this.visable = false;
|
|
33184
|
-
return true;
|
|
33185
|
-
},
|
|
33186
|
-
addChatListener: async (listenerKey, handler) => {
|
|
33187
|
-
await addEventAction(listenerKey, handler);
|
|
33188
|
-
},
|
|
33189
|
-
fireEventToChatWindow: async (event, chart_origin, key, params, handler) => {
|
|
33190
|
-
await sendWindowMessage(event.source, chart_origin, key, params, handler);
|
|
33191
|
-
},
|
|
33192
|
-
onChatInitFinished: async () => {
|
|
33193
|
-
// this.chatInitFinish = true;
|
|
33194
|
-
},
|
|
33195
|
-
onAIAgentEvent: async (data, event) => {
|
|
33196
|
-
// this.onAIAgentEvent(data,event);
|
|
33197
|
-
},
|
|
33198
|
-
getPortalDocmentInfo: async data => {
|
|
33199
|
-
let kb_doc_id = data.kb_doc_id;
|
|
33200
|
-
let doc_info = await getPortalDocmentInfo(kb_doc_id);
|
|
33201
|
-
let urlStr = doc_info?.summary;
|
|
33202
|
-
if (urlStr) {
|
|
33203
|
-
let urlObj = JSON.parse(urlStr);
|
|
33204
|
-
if (urlObj) {
|
|
33205
|
-
let url = urlObj[0].url;
|
|
33206
|
-
let home_page = window.smardaten_api_context_path;
|
|
33207
|
-
let finalUrl = `${home_page}/storage_area/public${url}`;
|
|
33208
|
-
let fileSize = await getFileSize(finalUrl);
|
|
33209
|
-
doc_info.fileSize = fileSize;
|
|
32627
|
+
const classes = element.classList;
|
|
32628
|
+
if (!classes) {
|
|
32629
|
+
return checkResult;
|
|
32630
|
+
}
|
|
32631
|
+
let innerHTML = element.innerHTML;
|
|
32632
|
+
let oldValue = element.getAttribute("oldValue");
|
|
32633
|
+
if (!oldValue) {
|
|
32634
|
+
oldValue = innerHTML;
|
|
32635
|
+
}
|
|
32636
|
+
// 检查目录列表 名称 列
|
|
32637
|
+
if (classes.contains("catalog_name_content")) {
|
|
32638
|
+
// console.log("检查smardaten平台目录列表 元素:",innerHTML);
|
|
32639
|
+
let scriptFunction = (appID, lang) => {
|
|
32640
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32641
|
+
let scriptNodeItem = element.childNodes[i];
|
|
32642
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32643
|
+
let text = element.getAttribute("oldValue");
|
|
32644
|
+
let isTextMatch = checkTextFormat(text);
|
|
32645
|
+
if (!isTextMatch) {
|
|
32646
|
+
element.appendChild(scriptNodeItem);
|
|
32647
|
+
} else {
|
|
32648
|
+
element.removeChild(scriptNodeItem);
|
|
32649
|
+
let key = isTextMatch.key;
|
|
32650
|
+
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
32651
|
+
element.appendChild(textNode);
|
|
32652
|
+
}
|
|
32653
|
+
} else {
|
|
32654
|
+
element.appendChild(scriptNodeItem);
|
|
33210
32655
|
}
|
|
33211
32656
|
}
|
|
33212
|
-
|
|
33213
|
-
|
|
33214
|
-
|
|
33215
|
-
|
|
33216
|
-
|
|
33217
|
-
|
|
33218
|
-
|
|
33219
|
-
|
|
32657
|
+
};
|
|
32658
|
+
let tempHTMLMatch = {
|
|
32659
|
+
oldValue: oldValue,
|
|
32660
|
+
isScriptAction: true,
|
|
32661
|
+
scriptFunction: scriptFunction
|
|
32662
|
+
};
|
|
32663
|
+
checkResult.result = true;
|
|
32664
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32665
|
+
return checkResult;
|
|
32666
|
+
}
|
|
32667
|
+
if (classes.contains("catalog-tree-search")) {
|
|
32668
|
+
let scriptFunction = (appID, lang) => {
|
|
32669
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32670
|
+
let scriptNodeItem = element.childNodes[i];
|
|
32671
|
+
if (scriptNodeItem.tagName === 'INPUT') {
|
|
32672
|
+
let oldValue = scriptNodeItem.getAttribute("oldplaceholderValue");
|
|
32673
|
+
if (!oldValue) {
|
|
32674
|
+
let text = scriptNodeItem.getAttribute("placeholder");
|
|
32675
|
+
if (text) {
|
|
32676
|
+
text = `$L{${text}}`;
|
|
32677
|
+
}
|
|
32678
|
+
scriptNodeItem.setAttribute("placeholder", text);
|
|
32679
|
+
processElement(scriptNodeItem, appID, lang);
|
|
32680
|
+
}
|
|
32681
|
+
}
|
|
32682
|
+
}
|
|
32683
|
+
};
|
|
32684
|
+
let tempHTMLMatch = {
|
|
32685
|
+
oldValue: oldValue,
|
|
32686
|
+
isScriptAction: true,
|
|
32687
|
+
scriptFunction: scriptFunction
|
|
32688
|
+
};
|
|
32689
|
+
checkResult.result = true;
|
|
32690
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32691
|
+
return checkResult;
|
|
32692
|
+
}
|
|
32693
|
+
return checkResult;
|
|
33220
32694
|
};
|
|
33221
|
-
|
|
33222
|
-
;// ./src/api/dify.js
|
|
32695
|
+
;// ./src/api/i18n/commom_i18n/common_i18n.js
|
|
33223
32696
|
|
|
33224
32697
|
|
|
33225
|
-
|
|
33226
|
-
|
|
33227
|
-
|
|
33228
|
-
|
|
33229
|
-
|
|
33230
|
-
|
|
33231
|
-
|
|
33232
|
-
|
|
33233
|
-
|
|
33234
|
-
|
|
33235
|
-
request.post(serverUrl, JSON.stringify(queryData)).then(res => {
|
|
33236
|
-
console.log("发送消息成功:", res);
|
|
33237
|
-
if (successCallback) successCallback(res);
|
|
33238
|
-
}).catch(error => {
|
|
33239
|
-
console.error("发送消息失败:", error);
|
|
33240
|
-
if (errorCallback) errorCallback(error);
|
|
33241
|
-
});
|
|
33242
|
-
};
|
|
33243
|
-
const getDifyFileType = fileType => {
|
|
33244
|
-
let typeOptions = {
|
|
33245
|
-
"DOCX": "document",
|
|
33246
|
-
"TXT": "document",
|
|
33247
|
-
"MD": "document",
|
|
33248
|
-
"MARKDOWN": "document",
|
|
33249
|
-
"MDX": "document",
|
|
33250
|
-
"PDF": "document",
|
|
33251
|
-
"HTML": "document",
|
|
33252
|
-
"XLSX": "document",
|
|
33253
|
-
"XLS": "document",
|
|
33254
|
-
"VTT": "document",
|
|
33255
|
-
"DOC": "document",
|
|
33256
|
-
"CSV": "document",
|
|
33257
|
-
"EML": "document",
|
|
33258
|
-
"MSG": "document",
|
|
33259
|
-
"PPTX": "document",
|
|
33260
|
-
"PPT": "document",
|
|
33261
|
-
"XML": "document",
|
|
33262
|
-
"EPUB": "document",
|
|
33263
|
-
"JPG": "image",
|
|
33264
|
-
"JPEG": "image",
|
|
33265
|
-
"PNG": "image",
|
|
33266
|
-
"GIF": "image",
|
|
33267
|
-
"WEBP": "image",
|
|
33268
|
-
"MP3": "audio",
|
|
33269
|
-
"M4A": "audio",
|
|
33270
|
-
"WAV": "audio",
|
|
33271
|
-
"WEBM": "audio",
|
|
33272
|
-
"MPGA": "audio",
|
|
33273
|
-
"MP4": "video",
|
|
33274
|
-
"MOV": "video",
|
|
33275
|
-
"MPEG": "video"
|
|
32698
|
+
function getOldValueNodeText(innerHTML, index) {
|
|
32699
|
+
const container = document.createElement('div');
|
|
32700
|
+
container.innerHTML = innerHTML;
|
|
32701
|
+
const childNode = container.childNodes[index];
|
|
32702
|
+
return childNode.textContent;
|
|
32703
|
+
}
|
|
32704
|
+
const common_i18n_check = element => {
|
|
32705
|
+
const checkResult = {
|
|
32706
|
+
result: false,
|
|
32707
|
+
innerHTMLMatch: null
|
|
33276
32708
|
};
|
|
33277
|
-
|
|
33278
|
-
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33283
|
-
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
//
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
32709
|
+
// 检查目录列表 名称 列
|
|
32710
|
+
if (element.tagName === 'BUTTON' || element.tagName === 'P') {
|
|
32711
|
+
//TODO:先检查新的是否需要解析,新的不需要有可能是解析后的再次判断,如果有历史解析值,则解析
|
|
32712
|
+
//如果新的需要解析,更新缓存的历史解析值
|
|
32713
|
+
let innerHTML = element.innerHTML;
|
|
32714
|
+
let oldValue = element.getAttribute("oldValue");
|
|
32715
|
+
if (!oldValue) {
|
|
32716
|
+
oldValue = innerHTML;
|
|
32717
|
+
}
|
|
32718
|
+
let firstCheck = checkTextFormat(oldValue);
|
|
32719
|
+
let firstCheckResult = firstCheck ? true : false;
|
|
32720
|
+
// console.log("检查 button 元素:",innerHTML);
|
|
32721
|
+
// console.log("检查结果:",firstCheckResult);
|
|
32722
|
+
let scriptFunction = (appID, lang) => {
|
|
32723
|
+
let elementsArray = [];
|
|
32724
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32725
|
+
let scriptNodeItem = element.childNodes[i];
|
|
32726
|
+
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
32727
|
+
let oldValue = element.getAttribute("oldValue");
|
|
32728
|
+
// console.log("执行 button 文本节点翻译:", text);
|
|
32729
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
32730
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
32731
|
+
let isTextMatch = checkTextFormat(oldValue);
|
|
32732
|
+
if (!isTextMatch) {
|
|
32733
|
+
elementsArray.push(scriptNodeItem);
|
|
32734
|
+
} else {
|
|
32735
|
+
// console.log("执行 button 脚本节点翻译isTextMatch:", isTextMatch?true:false);
|
|
32736
|
+
// element.removeChild(scriptNodeItem);
|
|
32737
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
32738
|
+
let childNodeText = getOldValueNodeText(oldValue, i);
|
|
32739
|
+
let newValue = childNodeText;
|
|
32740
|
+
let match;
|
|
32741
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
32742
|
+
const fullMatch = match[0];
|
|
32743
|
+
const placeholderKey = match[1];
|
|
32744
|
+
const translation = i18n(placeholderKey, appID, lang);
|
|
32745
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
32746
|
+
}
|
|
32747
|
+
let textNode = document.createTextNode(newValue);
|
|
32748
|
+
elementsArray.push(textNode);
|
|
32749
|
+
}
|
|
32750
|
+
} else {
|
|
32751
|
+
elementsArray.push(scriptNodeItem);
|
|
32752
|
+
}
|
|
32753
|
+
}
|
|
32754
|
+
element.innerHTML = '';
|
|
32755
|
+
elementsArray.forEach(el => {
|
|
32756
|
+
element.appendChild(el);
|
|
32757
|
+
});
|
|
32758
|
+
};
|
|
32759
|
+
let tempHTMLMatch = {
|
|
32760
|
+
oldValue: oldValue,
|
|
32761
|
+
isScriptAction: true,
|
|
32762
|
+
scriptFunction: scriptFunction
|
|
32763
|
+
};
|
|
32764
|
+
checkResult.result = firstCheckResult;
|
|
32765
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
32766
|
+
return checkResult;
|
|
33293
32767
|
}
|
|
32768
|
+
return checkResult;
|
|
33294
32769
|
};
|
|
33295
|
-
;//
|
|
33296
|
-
var external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject = require("vue");
|
|
33297
|
-
;// ./src/api/i18n/smardaten_i18n/table_i18n.js
|
|
32770
|
+
;// ./src/api/i18n/commom_i18n/attribute_i18n.js
|
|
33298
32771
|
|
|
33299
|
-
const
|
|
32772
|
+
const attribute_i18n_check = element => {
|
|
33300
32773
|
const checkResult = {
|
|
33301
32774
|
result: false,
|
|
33302
32775
|
innerHTMLMatch: null
|
|
33303
32776
|
};
|
|
33304
|
-
|
|
33305
|
-
if (!classes) {
|
|
32777
|
+
if (!element) {
|
|
33306
32778
|
return checkResult;
|
|
33307
32779
|
}
|
|
33308
|
-
|
|
33309
|
-
|
|
33310
|
-
let
|
|
33311
|
-
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
};
|
|
32780
|
+
const checkAttributes = ["placeholder", "title"];
|
|
32781
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
32782
|
+
let attr = checkAttributes[i];
|
|
32783
|
+
let attrValue = element.getAttribute(attr) || element[attr];
|
|
32784
|
+
const attrMatch = attrValue ? checkTextFormat(attrValue) : null;
|
|
32785
|
+
if (attrMatch) {
|
|
32786
|
+
// console.log("检查元素属性 i18n 元素:", attr, attrValue);
|
|
32787
|
+
element.setAttribute(`old${attr}Value`, attrValue);
|
|
33316
32788
|
checkResult.result = true;
|
|
33317
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33318
|
-
return checkResult;
|
|
33319
32789
|
}
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
|
|
33323
|
-
|
|
33324
|
-
};
|
|
33325
|
-
|
|
33326
|
-
|
|
33327
|
-
|
|
32790
|
+
}
|
|
32791
|
+
let scriptFunction = (appID, lang) => {
|
|
32792
|
+
for (let i = 0; i < checkAttributes.length; i++) {
|
|
32793
|
+
let attr = checkAttributes[i];
|
|
32794
|
+
const oldAttrValue = element.getAttribute(`old${attr}Value`);
|
|
32795
|
+
if (oldAttrValue) {
|
|
32796
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
32797
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
32798
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
32799
|
+
let newAttrValue = oldAttrValue;
|
|
32800
|
+
let match;
|
|
32801
|
+
while ((match = regex.exec(oldAttrValue)) !== null) {
|
|
32802
|
+
const fullMatch = match[0];
|
|
32803
|
+
const attrKey = match[1];
|
|
32804
|
+
const translation = i18n(attrKey, appID, lang);
|
|
32805
|
+
newAttrValue = newAttrValue.replace(fullMatch, translation);
|
|
32806
|
+
}
|
|
32807
|
+
// 更新元素的placeholder属性
|
|
32808
|
+
element.setAttribute(attr, newAttrValue);
|
|
32809
|
+
}
|
|
33328
32810
|
}
|
|
32811
|
+
};
|
|
32812
|
+
checkResult.scriptFunction = scriptFunction;
|
|
32813
|
+
return checkResult;
|
|
32814
|
+
};
|
|
32815
|
+
;// ./src/api/i18n/smardaten_i18n/calendar_i18n.js
|
|
32816
|
+
|
|
32817
|
+
|
|
32818
|
+
function convertToChineseWeekday(englishInput) {
|
|
32819
|
+
// 清理输入:去除首尾空格并转为小写
|
|
32820
|
+
const input = englishInput.trim().toLowerCase();
|
|
32821
|
+
|
|
32822
|
+
// 定义星期映射关系
|
|
32823
|
+
const weekdayMap = {
|
|
32824
|
+
'mon': '周一',
|
|
32825
|
+
'monday': '周一',
|
|
32826
|
+
'mondays': '周一',
|
|
32827
|
+
'tue': '周二',
|
|
32828
|
+
'tues': '周二',
|
|
32829
|
+
'tuesday': '周二',
|
|
32830
|
+
'tuesdays': '周二',
|
|
32831
|
+
'wed': '周三',
|
|
32832
|
+
'wednesday': '周三',
|
|
32833
|
+
'wednesdays': '周三',
|
|
32834
|
+
'thu': '周四',
|
|
32835
|
+
'thur': '周四',
|
|
32836
|
+
'thurs': '周四',
|
|
32837
|
+
'thursday': '周四',
|
|
32838
|
+
'thursdays': '周四',
|
|
32839
|
+
'fri': '周五',
|
|
32840
|
+
'friday': '周五',
|
|
32841
|
+
'fridays': '周五',
|
|
32842
|
+
'sat': '周六',
|
|
32843
|
+
'saturday': '周六',
|
|
32844
|
+
'saturdays': '周六',
|
|
32845
|
+
'sun': '周日',
|
|
32846
|
+
'sunday': '周日',
|
|
32847
|
+
'sundays': '周日'
|
|
32848
|
+
};
|
|
32849
|
+
|
|
32850
|
+
// 使用正则表达式匹配所有可能的星期格式
|
|
32851
|
+
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;
|
|
32852
|
+
|
|
32853
|
+
// 测试输入是否匹配星期格式
|
|
32854
|
+
if (!pattern.test(input)) {
|
|
32855
|
+
return '未知日期';
|
|
33329
32856
|
}
|
|
33330
|
-
|
|
33331
|
-
|
|
33332
|
-
|
|
33333
|
-
|
|
33334
|
-
|
|
33335
|
-
|
|
33336
|
-
|
|
33337
|
-
|
|
33338
|
-
|
|
33339
|
-
|
|
33340
|
-
|
|
32857
|
+
|
|
32858
|
+
// 提取基础名称(去除复数形式和句点)
|
|
32859
|
+
const baseName = input.replace(/\./g, '') // 移除所有句点
|
|
32860
|
+
.replace(/s$/, ''); // 移除结尾的's'(复数形式)
|
|
32861
|
+
|
|
32862
|
+
// 特殊处理周四的多种缩写形式
|
|
32863
|
+
const normalized = baseName.startsWith('thu') ? 'thu' : baseName.slice(0, 3);
|
|
32864
|
+
|
|
32865
|
+
// 映射到中文名称
|
|
32866
|
+
return weekdayMap[normalized] || weekdayMap[baseName] || '未知日期';
|
|
32867
|
+
}
|
|
32868
|
+
function extractYearMonth(str) {
|
|
32869
|
+
const regex = /(\d{4})年(0?[1-9]|1[0-2])月/g;
|
|
32870
|
+
const matches = str.matchAll(regex);
|
|
32871
|
+
const result = [];
|
|
32872
|
+
for (const match of matches) {
|
|
32873
|
+
const year = parseInt(match[1], 10);
|
|
32874
|
+
const month = parseInt(match[2], 10);
|
|
32875
|
+
result.push({
|
|
32876
|
+
year,
|
|
32877
|
+
month
|
|
32878
|
+
});
|
|
32879
|
+
}
|
|
32880
|
+
return result;
|
|
32881
|
+
}
|
|
32882
|
+
function extractDayNumbers(text) {
|
|
32883
|
+
// 匹配两种情况:
|
|
32884
|
+
// 1. "数字+日"格式(如"5日"、"12日")
|
|
32885
|
+
// 2. 独立的1-31数字(前后有边界)
|
|
32886
|
+
const regex = /(?:(\b(0?[1-9]|[12]\d|3[01])\b)(?=日))|(\b(0?[1-9]|[12]\d|3[01])\b)/g;
|
|
32887
|
+
const results = [];
|
|
32888
|
+
let match;
|
|
32889
|
+
while ((match = regex.exec(text)) !== null) {
|
|
32890
|
+
// match[2] 对应第一种情况(带"日"字的数字)
|
|
32891
|
+
// match[4] 对应第二种情况(独立数字)
|
|
32892
|
+
const numStr = match[2] || match[4];
|
|
32893
|
+
if (numStr) {
|
|
32894
|
+
// 转换为整数并验证范围
|
|
32895
|
+
const day = parseInt(numStr, 10);
|
|
32896
|
+
if (day >= 1 && day <= 31) {
|
|
32897
|
+
results.push(day);
|
|
32898
|
+
}
|
|
33341
32899
|
}
|
|
33342
32900
|
}
|
|
33343
|
-
|
|
33344
|
-
|
|
33345
|
-
|
|
33346
|
-
|
|
33347
|
-
|
|
33348
|
-
|
|
33349
|
-
|
|
33350
|
-
|
|
33351
|
-
|
|
33352
|
-
|
|
33353
|
-
|
|
33354
|
-
|
|
33355
|
-
|
|
33356
|
-
|
|
33357
|
-
|
|
33358
|
-
|
|
33359
|
-
|
|
33360
|
-
|
|
33361
|
-
|
|
33362
|
-
|
|
33363
|
-
|
|
33364
|
-
|
|
33365
|
-
|
|
33366
|
-
|
|
33367
|
-
|
|
33368
|
-
|
|
33369
|
-
|
|
33370
|
-
|
|
33371
|
-
|
|
33372
|
-
|
|
33373
|
-
|
|
33374
|
-
|
|
33375
|
-
|
|
33376
|
-
|
|
33377
|
-
|
|
33378
|
-
|
|
33379
|
-
|
|
33380
|
-
|
|
32901
|
+
return results;
|
|
32902
|
+
}
|
|
32903
|
+
function extractNumbersFromScenarios(text) {
|
|
32904
|
+
// 定义两种场景的正则表达式
|
|
32905
|
+
const patterns = [
|
|
32906
|
+
// 场景1: "Other X pieces of data"
|
|
32907
|
+
/Other\s+(\d+)\s+pieces of data/gi,
|
|
32908
|
+
// 场景2: "其他 X 条记录"
|
|
32909
|
+
/其他\s+(\d+)\s+条记录/g];
|
|
32910
|
+
const results = [];
|
|
32911
|
+
|
|
32912
|
+
// 遍历所有模式进行匹配
|
|
32913
|
+
patterns.forEach(pattern => {
|
|
32914
|
+
let match;
|
|
32915
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
32916
|
+
// 提取捕获组中的数字
|
|
32917
|
+
const number = parseInt(match[1], 10);
|
|
32918
|
+
results.push({
|
|
32919
|
+
scenario: match[0],
|
|
32920
|
+
// 完整匹配的字符串
|
|
32921
|
+
number: number,
|
|
32922
|
+
// 提取的数字
|
|
32923
|
+
type: pattern.source.includes('Other') ? 'English' : 'Chinese'
|
|
32924
|
+
});
|
|
32925
|
+
}
|
|
32926
|
+
});
|
|
32927
|
+
return results;
|
|
32928
|
+
}
|
|
32929
|
+
const calendar_i18n_check = element => {
|
|
32930
|
+
const checkResult = {
|
|
32931
|
+
result: false,
|
|
32932
|
+
innerHTMLMatch: null
|
|
32933
|
+
};
|
|
32934
|
+
const classes = element.classList;
|
|
32935
|
+
if (!classes) {
|
|
32936
|
+
return checkResult;
|
|
32937
|
+
}
|
|
32938
|
+
// 检查日历标题
|
|
32939
|
+
if (classes.contains("fc-toolbar-title")) {
|
|
32940
|
+
let scriptFunction = (appID, lang) => {
|
|
32941
|
+
let oldValue = element.getAttribute("oldValue");
|
|
32942
|
+
let yearMonthList = extractYearMonth(oldValue);
|
|
32943
|
+
if (yearMonthList.length > 0) {
|
|
32944
|
+
let yearMonth = yearMonthList[0];
|
|
32945
|
+
let year = yearMonth.year;
|
|
32946
|
+
let month = yearMonth.month;
|
|
32947
|
+
let newInnerHTML = `${year}/${month}`;
|
|
32948
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
32949
|
+
if (lang === "zh-CN") {
|
|
32950
|
+
newInnerHTML = `${year}年${month}月`;
|
|
33381
32951
|
}
|
|
33382
|
-
|
|
32952
|
+
element.innerHTML = newInnerHTML;
|
|
32953
|
+
}
|
|
32954
|
+
};
|
|
32955
|
+
let innerHTML = element.innerHTML;
|
|
32956
|
+
let testRule = /^\d{4}年(0?[1-9]|1[0-2])月$/;
|
|
32957
|
+
if (testRule.test(innerHTML)) {
|
|
32958
|
+
// console.log("检查smardaten平台日历标题 元素:",innerHTML);
|
|
33383
32959
|
let tempHTMLMatch = {
|
|
32960
|
+
oldValue: innerHTML,
|
|
33384
32961
|
isScriptAction: true,
|
|
33385
32962
|
scriptFunction: scriptFunction
|
|
33386
32963
|
};
|
|
@@ -33389,1074 +32966,1504 @@ const check = element => {
|
|
|
33389
32966
|
return checkResult;
|
|
33390
32967
|
}
|
|
33391
32968
|
}
|
|
33392
|
-
//
|
|
33393
|
-
if (classes.contains("
|
|
32969
|
+
// 检查日历今天按钮
|
|
32970
|
+
if (classes.contains("fc-today-button")) {
|
|
33394
32971
|
let innerHTML = element.innerHTML;
|
|
33395
|
-
if (innerHTML.includes("
|
|
33396
|
-
// console.log("检查smardaten
|
|
33397
|
-
let scriptFunction = (appID, lang) => {
|
|
33398
|
-
let scriptNode = null;
|
|
33399
|
-
for (let node of element.childNodes) {
|
|
33400
|
-
// 检查是否为文本节点且包含"Total"
|
|
33401
|
-
if (node.tagName === "INPUT") {
|
|
33402
|
-
scriptNode = node;
|
|
33403
|
-
}
|
|
33404
|
-
}
|
|
33405
|
-
let scriptNodes = [{
|
|
33406
|
-
nodeType: Node.TEXT_NODE,
|
|
33407
|
-
key: '跳至'
|
|
33408
|
-
}, {
|
|
33409
|
-
nodeType: "SCRIPTNODE",
|
|
33410
|
-
node: scriptNode
|
|
33411
|
-
}, {
|
|
33412
|
-
nodeType: Node.TEXT_NODE,
|
|
33413
|
-
key: '页'
|
|
33414
|
-
}];
|
|
33415
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33416
|
-
let childNode = element.childNodes[i];
|
|
33417
|
-
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
33418
|
-
element.removeChild(childNode);
|
|
33419
|
-
}
|
|
33420
|
-
}
|
|
33421
|
-
for (let i = 0; i < scriptNodes.length; i++) {
|
|
33422
|
-
let scriptNodeItem = scriptNodes[i];
|
|
33423
|
-
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33424
|
-
let textNode = document.createTextNode(i18n(scriptNodeItem.key, appID, lang) || scriptNodeItem.key);
|
|
33425
|
-
element.appendChild(textNode);
|
|
33426
|
-
}
|
|
33427
|
-
if (scriptNodeItem.nodeType === "SCRIPTNODE") {
|
|
33428
|
-
element.appendChild(scriptNodeItem.node);
|
|
33429
|
-
}
|
|
33430
|
-
}
|
|
33431
|
-
};
|
|
32972
|
+
if (innerHTML.includes("今天") || innerHTML.includes("today")) {
|
|
32973
|
+
// console.log("检查smardaten平台日历 今天 元素:",innerHTML);
|
|
33432
32974
|
let tempHTMLMatch = {
|
|
33433
|
-
|
|
33434
|
-
scriptFunction: scriptFunction
|
|
32975
|
+
oldValue: '$L{今天}'
|
|
33435
32976
|
};
|
|
33436
32977
|
checkResult.result = true;
|
|
33437
32978
|
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33438
32979
|
return checkResult;
|
|
33439
32980
|
}
|
|
33440
32981
|
}
|
|
33441
|
-
//
|
|
33442
|
-
if (classes.contains("
|
|
32982
|
+
// 检查日历标题
|
|
32983
|
+
if (classes.contains("fullCalendar_title_value")) {
|
|
33443
32984
|
let innerHTML = element.innerHTML;
|
|
33444
|
-
|
|
33445
|
-
|
|
33446
|
-
|
|
33447
|
-
|
|
33448
|
-
|
|
33449
|
-
|
|
33450
|
-
if (innerHTML.includes("页")) {
|
|
33451
|
-
oldValue = oldValue.replace('页', '$L{页}');
|
|
33452
|
-
}
|
|
33453
|
-
if (innerHTML.includes("条")) {
|
|
33454
|
-
oldValue = oldValue.replace('条', '$L{条}');
|
|
33455
|
-
}
|
|
32985
|
+
const regex = /周[一二三四五六日]/;
|
|
32986
|
+
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;
|
|
32987
|
+
let match = innerHTML.match(regex);
|
|
32988
|
+
if (match) {
|
|
32989
|
+
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
32990
|
+
let day = match[0];
|
|
33456
32991
|
let tempHTMLMatch = {
|
|
33457
|
-
oldValue:
|
|
32992
|
+
oldValue: `$L{${day}}`
|
|
33458
32993
|
};
|
|
33459
32994
|
checkResult.result = true;
|
|
33460
32995
|
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33461
32996
|
return checkResult;
|
|
33462
32997
|
}
|
|
33463
|
-
|
|
33464
|
-
|
|
33465
|
-
|
|
33466
|
-
|
|
33467
|
-
if (innerHTML.includes("确认执行:") || innerHTML.includes("Confirm Execution:")) {
|
|
33468
|
-
// console.log("检查smardaten平台删除提问对话框:",innerHTML);
|
|
32998
|
+
match = innerHTML.match(regex_en);
|
|
32999
|
+
if (match) {
|
|
33000
|
+
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33001
|
+
let day = match[0];
|
|
33469
33002
|
let tempHTMLMatch = {
|
|
33470
|
-
oldValue:
|
|
33003
|
+
oldValue: `$L{${convertToChineseWeekday(day)}}`
|
|
33471
33004
|
};
|
|
33472
33005
|
checkResult.result = true;
|
|
33473
33006
|
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33474
33007
|
return checkResult;
|
|
33475
33008
|
}
|
|
33476
33009
|
}
|
|
33477
|
-
|
|
33478
|
-
if (classes.contains("
|
|
33010
|
+
//日期单元格
|
|
33011
|
+
if (classes.contains("fc-daygrid-day-number")) {
|
|
33012
|
+
let scriptFunction = (appID, lang) => {
|
|
33013
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33014
|
+
let result = extractDayNumbers(oldValue);
|
|
33015
|
+
if (result && result.length > 0) {
|
|
33016
|
+
let day = result[0];
|
|
33017
|
+
let newInnerHTML = `${day}`;
|
|
33018
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33019
|
+
if (lang === "zh-CN") {
|
|
33020
|
+
newInnerHTML = `${day}日`;
|
|
33021
|
+
}
|
|
33022
|
+
element.innerHTML = newInnerHTML;
|
|
33023
|
+
}
|
|
33024
|
+
};
|
|
33479
33025
|
let innerHTML = element.innerHTML;
|
|
33480
|
-
|
|
33481
|
-
|
|
33026
|
+
let match = extractDayNumbers(innerHTML);
|
|
33027
|
+
if (match.length > 0) {
|
|
33028
|
+
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33482
33029
|
let tempHTMLMatch = {
|
|
33483
|
-
oldValue:
|
|
33030
|
+
oldValue: innerHTML,
|
|
33031
|
+
isScriptAction: true,
|
|
33032
|
+
scriptFunction: scriptFunction
|
|
33484
33033
|
};
|
|
33485
33034
|
checkResult.result = true;
|
|
33486
33035
|
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33487
33036
|
return checkResult;
|
|
33488
33037
|
}
|
|
33489
|
-
|
|
33490
|
-
|
|
33038
|
+
}
|
|
33039
|
+
// 日历更多按钮
|
|
33040
|
+
if (classes.contains("fc-daygrid-more-link")) {
|
|
33041
|
+
let scriptFunction = (appID, lang) => {
|
|
33042
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33043
|
+
let result = extractNumbersFromScenarios(oldValue);
|
|
33044
|
+
if (result && result.length > 0) {
|
|
33045
|
+
let day = result[0]["number"];
|
|
33046
|
+
let newInnerHTML = "另外${X}条数据";
|
|
33047
|
+
newInnerHTML = i18n(newInnerHTML, appID, lang);
|
|
33048
|
+
newInnerHTML = newInnerHTML.replace("${X}", day);
|
|
33049
|
+
element.innerHTML = newInnerHTML;
|
|
33050
|
+
}
|
|
33051
|
+
};
|
|
33052
|
+
let innerHTML = element.innerHTML;
|
|
33053
|
+
let match = extractNumbersFromScenarios(innerHTML);
|
|
33054
|
+
if (match.length > 0) {
|
|
33055
|
+
// console.log("检查smardaten平台日历 更多 元素:",innerHTML);
|
|
33491
33056
|
let tempHTMLMatch = {
|
|
33492
|
-
oldValue:
|
|
33057
|
+
oldValue: innerHTML,
|
|
33058
|
+
isScriptAction: true,
|
|
33059
|
+
scriptFunction: scriptFunction
|
|
33493
33060
|
};
|
|
33494
33061
|
checkResult.result = true;
|
|
33495
33062
|
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33496
33063
|
return checkResult;
|
|
33497
33064
|
}
|
|
33498
33065
|
}
|
|
33499
|
-
|
|
33500
|
-
|
|
33501
|
-
|
|
33502
|
-
|
|
33503
|
-
const catalog_i18n_check = element => {
|
|
33504
|
-
const checkResult = {
|
|
33505
|
-
result: false,
|
|
33506
|
-
innerHTMLMatch: null
|
|
33507
|
-
};
|
|
33508
|
-
const classes = element.classList;
|
|
33509
|
-
if (!classes) {
|
|
33510
|
-
return checkResult;
|
|
33511
|
-
}
|
|
33512
|
-
let innerHTML = element.innerHTML;
|
|
33513
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33514
|
-
if (!oldValue) {
|
|
33515
|
-
oldValue = innerHTML;
|
|
33516
|
-
}
|
|
33517
|
-
// 检查目录列表 名称 列
|
|
33518
|
-
if (classes.contains("catalog_name_content")) {
|
|
33519
|
-
// console.log("检查smardaten平台目录列表 元素:",innerHTML);
|
|
33520
|
-
let scriptFunction = (appID, lang) => {
|
|
33521
|
-
for (let i = 0; i < element.childNodes.length; i++) {
|
|
33522
|
-
let scriptNodeItem = element.childNodes[i];
|
|
33523
|
-
if (scriptNodeItem.nodeType === Node.TEXT_NODE) {
|
|
33524
|
-
let text = element.getAttribute("oldValue");
|
|
33525
|
-
let isTextMatch = checkTextFormat(text);
|
|
33526
|
-
if (!isTextMatch) {
|
|
33527
|
-
element.appendChild(scriptNodeItem);
|
|
33528
|
-
} else {
|
|
33529
|
-
element.removeChild(scriptNodeItem);
|
|
33530
|
-
let key = isTextMatch.key;
|
|
33531
|
-
let textNode = document.createTextNode(i18n(key, appID, lang) || key);
|
|
33532
|
-
element.appendChild(textNode);
|
|
33533
|
-
}
|
|
33534
|
-
} else {
|
|
33535
|
-
element.appendChild(scriptNodeItem);
|
|
33536
|
-
}
|
|
33537
|
-
}
|
|
33538
|
-
};
|
|
33539
|
-
let tempHTMLMatch = {
|
|
33540
|
-
oldValue: oldValue,
|
|
33541
|
-
isScriptAction: true,
|
|
33542
|
-
scriptFunction: scriptFunction
|
|
33543
|
-
};
|
|
33544
|
-
checkResult.result = true;
|
|
33545
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33546
|
-
return checkResult;
|
|
33547
|
-
}
|
|
33548
|
-
if (classes.contains("catalog-tree-search")) {
|
|
33066
|
+
// 日历弹窗标题
|
|
33067
|
+
if (classes.contains("fc-popover-title")) {
|
|
33068
|
+
// 正则表达式匹配中文日期格式
|
|
33069
|
+
const regex = /(\d{4})年(\d{1,2})月(\d{1,2})日/g;
|
|
33549
33070
|
let scriptFunction = (appID, lang) => {
|
|
33550
|
-
|
|
33551
|
-
|
|
33552
|
-
|
|
33553
|
-
|
|
33554
|
-
|
|
33555
|
-
|
|
33556
|
-
|
|
33557
|
-
|
|
33558
|
-
|
|
33559
|
-
|
|
33560
|
-
|
|
33071
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33072
|
+
let match = oldValue.match(regex);
|
|
33073
|
+
if (match) {
|
|
33074
|
+
// 替换函数
|
|
33075
|
+
const convertedText = oldValue.replace(regex, function (match, year, month, day) {
|
|
33076
|
+
// 格式化月份和日期为两位数
|
|
33077
|
+
const formattedMonth = month.padStart(2, '0');
|
|
33078
|
+
const formattedDay = day.padStart(2, '0');
|
|
33079
|
+
let result = `${year}/${formattedMonth}/${formattedDay}`;
|
|
33080
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33081
|
+
if (lang === "zh-CN") {
|
|
33082
|
+
result = `${year}年${formattedMonth}月${formattedDay}日`;
|
|
33561
33083
|
}
|
|
33562
|
-
|
|
33084
|
+
// 返回新格式的日期
|
|
33085
|
+
return result;
|
|
33086
|
+
});
|
|
33087
|
+
element.innerHTML = convertedText;
|
|
33563
33088
|
}
|
|
33564
33089
|
};
|
|
33565
|
-
let
|
|
33566
|
-
|
|
33567
|
-
|
|
33568
|
-
|
|
33569
|
-
|
|
33570
|
-
|
|
33571
|
-
|
|
33572
|
-
|
|
33090
|
+
let innerHTML = element.innerHTML;
|
|
33091
|
+
let match = innerHTML.match(regex);
|
|
33092
|
+
if (match && match.length > 0) {
|
|
33093
|
+
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33094
|
+
let tempHTMLMatch = {
|
|
33095
|
+
oldValue: innerHTML,
|
|
33096
|
+
isScriptAction: true,
|
|
33097
|
+
scriptFunction: scriptFunction
|
|
33098
|
+
};
|
|
33099
|
+
checkResult.result = true;
|
|
33100
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33101
|
+
return checkResult;
|
|
33102
|
+
}
|
|
33573
33103
|
}
|
|
33574
33104
|
return checkResult;
|
|
33575
33105
|
};
|
|
33576
|
-
;// ./src/api/i18n/
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
function getOldValueNodeText(innerHTML, index) {
|
|
33580
|
-
const container = document.createElement('div');
|
|
33581
|
-
container.innerHTML = innerHTML;
|
|
33582
|
-
const childNode = container.childNodes[index];
|
|
33583
|
-
return childNode.textContent;
|
|
33584
|
-
}
|
|
33585
|
-
const common_i18n_check = element => {
|
|
33106
|
+
;// ./src/api/i18n/smardaten_i18n/dialog_i18n.js
|
|
33107
|
+
const dialog_i18n_check = element => {
|
|
33586
33108
|
const checkResult = {
|
|
33587
33109
|
result: false,
|
|
33588
33110
|
innerHTMLMatch: null
|
|
33589
33111
|
};
|
|
33590
|
-
|
|
33591
|
-
if (
|
|
33592
|
-
|
|
33593
|
-
|
|
33112
|
+
const classes = element.classList;
|
|
33113
|
+
if (!classes) {
|
|
33114
|
+
return checkResult;
|
|
33115
|
+
}
|
|
33116
|
+
let innerHTML = element.innerHTML;
|
|
33117
|
+
let oldValue = element.getAttribute("oldValue");
|
|
33118
|
+
if (!oldValue) {
|
|
33119
|
+
oldValue = innerHTML;
|
|
33120
|
+
}
|
|
33121
|
+
// 检查删除确认对话框按钮 取消 确认
|
|
33122
|
+
if (classes.contains("ant-modal-title")) {
|
|
33594
33123
|
let innerHTML = element.innerHTML;
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33124
|
+
if (innerHTML.includes("Select Data") || innerHTML.includes("选择数据")) {
|
|
33125
|
+
// console.log("检查smardaten平台 Tip提问取消删除按钮:",innerHTML);
|
|
33126
|
+
let tempHTMLMatch = {
|
|
33127
|
+
oldValue: '$L{选择数据}'
|
|
33128
|
+
};
|
|
33129
|
+
checkResult.result = true;
|
|
33130
|
+
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33131
|
+
return checkResult;
|
|
33598
33132
|
}
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33133
|
+
}
|
|
33134
|
+
return checkResult;
|
|
33135
|
+
};
|
|
33136
|
+
;// ./src/api/i18n/commom_view.js
|
|
33137
|
+
const commom_view_check = element => {
|
|
33138
|
+
const checkResult = {
|
|
33139
|
+
result: false
|
|
33140
|
+
};
|
|
33141
|
+
const classes = element.classList;
|
|
33142
|
+
if (!classes) {
|
|
33143
|
+
return checkResult;
|
|
33144
|
+
}
|
|
33145
|
+
// 处理容器节点
|
|
33146
|
+
if (element.tagName === "DIV" && classes.contains("template-block")) {
|
|
33603
33147
|
let scriptFunction = (appID, lang) => {
|
|
33604
|
-
let
|
|
33605
|
-
|
|
33606
|
-
|
|
33607
|
-
|
|
33608
|
-
|
|
33609
|
-
|
|
33610
|
-
|
|
33611
|
-
|
|
33612
|
-
|
|
33613
|
-
if (
|
|
33614
|
-
|
|
33615
|
-
|
|
33616
|
-
|
|
33617
|
-
|
|
33618
|
-
|
|
33619
|
-
|
|
33620
|
-
|
|
33621
|
-
|
|
33622
|
-
|
|
33623
|
-
|
|
33624
|
-
|
|
33625
|
-
|
|
33626
|
-
|
|
33148
|
+
let divDom = element.parentNode;
|
|
33149
|
+
let divDom2;
|
|
33150
|
+
let appBlockDom;
|
|
33151
|
+
let comDom;
|
|
33152
|
+
let renderDom;
|
|
33153
|
+
if (divDom && divDom.tagName === "DIV") {
|
|
33154
|
+
divDom2 = divDom.parentNode;
|
|
33155
|
+
if (divDom2 && divDom2.tagName === "DIV") {
|
|
33156
|
+
appBlockDom = divDom2.parentNode;
|
|
33157
|
+
if (appBlockDom && appBlockDom.tagName === "DIV" && appBlockDom.classList.contains("application-block")) {
|
|
33158
|
+
comDom = appBlockDom.parentNode;
|
|
33159
|
+
if (comDom && comDom.tagName === "DIV" && comDom.classList.contains("componentDiv")) {
|
|
33160
|
+
renderDom = comDom.parentNode;
|
|
33161
|
+
if (renderDom && renderDom.tagName === "DIV" && renderDom.classList.contains("render-all-blocks")) {
|
|
33162
|
+
//隐藏整个组件
|
|
33163
|
+
renderDom.style.height = "100%";
|
|
33164
|
+
comDom.style.height = "100%";
|
|
33165
|
+
appBlockDom.style.height = "100%";
|
|
33166
|
+
divDom2.style.height = "100%";
|
|
33167
|
+
divDom.style.height = "100%";
|
|
33168
|
+
element.style.height = "100%";
|
|
33169
|
+
//标记已经处理过
|
|
33170
|
+
element.setAttribute("viewDomID", generateUniqueId());
|
|
33171
|
+
}
|
|
33627
33172
|
}
|
|
33628
|
-
let textNode = document.createTextNode(newValue);
|
|
33629
|
-
elementsArray.push(textNode);
|
|
33630
33173
|
}
|
|
33631
|
-
} else {
|
|
33632
|
-
elementsArray.push(scriptNodeItem);
|
|
33633
33174
|
}
|
|
33634
33175
|
}
|
|
33635
|
-
element.innerHTML = '';
|
|
33636
|
-
elementsArray.forEach(el => {
|
|
33637
|
-
element.appendChild(el);
|
|
33638
|
-
});
|
|
33639
|
-
};
|
|
33640
|
-
let tempHTMLMatch = {
|
|
33641
|
-
oldValue: oldValue,
|
|
33642
|
-
isScriptAction: true,
|
|
33643
|
-
scriptFunction: scriptFunction
|
|
33644
33176
|
};
|
|
33645
|
-
checkResult.result =
|
|
33646
|
-
checkResult.
|
|
33177
|
+
checkResult.result = true;
|
|
33178
|
+
checkResult.scriptFunction = scriptFunction;
|
|
33647
33179
|
return checkResult;
|
|
33648
33180
|
}
|
|
33649
33181
|
return checkResult;
|
|
33650
33182
|
};
|
|
33651
|
-
|
|
33183
|
+
function generateUniqueId() {
|
|
33184
|
+
return `rjview_${Date.now()}`;
|
|
33185
|
+
}
|
|
33186
|
+
;// ./src/api/i18n/i18n.js
|
|
33652
33187
|
|
|
33653
|
-
|
|
33654
|
-
|
|
33655
|
-
|
|
33656
|
-
|
|
33657
|
-
|
|
33658
|
-
|
|
33659
|
-
|
|
33660
|
-
|
|
33661
|
-
|
|
33662
|
-
|
|
33663
|
-
|
|
33664
|
-
|
|
33665
|
-
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
|
|
33669
|
-
checkResult.result = true;
|
|
33188
|
+
|
|
33189
|
+
|
|
33190
|
+
|
|
33191
|
+
|
|
33192
|
+
|
|
33193
|
+
|
|
33194
|
+
|
|
33195
|
+
|
|
33196
|
+
|
|
33197
|
+
|
|
33198
|
+
|
|
33199
|
+
|
|
33200
|
+
const getLanguages = async appID => {
|
|
33201
|
+
let queryData = {
|
|
33202
|
+
param: {
|
|
33203
|
+
appID: appID
|
|
33670
33204
|
}
|
|
33671
|
-
}
|
|
33672
|
-
let
|
|
33673
|
-
|
|
33674
|
-
|
|
33675
|
-
|
|
33676
|
-
|
|
33677
|
-
|
|
33678
|
-
|
|
33679
|
-
|
|
33680
|
-
|
|
33681
|
-
|
|
33682
|
-
|
|
33683
|
-
|
|
33684
|
-
|
|
33685
|
-
|
|
33686
|
-
|
|
33687
|
-
|
|
33688
|
-
|
|
33689
|
-
element.setAttribute(attr, newAttrValue);
|
|
33690
|
-
}
|
|
33205
|
+
};
|
|
33206
|
+
let response = await request.post(`/dataservice/rest/orchestration/getAppLanguages`, queryData);
|
|
33207
|
+
let resultDatas = response.data.resultDatas || [];
|
|
33208
|
+
return resultDatas;
|
|
33209
|
+
};
|
|
33210
|
+
const i18n = (key, appID, localID) => {
|
|
33211
|
+
let result = window.customI18nObject?.get(`${appID}-${key}-${localID}`) || key;
|
|
33212
|
+
return result;
|
|
33213
|
+
};
|
|
33214
|
+
function i18nText(key) {
|
|
33215
|
+
let app_id = getPoratlAppID();
|
|
33216
|
+
let langID = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33217
|
+
return i18n(key, app_id, langID);
|
|
33218
|
+
}
|
|
33219
|
+
const loadi18nTexts = async appID => {
|
|
33220
|
+
let queryData = {
|
|
33221
|
+
param: {
|
|
33222
|
+
appID: appID
|
|
33691
33223
|
}
|
|
33692
33224
|
};
|
|
33693
|
-
|
|
33694
|
-
|
|
33225
|
+
let response = await request.post(`/dataservice/rest/orchestration/getAllTexts`, queryData);
|
|
33226
|
+
let resultDatas = response.data.resultDatas || [];
|
|
33227
|
+
window.customI18nObject = new Map();
|
|
33228
|
+
for (let item of resultDatas) {
|
|
33229
|
+
window.customI18nObject.set(`${appID}-${item.key}-${item.lang}`, item.value);
|
|
33230
|
+
}
|
|
33695
33231
|
};
|
|
33696
|
-
;// ./src/api/i18n/smardaten_i18n/calendar_i18n.js
|
|
33697
33232
|
|
|
33233
|
+
/**
|
|
33234
|
+
* 检查元素是否有子DOM元素
|
|
33235
|
+
* @param {HTMLElement} element - 要检查的DOM元素
|
|
33236
|
+
* @returns {boolean} - 是否有子元素
|
|
33237
|
+
*/
|
|
33238
|
+
function hasChildElements(element) {
|
|
33239
|
+
return element && element.children?.length > 0;
|
|
33240
|
+
}
|
|
33698
33241
|
|
|
33699
|
-
|
|
33700
|
-
|
|
33701
|
-
|
|
33242
|
+
/**
|
|
33243
|
+
* 检查文本是否匹配$L{...}格式
|
|
33244
|
+
* @param {string} text - 要检查的文本
|
|
33245
|
+
* @returns {Object|null} - 匹配结果或null
|
|
33246
|
+
*/
|
|
33247
|
+
function checkTextFormat(text) {
|
|
33248
|
+
if (!text) return null;
|
|
33249
|
+
const regex = /\$L\{([^}]+)\}/;
|
|
33250
|
+
const match = text.match(regex);
|
|
33251
|
+
if (match) {
|
|
33252
|
+
return {
|
|
33253
|
+
fullMatch: match[0],
|
|
33254
|
+
key: match[1]
|
|
33255
|
+
};
|
|
33256
|
+
}
|
|
33257
|
+
return null;
|
|
33258
|
+
}
|
|
33259
|
+
function i18n_generateUniqueId() {
|
|
33260
|
+
window.idCounter = window.idCounter || 0;
|
|
33261
|
+
return `i18n_${Date.now()}_${window.idCounter++}`;
|
|
33262
|
+
}
|
|
33702
33263
|
|
|
33703
|
-
|
|
33704
|
-
|
|
33705
|
-
|
|
33706
|
-
|
|
33707
|
-
|
|
33708
|
-
|
|
33709
|
-
|
|
33710
|
-
|
|
33711
|
-
|
|
33712
|
-
'wed': '周三',
|
|
33713
|
-
'wednesday': '周三',
|
|
33714
|
-
'wednesdays': '周三',
|
|
33715
|
-
'thu': '周四',
|
|
33716
|
-
'thur': '周四',
|
|
33717
|
-
'thurs': '周四',
|
|
33718
|
-
'thursday': '周四',
|
|
33719
|
-
'thursdays': '周四',
|
|
33720
|
-
'fri': '周五',
|
|
33721
|
-
'friday': '周五',
|
|
33722
|
-
'fridays': '周五',
|
|
33723
|
-
'sat': '周六',
|
|
33724
|
-
'saturday': '周六',
|
|
33725
|
-
'saturdays': '周六',
|
|
33726
|
-
'sun': '周日',
|
|
33727
|
-
'sunday': '周日',
|
|
33728
|
-
'sundays': '周日'
|
|
33264
|
+
/**
|
|
33265
|
+
* 检查平台特定元素并返回匹配结果
|
|
33266
|
+
* @param {*} element
|
|
33267
|
+
* @returns
|
|
33268
|
+
*/
|
|
33269
|
+
function checkPlatformElementContent(element) {
|
|
33270
|
+
const checkContentResult = {
|
|
33271
|
+
result: false,
|
|
33272
|
+
innerHTMLMatch: null
|
|
33729
33273
|
};
|
|
33274
|
+
let checkArr = [check, catalog_i18n_check, calendar_i18n_check, dialog_i18n_check, common_i18n_check];
|
|
33275
|
+
for (let i = 0; i < checkArr.length; i++) {
|
|
33276
|
+
let checkFunc = checkArr[i];
|
|
33277
|
+
let checkContentResult = checkFunc(element);
|
|
33278
|
+
if (checkContentResult.result) {
|
|
33279
|
+
return checkContentResult;
|
|
33280
|
+
}
|
|
33281
|
+
}
|
|
33282
|
+
return checkContentResult;
|
|
33283
|
+
}
|
|
33284
|
+
function processElement(element) {
|
|
33285
|
+
if (!element) {
|
|
33286
|
+
return false;
|
|
33287
|
+
}
|
|
33730
33288
|
|
|
33731
|
-
//
|
|
33732
|
-
|
|
33289
|
+
// 仅处理元素节点
|
|
33290
|
+
if (element && element.nodeType !== Node.ELEMENT_NODE) {
|
|
33291
|
+
return false;
|
|
33292
|
+
}
|
|
33733
33293
|
|
|
33734
|
-
//
|
|
33735
|
-
|
|
33736
|
-
|
|
33294
|
+
// 如果元素有子元素,递归处理子元素
|
|
33295
|
+
const hasChildren = hasChildElements(element);
|
|
33296
|
+
if (hasChildren) {
|
|
33297
|
+
let children = element.children;
|
|
33298
|
+
for (let i = 0; i < children.length; i++) {
|
|
33299
|
+
let child = children[i];
|
|
33300
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
33301
|
+
let childLocalDomID = child.getAttribute("localDomID");
|
|
33302
|
+
// 如果子元素有localDomID但不在缓存中,移除localDomID属性
|
|
33303
|
+
if (childLocalDomID && window.i18nElementsMap && !window.i18nElementsMap.has(childLocalDomID)) {
|
|
33304
|
+
unProcessElement(child);
|
|
33305
|
+
}
|
|
33306
|
+
}
|
|
33307
|
+
processElement(children[i]);
|
|
33308
|
+
}
|
|
33737
33309
|
}
|
|
33738
33310
|
|
|
33739
|
-
//
|
|
33740
|
-
|
|
33741
|
-
|
|
33311
|
+
// 检查innerHTML是否匹配(仅对没有子元素的元素)
|
|
33312
|
+
let innerHTMLMatch = null;
|
|
33313
|
+
const attrCheckResult = attribute_i18n_check(element);
|
|
33314
|
+
if (attrCheckResult.result) {
|
|
33315
|
+
console.log("检查到属性匹配元素:", element);
|
|
33316
|
+
}
|
|
33742
33317
|
|
|
33743
|
-
|
|
33744
|
-
const
|
|
33318
|
+
//检查是否是smardaten平台元素
|
|
33319
|
+
const checkContentResult = checkPlatformElementContent(element);
|
|
33320
|
+
if (checkContentResult.result) {
|
|
33321
|
+
innerHTMLMatch = checkContentResult.innerHTMLMatch;
|
|
33322
|
+
element.setAttribute("oldValue", innerHTMLMatch.oldValue);
|
|
33323
|
+
} else {
|
|
33324
|
+
if (!hasChildren) {
|
|
33325
|
+
//如果存在历史值,说明之前解析过,有可能是值需要刷新触发
|
|
33326
|
+
let newValue = element.innerHTML;
|
|
33327
|
+
let newMatch = checkTextFormat(newValue);
|
|
33328
|
+
if (newMatch) {
|
|
33329
|
+
innerHTMLMatch = newMatch;
|
|
33330
|
+
} else {
|
|
33331
|
+
newValue = element.getAttribute("oldValue");
|
|
33332
|
+
if (!newValue) {
|
|
33333
|
+
newValue = element.innerHTML;
|
|
33334
|
+
}
|
|
33335
|
+
innerHTMLMatch = checkTextFormat(newValue);
|
|
33336
|
+
}
|
|
33337
|
+
if (innerHTMLMatch) {
|
|
33338
|
+
// console.log("检查到innerHTML匹配元素:",element);
|
|
33339
|
+
element.setAttribute("oldValue", newValue);
|
|
33340
|
+
}
|
|
33341
|
+
}
|
|
33342
|
+
}
|
|
33745
33343
|
|
|
33746
|
-
//
|
|
33747
|
-
|
|
33748
|
-
|
|
33749
|
-
function extractYearMonth(str) {
|
|
33750
|
-
const regex = /(\d{4})年(0?[1-9]|1[0-2])月/g;
|
|
33751
|
-
const matches = str.matchAll(regex);
|
|
33752
|
-
const result = [];
|
|
33753
|
-
for (const match of matches) {
|
|
33754
|
-
const year = parseInt(match[1], 10);
|
|
33755
|
-
const month = parseInt(match[2], 10);
|
|
33756
|
-
result.push({
|
|
33757
|
-
year,
|
|
33758
|
-
month
|
|
33759
|
-
});
|
|
33344
|
+
// 如果没有匹配的内容,则不处理
|
|
33345
|
+
if (!innerHTMLMatch && !checkContentResult.result && !attrCheckResult.result) {
|
|
33346
|
+
return false;
|
|
33760
33347
|
}
|
|
33761
|
-
|
|
33348
|
+
let elementId = element.getAttribute("localDomID");
|
|
33349
|
+
if (!elementId) {
|
|
33350
|
+
elementId = i18n_generateUniqueId();
|
|
33351
|
+
} else {
|
|
33352
|
+
// 已经处理过的元素跳过
|
|
33353
|
+
return false;
|
|
33354
|
+
}
|
|
33355
|
+
element.setAttribute("localDomID", elementId);
|
|
33356
|
+
if (!window.i18nElementsMap) {
|
|
33357
|
+
window.i18nElementsMap = new Map();
|
|
33358
|
+
}
|
|
33359
|
+
// 添加到Map缓存
|
|
33360
|
+
window.i18nElementsMap.set(elementId, {
|
|
33361
|
+
dom: element,
|
|
33362
|
+
id: elementId,
|
|
33363
|
+
isScriptAction: innerHTMLMatch ? innerHTMLMatch.isScriptAction || false : false,
|
|
33364
|
+
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
|
|
33365
|
+
isAttibuteAction: attrCheckResult.result,
|
|
33366
|
+
attrFunction: attrCheckResult.scriptFunction || null
|
|
33367
|
+
});
|
|
33368
|
+
// console.log("添加后元素缓冲数:",window.i18nElementsMap.size);
|
|
33369
|
+
applyTranslation(element);
|
|
33370
|
+
return true;
|
|
33762
33371
|
}
|
|
33763
|
-
function
|
|
33764
|
-
|
|
33765
|
-
|
|
33766
|
-
|
|
33767
|
-
|
|
33768
|
-
|
|
33769
|
-
|
|
33770
|
-
|
|
33771
|
-
|
|
33772
|
-
// match[4] 对应第二种情况(独立数字)
|
|
33773
|
-
const numStr = match[2] || match[4];
|
|
33774
|
-
if (numStr) {
|
|
33775
|
-
// 转换为整数并验证范围
|
|
33776
|
-
const day = parseInt(numStr, 10);
|
|
33777
|
-
if (day >= 1 && day <= 31) {
|
|
33778
|
-
results.push(day);
|
|
33779
|
-
}
|
|
33372
|
+
function unProcessElement(element) {
|
|
33373
|
+
if (element && element.nodeType !== 1) {
|
|
33374
|
+
return;
|
|
33375
|
+
}
|
|
33376
|
+
let hasChildren = hasChildElements(element);
|
|
33377
|
+
if (hasChildren) {
|
|
33378
|
+
let children = element.children;
|
|
33379
|
+
for (let i = 0; i < children.length; i++) {
|
|
33380
|
+
unProcessElement(children[i]);
|
|
33780
33381
|
}
|
|
33781
33382
|
}
|
|
33782
|
-
|
|
33383
|
+
const localDomID = element.getAttribute("localDomID");
|
|
33384
|
+
if (localDomID) {
|
|
33385
|
+
// console.log(`处理元素ID:${localDomID} 移除缓存`);
|
|
33386
|
+
element.removeAttribute("localDomID");
|
|
33387
|
+
}
|
|
33388
|
+
if (localDomID && window.i18nElementsMap.has(localDomID)) {
|
|
33389
|
+
// let oldValue = element.getAttribute("oldValue");
|
|
33390
|
+
// if(oldValue){
|
|
33391
|
+
// element.removeAttribute("oldValue");
|
|
33392
|
+
// 更新元素的innerHTML
|
|
33393
|
+
// element.innerHTML = oldValue;
|
|
33394
|
+
// }
|
|
33395
|
+
window.i18nElementsMap.delete(localDomID);
|
|
33396
|
+
// console.log("移除后元素缓冲数:",window.i18nElementsMap.size);
|
|
33397
|
+
}
|
|
33783
33398
|
}
|
|
33784
|
-
function extractNumbersFromScenarios(text) {
|
|
33785
|
-
// 定义两种场景的正则表达式
|
|
33786
|
-
const patterns = [
|
|
33787
|
-
// 场景1: "Other X pieces of data"
|
|
33788
|
-
/Other\s+(\d+)\s+pieces of data/gi,
|
|
33789
|
-
// 场景2: "其他 X 条记录"
|
|
33790
|
-
/其他\s+(\d+)\s+条记录/g];
|
|
33791
|
-
const results = [];
|
|
33792
33399
|
|
|
33793
|
-
|
|
33794
|
-
|
|
33795
|
-
|
|
33796
|
-
|
|
33797
|
-
|
|
33798
|
-
|
|
33799
|
-
|
|
33800
|
-
|
|
33801
|
-
|
|
33802
|
-
|
|
33803
|
-
|
|
33804
|
-
|
|
33400
|
+
/**
|
|
33401
|
+
* 应用翻译到单个元素
|
|
33402
|
+
* @param {HTMLElement} element - 要更新的DOM元素
|
|
33403
|
+
* @param {string} lang - 语言标识符
|
|
33404
|
+
*/
|
|
33405
|
+
const applyTranslation = async element => {
|
|
33406
|
+
let parentNode = element.parentNode;
|
|
33407
|
+
if (!parentNode) {
|
|
33408
|
+
unProcessElement(element);
|
|
33409
|
+
console.log("元素已无父节点,移除缓存");
|
|
33410
|
+
return;
|
|
33411
|
+
}
|
|
33412
|
+
let lang = window.localStorage.getItem("iportal_localID") || "zh-CN";
|
|
33413
|
+
let appID = getPoratlAppID();
|
|
33414
|
+
const elementId = element.getAttribute("localDomID");
|
|
33415
|
+
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
33416
|
+
if (!cachedItem) return;
|
|
33417
|
+
// 处理属性
|
|
33418
|
+
if (cachedItem.isAttibuteAction) {
|
|
33419
|
+
cachedItem.attrFunction(appID, lang);
|
|
33420
|
+
}
|
|
33421
|
+
// 处理innerHTML
|
|
33422
|
+
if (cachedItem.isScriptAction) {
|
|
33423
|
+
cachedItem.scriptFunction(appID, lang);
|
|
33424
|
+
} else {
|
|
33425
|
+
const oldValue = element.getAttribute("oldValue");
|
|
33426
|
+
if (oldValue) {
|
|
33427
|
+
// 创建正则表达式匹配所有 $L{...} 格式
|
|
33428
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33429
|
+
// 替换所有 $L{...} 占位符为翻译文本
|
|
33430
|
+
let newValue = oldValue;
|
|
33431
|
+
let match;
|
|
33432
|
+
while ((match = regex.exec(oldValue)) !== null) {
|
|
33433
|
+
const fullMatch = match[0];
|
|
33434
|
+
const placeholderKey = match[1];
|
|
33435
|
+
const translation = i18n(placeholderKey, appID, lang);
|
|
33436
|
+
newValue = newValue.replace(fullMatch, translation);
|
|
33437
|
+
}
|
|
33438
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.nextTick)(() => {
|
|
33439
|
+
// 更新元素的innerHTML
|
|
33440
|
+
element.innerHTML = newValue;
|
|
33805
33441
|
});
|
|
33806
33442
|
}
|
|
33443
|
+
}
|
|
33444
|
+
};
|
|
33445
|
+
const initDomNodeI18NObserver = () => {
|
|
33446
|
+
if (!window.i18nElementsMap) {
|
|
33447
|
+
window.i18nElementsMap = new Map();
|
|
33448
|
+
} else {
|
|
33449
|
+
window.i18nElementsMap.clear();
|
|
33450
|
+
}
|
|
33451
|
+
registerEventListener("IPORTAL_LANGUAGE_CHANGE_EVENT", async lang => {
|
|
33452
|
+
console.log("语言切换事件触发,更新已处理元素的翻译:", lang);
|
|
33453
|
+
// 遍历Map,更新每个已处理元素的翻译
|
|
33454
|
+
for (const [elementId, item] of window.i18nElementsMap.entries()) {
|
|
33455
|
+
// console.log("更新元素翻译:", elementId, item.dom);
|
|
33456
|
+
applyTranslation(item.dom);
|
|
33457
|
+
}
|
|
33807
33458
|
});
|
|
33808
|
-
|
|
33809
|
-
|
|
33810
|
-
|
|
33811
|
-
|
|
33812
|
-
|
|
33813
|
-
|
|
33459
|
+
// 创建观察器实例
|
|
33460
|
+
const observer = new MutationObserver(mutations => {
|
|
33461
|
+
mutations.forEach(mutation => {
|
|
33462
|
+
if (mutation.type === 'childList') {
|
|
33463
|
+
// 节点添加
|
|
33464
|
+
if (mutation.addedNodes.length > 0) {
|
|
33465
|
+
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
33466
|
+
let node = mutation.addedNodes[i];
|
|
33467
|
+
// console.log(`处理新增节点:`,node);
|
|
33468
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
33469
|
+
node = node.parentNode;
|
|
33470
|
+
}
|
|
33471
|
+
processElement(node);
|
|
33472
|
+
}
|
|
33473
|
+
}
|
|
33474
|
+
// 节点移除
|
|
33475
|
+
if (mutation.removedNodes.length > 0) {
|
|
33476
|
+
for (let i = 0; i < mutation.removedNodes.length; i++) {
|
|
33477
|
+
let node = mutation.removedNodes[i];
|
|
33478
|
+
// console.log(`处理移除节点:`,node);
|
|
33479
|
+
unProcessElement(node);
|
|
33480
|
+
}
|
|
33481
|
+
}
|
|
33482
|
+
} else if (mutation.type === 'characterData') {
|
|
33483
|
+
// 处理文本变化
|
|
33484
|
+
const oldValue = mutation.oldValue;
|
|
33485
|
+
const targetNode = mutation.target;
|
|
33486
|
+
const newValue = targetNode.data;
|
|
33487
|
+
// 创建日志条目并显示
|
|
33488
|
+
console.log(`文本修改: ${oldValue} → ${newValue}`);
|
|
33489
|
+
const parentElement = targetNode.parentNode;
|
|
33490
|
+
if (parentElement) {
|
|
33491
|
+
let localDomID = parentElement.getAttribute("localDomID");
|
|
33492
|
+
// 如果有localDomID,说明之前处理过,先移除缓存
|
|
33493
|
+
if (localDomID) {
|
|
33494
|
+
unProcessElement(parentElement);
|
|
33495
|
+
}
|
|
33496
|
+
}
|
|
33497
|
+
processElement(parentElement);
|
|
33498
|
+
}
|
|
33499
|
+
});
|
|
33500
|
+
});
|
|
33501
|
+
|
|
33502
|
+
// 配置观察选项
|
|
33503
|
+
const config = {
|
|
33504
|
+
childList: true,
|
|
33505
|
+
// 观察子节点变化
|
|
33506
|
+
subtree: true,
|
|
33507
|
+
// 观察所有后代节点
|
|
33508
|
+
attributes: false,
|
|
33509
|
+
// 不观察属性变化
|
|
33510
|
+
characterData: true,
|
|
33511
|
+
// 不观察文本内容变化
|
|
33512
|
+
characterDataOldValue: true
|
|
33814
33513
|
};
|
|
33815
|
-
|
|
33816
|
-
|
|
33817
|
-
|
|
33818
|
-
|
|
33819
|
-
|
|
33820
|
-
|
|
33821
|
-
|
|
33822
|
-
|
|
33823
|
-
|
|
33824
|
-
if (
|
|
33825
|
-
|
|
33826
|
-
|
|
33827
|
-
|
|
33828
|
-
|
|
33829
|
-
|
|
33830
|
-
|
|
33831
|
-
newInnerHTML = `${year}年${month}月`;
|
|
33514
|
+
// 开始观察目标节点
|
|
33515
|
+
const targetNode = document.body;
|
|
33516
|
+
processElement(targetNode);
|
|
33517
|
+
observer.observe(targetNode, config);
|
|
33518
|
+
};
|
|
33519
|
+
const initDomNodeViewObserver = () => {
|
|
33520
|
+
// 创建观察器实例
|
|
33521
|
+
const observer = new MutationObserver(mutations => {
|
|
33522
|
+
mutations.forEach(mutation => {
|
|
33523
|
+
if (mutation.type === 'childList') {
|
|
33524
|
+
// 节点添加
|
|
33525
|
+
if (mutation.addedNodes.length > 0) {
|
|
33526
|
+
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
33527
|
+
let node = mutation.addedNodes[i];
|
|
33528
|
+
processViewElement(node);
|
|
33529
|
+
}
|
|
33832
33530
|
}
|
|
33833
|
-
element.innerHTML = newInnerHTML;
|
|
33834
33531
|
}
|
|
33835
|
-
};
|
|
33836
|
-
|
|
33837
|
-
|
|
33838
|
-
|
|
33839
|
-
|
|
33840
|
-
|
|
33841
|
-
|
|
33842
|
-
|
|
33843
|
-
|
|
33844
|
-
|
|
33845
|
-
|
|
33846
|
-
|
|
33847
|
-
|
|
33848
|
-
|
|
33532
|
+
});
|
|
33533
|
+
});
|
|
33534
|
+
|
|
33535
|
+
// 配置观察选项
|
|
33536
|
+
const config = {
|
|
33537
|
+
childList: true,
|
|
33538
|
+
// 观察子节点变化
|
|
33539
|
+
subtree: true,
|
|
33540
|
+
// 观察所有后代节点
|
|
33541
|
+
attributes: false,
|
|
33542
|
+
// 不观察属性变化
|
|
33543
|
+
characterData: true,
|
|
33544
|
+
// 不观察文本内容变化
|
|
33545
|
+
characterDataOldValue: true
|
|
33546
|
+
};
|
|
33547
|
+
// 开始观察目标节点
|
|
33548
|
+
const targetNode = document.body;
|
|
33549
|
+
processViewElement(targetNode);
|
|
33550
|
+
observer.observe(targetNode, config);
|
|
33551
|
+
};
|
|
33552
|
+
|
|
33553
|
+
// 处理单个DOM元素的函数
|
|
33554
|
+
function processViewElement(element) {
|
|
33555
|
+
if (!element) {
|
|
33556
|
+
return false;
|
|
33849
33557
|
}
|
|
33850
|
-
//
|
|
33851
|
-
if (
|
|
33852
|
-
|
|
33853
|
-
if (innerHTML.includes("今天") || innerHTML.includes("today")) {
|
|
33854
|
-
// console.log("检查smardaten平台日历 今天 元素:",innerHTML);
|
|
33855
|
-
let tempHTMLMatch = {
|
|
33856
|
-
oldValue: '$L{今天}'
|
|
33857
|
-
};
|
|
33858
|
-
checkResult.result = true;
|
|
33859
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33860
|
-
return checkResult;
|
|
33861
|
-
}
|
|
33558
|
+
// 仅处理元素节点
|
|
33559
|
+
if (element && element.nodeType !== Node.ELEMENT_NODE) {
|
|
33560
|
+
return false;
|
|
33862
33561
|
}
|
|
33863
|
-
//
|
|
33864
|
-
|
|
33865
|
-
|
|
33866
|
-
|
|
33867
|
-
|
|
33868
|
-
|
|
33869
|
-
|
|
33870
|
-
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33871
|
-
let day = match[0];
|
|
33872
|
-
let tempHTMLMatch = {
|
|
33873
|
-
oldValue: `$L{${day}}`
|
|
33874
|
-
};
|
|
33875
|
-
checkResult.result = true;
|
|
33876
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33877
|
-
return checkResult;
|
|
33878
|
-
}
|
|
33879
|
-
match = innerHTML.match(regex_en);
|
|
33880
|
-
if (match) {
|
|
33881
|
-
// console.log("检查smardaten平台日历 周 元素:",innerHTML);
|
|
33882
|
-
let day = match[0];
|
|
33883
|
-
let tempHTMLMatch = {
|
|
33884
|
-
oldValue: `$L{${convertToChineseWeekday(day)}}`
|
|
33885
|
-
};
|
|
33886
|
-
checkResult.result = true;
|
|
33887
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33888
|
-
return checkResult;
|
|
33562
|
+
// 如果元素有子元素,则不处理innerHTML
|
|
33563
|
+
const hasChildren = hasChildElements(element);
|
|
33564
|
+
if (hasChildren) {
|
|
33565
|
+
let children = element.children;
|
|
33566
|
+
for (let i = 0; i < children.length; i++) {
|
|
33567
|
+
let child = children[i];
|
|
33568
|
+
processViewElement(child);
|
|
33889
33569
|
}
|
|
33890
33570
|
}
|
|
33891
|
-
|
|
33892
|
-
|
|
33893
|
-
|
|
33894
|
-
|
|
33895
|
-
|
|
33896
|
-
|
|
33897
|
-
|
|
33898
|
-
|
|
33899
|
-
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
|
|
33904
|
-
|
|
33571
|
+
let checkState = element.getAttribute("viewDomID");
|
|
33572
|
+
// 已经处理过的元素跳过
|
|
33573
|
+
if (checkState) {
|
|
33574
|
+
return false;
|
|
33575
|
+
}
|
|
33576
|
+
const viewCheckResult = commom_view_check(element);
|
|
33577
|
+
// 如果没有匹配的内容,则不处理
|
|
33578
|
+
if (!viewCheckResult.result) {
|
|
33579
|
+
return false;
|
|
33580
|
+
}
|
|
33581
|
+
viewCheckResult.scriptFunction();
|
|
33582
|
+
return true;
|
|
33583
|
+
}
|
|
33584
|
+
;// ./src/api/security.js
|
|
33585
|
+
|
|
33586
|
+
|
|
33587
|
+
|
|
33588
|
+
|
|
33589
|
+
|
|
33590
|
+
|
|
33591
|
+
/**
|
|
33592
|
+
*
|
|
33593
|
+
* @returns 获取登录验证码图片
|
|
33594
|
+
*/
|
|
33595
|
+
const getAuthPic = () => request.get(`/system/authority/getAuthPic?module=loginPassword`, {
|
|
33596
|
+
responseType: "arraybuffer"
|
|
33597
|
+
});
|
|
33598
|
+
|
|
33599
|
+
/**
|
|
33600
|
+
* 登出账号
|
|
33601
|
+
* @param endside_type 0: web 1:手机
|
|
33602
|
+
* @returns {Promise<*>}
|
|
33603
|
+
* @param endside_type 0: web 1:手机
|
|
33604
|
+
*
|
|
33605
|
+
*/
|
|
33606
|
+
const logoutAccount = async endside_type => {
|
|
33607
|
+
let resultData = await request.get(`/system/authority/logout?isMobileLogout=${endside_type}`);
|
|
33608
|
+
let response = JSON.parse(resultData.request.response);
|
|
33609
|
+
let resultCode = response.code;
|
|
33610
|
+
if (resultCode == "10110020") {
|
|
33611
|
+
window.sessionStorage.clear();
|
|
33612
|
+
return {
|
|
33613
|
+
code: resultCode,
|
|
33614
|
+
message: i18nText(response.message)
|
|
33905
33615
|
};
|
|
33906
|
-
|
|
33907
|
-
|
|
33908
|
-
|
|
33909
|
-
|
|
33910
|
-
let tempHTMLMatch = {
|
|
33911
|
-
oldValue: innerHTML,
|
|
33912
|
-
isScriptAction: true,
|
|
33913
|
-
scriptFunction: scriptFunction
|
|
33914
|
-
};
|
|
33915
|
-
checkResult.result = true;
|
|
33916
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33917
|
-
return checkResult;
|
|
33918
|
-
}
|
|
33919
|
-
}
|
|
33920
|
-
// 日历更多按钮
|
|
33921
|
-
if (classes.contains("fc-daygrid-more-link")) {
|
|
33922
|
-
let scriptFunction = (appID, lang) => {
|
|
33923
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33924
|
-
let result = extractNumbersFromScenarios(oldValue);
|
|
33925
|
-
if (result && result.length > 0) {
|
|
33926
|
-
let day = result[0]["number"];
|
|
33927
|
-
let newInnerHTML = "另外${X}条数据";
|
|
33928
|
-
newInnerHTML = i18n(newInnerHTML, appID, lang);
|
|
33929
|
-
newInnerHTML = newInnerHTML.replace("${X}", day);
|
|
33930
|
-
element.innerHTML = newInnerHTML;
|
|
33931
|
-
}
|
|
33616
|
+
} else {
|
|
33617
|
+
return {
|
|
33618
|
+
code: resultCode,
|
|
33619
|
+
message: i18nText(response.message)
|
|
33932
33620
|
};
|
|
33933
|
-
let innerHTML = element.innerHTML;
|
|
33934
|
-
let match = extractNumbersFromScenarios(innerHTML);
|
|
33935
|
-
if (match.length > 0) {
|
|
33936
|
-
// console.log("检查smardaten平台日历 更多 元素:",innerHTML);
|
|
33937
|
-
let tempHTMLMatch = {
|
|
33938
|
-
oldValue: innerHTML,
|
|
33939
|
-
isScriptAction: true,
|
|
33940
|
-
scriptFunction: scriptFunction
|
|
33941
|
-
};
|
|
33942
|
-
checkResult.result = true;
|
|
33943
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33944
|
-
return checkResult;
|
|
33945
|
-
}
|
|
33946
33621
|
}
|
|
33947
|
-
|
|
33948
|
-
|
|
33949
|
-
|
|
33950
|
-
|
|
33951
|
-
|
|
33952
|
-
|
|
33953
|
-
|
|
33954
|
-
|
|
33955
|
-
|
|
33956
|
-
|
|
33957
|
-
|
|
33958
|
-
|
|
33959
|
-
|
|
33960
|
-
|
|
33961
|
-
|
|
33962
|
-
|
|
33963
|
-
|
|
33964
|
-
|
|
33965
|
-
|
|
33966
|
-
|
|
33967
|
-
|
|
33968
|
-
|
|
33969
|
-
|
|
33622
|
+
};
|
|
33623
|
+
|
|
33624
|
+
/**
|
|
33625
|
+
* 解密
|
|
33626
|
+
*/
|
|
33627
|
+
const decrypt = async decryptStr => {
|
|
33628
|
+
let secretKey = await getKey();
|
|
33629
|
+
const decrypted = crypto_js_default().AES.decrypt(decryptStr, secretKey).toString((crypto_js_default()).enc.Utf8);
|
|
33630
|
+
return decrypted;
|
|
33631
|
+
};
|
|
33632
|
+
|
|
33633
|
+
/**
|
|
33634
|
+
* 解密
|
|
33635
|
+
*/
|
|
33636
|
+
const encrypt = async decryptStr => {
|
|
33637
|
+
let secretKey = await getKey();
|
|
33638
|
+
const encrypted = crypto_js_default().AES.encrypt(decryptStr, secretKey).toString();
|
|
33639
|
+
return encrypted;
|
|
33640
|
+
};
|
|
33641
|
+
|
|
33642
|
+
/**
|
|
33643
|
+
* 切换门户登录
|
|
33644
|
+
*/
|
|
33645
|
+
const switchPortalLogin = async (data, appid, endside_type) => {
|
|
33646
|
+
let old_key = window.sessionStorage.getItem("iportal_login_user_key");
|
|
33647
|
+
old_key = await decrypt(old_key);
|
|
33648
|
+
data.password = old_key;
|
|
33649
|
+
let resultData = await logoutAccount(endside_type);
|
|
33650
|
+
let resultCode = resultData.code;
|
|
33651
|
+
let message = resultData.message;
|
|
33652
|
+
//退出登录成功
|
|
33653
|
+
if (resultCode == "10110020") {
|
|
33654
|
+
let loginResult = await loginAccount(data, appid);
|
|
33655
|
+
return loginResult;
|
|
33656
|
+
} else {
|
|
33657
|
+
return {
|
|
33658
|
+
code: resultCode,
|
|
33659
|
+
message: i18nText(message)
|
|
33970
33660
|
};
|
|
33971
|
-
let innerHTML = element.innerHTML;
|
|
33972
|
-
let match = innerHTML.match(regex);
|
|
33973
|
-
if (match && match.length > 0) {
|
|
33974
|
-
// console.log("检查smardaten平台日历 日 元素:",innerHTML);
|
|
33975
|
-
let tempHTMLMatch = {
|
|
33976
|
-
oldValue: innerHTML,
|
|
33977
|
-
isScriptAction: true,
|
|
33978
|
-
scriptFunction: scriptFunction
|
|
33979
|
-
};
|
|
33980
|
-
checkResult.result = true;
|
|
33981
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
33982
|
-
return checkResult;
|
|
33983
|
-
}
|
|
33984
33661
|
}
|
|
33985
|
-
return checkResult;
|
|
33986
33662
|
};
|
|
33987
|
-
|
|
33988
|
-
|
|
33989
|
-
|
|
33990
|
-
|
|
33991
|
-
|
|
33992
|
-
|
|
33993
|
-
const classes = element.classList;
|
|
33994
|
-
if (!classes) {
|
|
33995
|
-
return checkResult;
|
|
33996
|
-
}
|
|
33997
|
-
let innerHTML = element.innerHTML;
|
|
33998
|
-
let oldValue = element.getAttribute("oldValue");
|
|
33999
|
-
if (!oldValue) {
|
|
34000
|
-
oldValue = innerHTML;
|
|
34001
|
-
}
|
|
34002
|
-
// 检查删除确认对话框按钮 取消 确认
|
|
34003
|
-
if (classes.contains("ant-modal-title")) {
|
|
34004
|
-
let innerHTML = element.innerHTML;
|
|
34005
|
-
if (innerHTML.includes("Select Data") || innerHTML.includes("选择数据")) {
|
|
34006
|
-
// console.log("检查smardaten平台 Tip提问取消删除按钮:",innerHTML);
|
|
34007
|
-
let tempHTMLMatch = {
|
|
34008
|
-
oldValue: '$L{选择数据}'
|
|
34009
|
-
};
|
|
34010
|
-
checkResult.result = true;
|
|
34011
|
-
checkResult.innerHTMLMatch = tempHTMLMatch;
|
|
34012
|
-
return checkResult;
|
|
33663
|
+
const getUserID = async (acccountName, old_key, group_id) => {
|
|
33664
|
+
let queryData = {
|
|
33665
|
+
param: {
|
|
33666
|
+
accountName: acccountName,
|
|
33667
|
+
group_id: group_id,
|
|
33668
|
+
account_key: old_key
|
|
34013
33669
|
}
|
|
34014
|
-
}
|
|
34015
|
-
return checkResult;
|
|
34016
|
-
};
|
|
34017
|
-
;// ./src/api/i18n/commom_view.js
|
|
34018
|
-
const commom_view_check = element => {
|
|
34019
|
-
const checkResult = {
|
|
34020
|
-
result: false
|
|
34021
33670
|
};
|
|
34022
|
-
|
|
34023
|
-
|
|
34024
|
-
|
|
34025
|
-
|
|
34026
|
-
|
|
34027
|
-
|
|
34028
|
-
|
|
34029
|
-
|
|
34030
|
-
|
|
34031
|
-
|
|
34032
|
-
|
|
34033
|
-
|
|
34034
|
-
|
|
34035
|
-
|
|
34036
|
-
|
|
34037
|
-
|
|
34038
|
-
|
|
34039
|
-
|
|
34040
|
-
|
|
34041
|
-
|
|
34042
|
-
|
|
34043
|
-
|
|
34044
|
-
|
|
34045
|
-
|
|
34046
|
-
|
|
34047
|
-
|
|
34048
|
-
|
|
34049
|
-
|
|
34050
|
-
|
|
34051
|
-
|
|
34052
|
-
|
|
34053
|
-
|
|
34054
|
-
|
|
34055
|
-
|
|
33671
|
+
let result = await request.post(`/dataservice/rest/orchestration/getUserID`, queryData);
|
|
33672
|
+
let persion_id = result.data.persion_id;
|
|
33673
|
+
return persion_id;
|
|
33674
|
+
};
|
|
33675
|
+
|
|
33676
|
+
/**
|
|
33677
|
+
* 登录账号
|
|
33678
|
+
* @param data 登录数据
|
|
33679
|
+
* @param appid 应用ID
|
|
33680
|
+
*
|
|
33681
|
+
* @description
|
|
33682
|
+
* 登录时需要传入验证码(authPicCode)和应用ID(dataappId),
|
|
33683
|
+
* mobileOrWeb参数用于区分是移动端还是网页端登录。
|
|
33684
|
+
*
|
|
33685
|
+
* @returns
|
|
33686
|
+
*/
|
|
33687
|
+
const loginAccount = async (data, appid) => {
|
|
33688
|
+
let result = await getLoginPortalAccountKey(data.account_view, data.groupid);
|
|
33689
|
+
let code = result.data.code;
|
|
33690
|
+
//获取key成功
|
|
33691
|
+
if (code == 10001) {
|
|
33692
|
+
//保存的真正一级密码
|
|
33693
|
+
let pwd_code = result.data.codeData.key;
|
|
33694
|
+
//缓存一级密码
|
|
33695
|
+
let old_key = pwd_code;
|
|
33696
|
+
//保存的正则2级密码
|
|
33697
|
+
let key_code = result.data.codeData.code;
|
|
33698
|
+
//反向解析一级密码
|
|
33699
|
+
pwd_code = await decrypt(pwd_code);
|
|
33700
|
+
//反向解析2级密码
|
|
33701
|
+
key_code = await decrypt(key_code);
|
|
33702
|
+
//密码匹配
|
|
33703
|
+
if (pwd_code == data.password) {
|
|
33704
|
+
//平台正向加密2级密码
|
|
33705
|
+
pwd_code = window.appSdk.Encrypt(key_code);
|
|
33706
|
+
data.password = pwd_code;
|
|
33707
|
+
result = await request.post(`/system/authority/loginAccount4Application?authPicCode=${data.imageCode}&dataappId=${appid}&mobileOrWeb=web`, data);
|
|
33708
|
+
let response = JSON.parse(result.request.response);
|
|
33709
|
+
code = response.code;
|
|
33710
|
+
//登录平台成功
|
|
33711
|
+
if (code == 10110004) {
|
|
33712
|
+
let id = await getUserID(data.account_view, old_key, data.groupid);
|
|
33713
|
+
// 初始化解析器
|
|
33714
|
+
const parser = new UAParser();
|
|
33715
|
+
// 获取浏览器信息
|
|
33716
|
+
const browser = parser.getBrowser();
|
|
33717
|
+
let timestamp = new Date().getTime();
|
|
33718
|
+
let clientID = browser.name + "_" + browser.version + "_" + timestamp;
|
|
33719
|
+
window.sessionStorage.setItem("iportal_login_user_id", id);
|
|
33720
|
+
window.sessionStorage.setItem("iportal_group_id", data.groupid);
|
|
33721
|
+
window.sessionStorage.setItem("iportal_login_user_key", old_key);
|
|
33722
|
+
window.sessionStorage.setItem("iportal_client_id", clientID);
|
|
33723
|
+
window.sessionStorage.setItem("iportal_app_id", appid);
|
|
33724
|
+
return {
|
|
33725
|
+
code: code
|
|
33726
|
+
};
|
|
33727
|
+
} else {
|
|
33728
|
+
return {
|
|
33729
|
+
code: code,
|
|
33730
|
+
message: i18nText(response.message)
|
|
33731
|
+
};
|
|
34056
33732
|
}
|
|
34057
|
-
}
|
|
34058
|
-
|
|
34059
|
-
|
|
34060
|
-
|
|
33733
|
+
} else {
|
|
33734
|
+
return {
|
|
33735
|
+
code: code,
|
|
33736
|
+
message: i18nText("账户密码错误")
|
|
33737
|
+
};
|
|
33738
|
+
}
|
|
34061
33739
|
}
|
|
34062
|
-
return
|
|
33740
|
+
return {
|
|
33741
|
+
code: code,
|
|
33742
|
+
message: i18nText(result.data.message)
|
|
33743
|
+
};
|
|
34063
33744
|
};
|
|
34064
|
-
function generateUniqueId() {
|
|
34065
|
-
return `rjview_${Date.now()}`;
|
|
34066
|
-
}
|
|
34067
|
-
;// ./src/api/i18n/i18n.js
|
|
34068
33745
|
|
|
33746
|
+
/**
|
|
33747
|
+
* 获取密钥
|
|
33748
|
+
* @returns
|
|
33749
|
+
*/
|
|
33750
|
+
const getKey = async () => {
|
|
33751
|
+
let queryData = {
|
|
33752
|
+
param: {}
|
|
33753
|
+
};
|
|
33754
|
+
let resultData = await request.post(`/dataservice/rest/orchestration/getKey`, queryData);
|
|
33755
|
+
let key = resultData.data.key;
|
|
33756
|
+
return key;
|
|
33757
|
+
};
|
|
33758
|
+
;// ./src/api/utils.js
|
|
34069
33759
|
|
|
34070
33760
|
|
|
34071
33761
|
|
|
34072
33762
|
|
|
33763
|
+
/**
|
|
33764
|
+
* 查询资产
|
|
33765
|
+
* @param id 资产ID
|
|
33766
|
+
*
|
|
33767
|
+
*/
|
|
33768
|
+
const queryAssetById = (id, count = 200) => request.post(`/asset/getAssetData?asset_id=${id}&count=${count}`, {
|
|
33769
|
+
filters: []
|
|
33770
|
+
});
|
|
34073
33771
|
|
|
33772
|
+
/**
|
|
33773
|
+
* 获取URL参数值
|
|
33774
|
+
* @param {} eventName
|
|
33775
|
+
* @param {*} actionFun
|
|
33776
|
+
*/
|
|
33777
|
+
const getUrlParamValue = (urlStr, paramName) => {
|
|
33778
|
+
try {
|
|
33779
|
+
const url = new URL(urlStr);
|
|
33780
|
+
const value = url.searchParams.get(paramName);
|
|
33781
|
+
// 如果参数值包含#,则只返回#之前的部分
|
|
33782
|
+
if (value && value.indexOf("#") !== -1) {
|
|
33783
|
+
return value.split("#")[0];
|
|
33784
|
+
}
|
|
33785
|
+
return value;
|
|
33786
|
+
} catch (err) {
|
|
33787
|
+
console.error("URL 格式错误:", err);
|
|
33788
|
+
return "";
|
|
33789
|
+
}
|
|
33790
|
+
};
|
|
34074
33791
|
|
|
33792
|
+
/**
|
|
33793
|
+
* 通过 URL 创建 File 对象
|
|
33794
|
+
* @param {string} url - 文件的网络 URL
|
|
33795
|
+
* @param {string} [filename] - 自定义文件名(可选,不传则从 URL 提取)
|
|
33796
|
+
* @returns {Promise<File>} - 返回 Promise 解析为 File 对象
|
|
33797
|
+
*/
|
|
33798
|
+
const createFileFromUrl = async (url, filename) => {
|
|
33799
|
+
try {
|
|
33800
|
+
// 1. 发起网络请求获取文件
|
|
33801
|
+
const response = await fetch(url);
|
|
33802
|
+
if (!response.ok) {
|
|
33803
|
+
throw new Error(`网络请求失败: ${response.status} ${response.statusText}`);
|
|
33804
|
+
}
|
|
34075
33805
|
|
|
33806
|
+
// 2. 将响应转换为 Blob(保留原始 MIME 类型)
|
|
33807
|
+
const blob = await response.blob();
|
|
34076
33808
|
|
|
33809
|
+
// 3. 确定文件名(若未自定义则从 URL 提取)
|
|
33810
|
+
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
34077
33811
|
|
|
33812
|
+
// 4. 构造 File 对象(Blob + 文件名 + 类型)
|
|
33813
|
+
return new File([blob], finalFilename, {
|
|
33814
|
+
type: blob.type,
|
|
33815
|
+
// 使用 Blob 的 MIME 类型(如 image/png)
|
|
33816
|
+
lastModified: Date.now() // 可选:设置最后修改时间
|
|
33817
|
+
});
|
|
33818
|
+
} catch (error) {
|
|
33819
|
+
console.error("创建 File 失败:", error);
|
|
33820
|
+
throw error;
|
|
33821
|
+
}
|
|
33822
|
+
};
|
|
34078
33823
|
|
|
33824
|
+
/**
|
|
33825
|
+
* 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
|
|
33826
|
+
* @param {string} url - 文件 URL
|
|
33827
|
+
* @returns {string} - 提取的文件名
|
|
33828
|
+
*/
|
|
33829
|
+
const extractFilenameFromUrl = url => {
|
|
33830
|
+
try {
|
|
33831
|
+
const urlObj = new URL(url);
|
|
33832
|
+
// 从路径中获取最后一个部分(文件名)
|
|
33833
|
+
return urlObj.pathname.split("/").pop() || "downloaded_file";
|
|
33834
|
+
} catch (e) {
|
|
33835
|
+
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
33836
|
+
}
|
|
33837
|
+
};
|
|
34079
33838
|
|
|
33839
|
+
/**
|
|
33840
|
+
* 提取数组中不在另一个数组中的元素
|
|
33841
|
+
* @param {*} oldItems 基础比较数组
|
|
33842
|
+
* @param {*} newItems 被提取检测的数组
|
|
33843
|
+
* @returns
|
|
33844
|
+
*/
|
|
33845
|
+
const extractNewItems = (oldItems, newItems) => {
|
|
33846
|
+
return oldItems.filter(item => !newItems.includes(item));
|
|
33847
|
+
};
|
|
34080
33848
|
|
|
34081
|
-
|
|
34082
|
-
|
|
34083
|
-
|
|
34084
|
-
|
|
34085
|
-
|
|
34086
|
-
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
33849
|
+
/**
|
|
33850
|
+
* 获取远程文件大小(单位:字节)
|
|
33851
|
+
* @param {string} url - 文件的URL地址
|
|
33852
|
+
* @returns {Promise<number>} 文件大小(字节),失败时返回-1
|
|
33853
|
+
*/
|
|
33854
|
+
const getFileSize = async url => {
|
|
33855
|
+
try {
|
|
33856
|
+
// 发送HEAD请求(不下载文件内容)
|
|
33857
|
+
const response = await fetch(url, {
|
|
33858
|
+
method: "GET",
|
|
33859
|
+
headers: {
|
|
33860
|
+
Range: "bytes=0-0"
|
|
33861
|
+
} // 仅请求第 1 个字节
|
|
33862
|
+
});
|
|
33863
|
+
if (response.status !== 206) throw new Error("不支持 Range 请求");
|
|
33864
|
+
const contentRange = response.headers.get("Content-Range");
|
|
33865
|
+
const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
|
|
33866
|
+
return totalSize ? parseInt(totalSize, 10) : -1;
|
|
33867
|
+
} catch (error) {
|
|
33868
|
+
console.error("获取文件大小失败:", error);
|
|
33869
|
+
return -1; // 返回-1表示失败
|
|
33870
|
+
}
|
|
34090
33871
|
};
|
|
34091
|
-
|
|
34092
|
-
|
|
34093
|
-
|
|
33872
|
+
// 获取i18n key
|
|
33873
|
+
const getI18nKey = text => {
|
|
33874
|
+
// 正则表达式匹配 $L{...} 格式
|
|
33875
|
+
const regex = /\$L\{([^}]+)\}/g;
|
|
33876
|
+
let match = regex.exec(text);
|
|
33877
|
+
if (!match) return text;
|
|
33878
|
+
let key = match[1];
|
|
33879
|
+
return key;
|
|
34094
33880
|
};
|
|
34095
|
-
|
|
34096
|
-
|
|
34097
|
-
|
|
34098
|
-
|
|
33881
|
+
|
|
33882
|
+
// 查找最近的具有指定 class 的祖先节点
|
|
33883
|
+
const findClosestAncestorByClass = (element, className) => {
|
|
33884
|
+
let currentElement = element;
|
|
33885
|
+
while (currentElement) {
|
|
33886
|
+
// 检查当前元素是否包含目标 class
|
|
33887
|
+
if (currentElement.classList && currentElement.classList.contains(className)) {
|
|
33888
|
+
return currentElement;
|
|
34099
33889
|
}
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
let resultDatas = response.data.resultDatas || [];
|
|
34103
|
-
window.customI18nObject = new Map();
|
|
34104
|
-
for (let item of resultDatas) {
|
|
34105
|
-
window.customI18nObject.set(`${appID}-${item.key}-${item.lang}`, item.value);
|
|
33890
|
+
// 向上遍历父节点
|
|
33891
|
+
currentElement = currentElement.parentElement;
|
|
34106
33892
|
}
|
|
33893
|
+
// 未找到匹配的祖先节点
|
|
33894
|
+
return null;
|
|
34107
33895
|
};
|
|
33896
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
|
|
33897
|
+
var es_iterator_some = __webpack_require__(3579);
|
|
33898
|
+
;// ./src/api/iframe.js
|
|
34108
33899
|
|
|
34109
|
-
/**
|
|
34110
|
-
* 检查元素是否有子DOM元素
|
|
34111
|
-
* @param {HTMLElement} element - 要检查的DOM元素
|
|
34112
|
-
* @returns {boolean} - 是否有子元素
|
|
34113
|
-
*/
|
|
34114
|
-
function hasChildElements(element) {
|
|
34115
|
-
return element && element.children?.length > 0;
|
|
34116
|
-
}
|
|
34117
33900
|
|
|
34118
|
-
/**
|
|
34119
|
-
* 检查文本是否匹配$L{...}格式
|
|
34120
|
-
* @param {string} text - 要检查的文本
|
|
34121
|
-
* @returns {Object|null} - 匹配结果或null
|
|
34122
|
-
*/
|
|
34123
|
-
function checkTextFormat(text) {
|
|
34124
|
-
if (!text) return null;
|
|
34125
|
-
const regex = /\$L\{([^}]+)\}/;
|
|
34126
|
-
const match = text.match(regex);
|
|
34127
|
-
if (match) {
|
|
34128
|
-
return {
|
|
34129
|
-
fullMatch: match[0],
|
|
34130
|
-
key: match[1]
|
|
34131
|
-
};
|
|
34132
|
-
}
|
|
34133
|
-
return null;
|
|
34134
|
-
}
|
|
34135
|
-
function i18n_generateUniqueId() {
|
|
34136
|
-
window.idCounter = window.idCounter || 0;
|
|
34137
|
-
return `i18n_${Date.now()}_${window.idCounter++}`;
|
|
34138
|
-
}
|
|
34139
33901
|
|
|
34140
|
-
|
|
34141
|
-
|
|
34142
|
-
|
|
34143
|
-
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34147
|
-
|
|
34148
|
-
|
|
34149
|
-
|
|
34150
|
-
let
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
|
|
34154
|
-
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
}
|
|
34158
|
-
|
|
34159
|
-
}
|
|
34160
|
-
|
|
34161
|
-
|
|
34162
|
-
|
|
34163
|
-
|
|
33902
|
+
const addWindowTrustedOrigin = origin => {
|
|
33903
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
33904
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
33905
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS.includes(origin)) {
|
|
33906
|
+
SDATA_WINDOW_TRUSTED_ORIGINS.push(origin);
|
|
33907
|
+
}
|
|
33908
|
+
};
|
|
33909
|
+
const removeWindowTrustedOrigin = origin => {
|
|
33910
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
33911
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
33912
|
+
let index = SDATA_WINDOW_TRUSTED_ORIGINS.indexOf(origin); // 查找元素在数组中的索引
|
|
33913
|
+
if (index > -1) {
|
|
33914
|
+
SDATA_WINDOW_TRUSTED_ORIGINS.splice(index, 1); // 删除元素
|
|
33915
|
+
}
|
|
33916
|
+
};
|
|
33917
|
+
const addEventAction = (eventKey, eventAction) => {
|
|
33918
|
+
let sdataEventActions = window.sdataEventActions;
|
|
33919
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
33920
|
+
window.sdataEventActions[eventKey] = eventAction;
|
|
33921
|
+
};
|
|
33922
|
+
const removeEventAction = eventKey => {
|
|
33923
|
+
let sdataEventActions = window.sdataEventActions;
|
|
33924
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
33925
|
+
delete window.sdataEventActions[eventKey];
|
|
33926
|
+
};
|
|
33927
|
+
const initFrameWindowListener = () => {
|
|
33928
|
+
if (window.isFrameWindowInited) return;
|
|
33929
|
+
let SDATA_WINDOW_TRUSTED_ORIGINS = window.SDATA_WINDOW_TRUSTED_ORIGINS;
|
|
33930
|
+
if (!SDATA_WINDOW_TRUSTED_ORIGINS) window.SDATA_WINDOW_TRUSTED_ORIGINS = [];
|
|
33931
|
+
let sdataEventActions = window.sdataEventActions;
|
|
33932
|
+
if (!sdataEventActions) window.sdataEventActions = {};
|
|
33933
|
+
// 监听主页面的消息
|
|
33934
|
+
window.addEventListener("message", async event => {
|
|
33935
|
+
// 步骤1:验证来源是否在白名单中
|
|
33936
|
+
const isTrusted = window.SDATA_WINDOW_TRUSTED_ORIGINS.some(origin => event.origin === origin || new RegExp(origin).test(event.origin));
|
|
33937
|
+
if (!isTrusted) {
|
|
33938
|
+
console.log("拒绝非可信源消息:", event.origin);
|
|
33939
|
+
return; // 直接终止处理
|
|
33940
|
+
}
|
|
33941
|
+
let eventKey = event.data?.eventKey;
|
|
33942
|
+
if (!eventKey) return;
|
|
33943
|
+
let eventSourceKey = event.origin;
|
|
33944
|
+
console.log(`收到${eventSourceKey}页面消息:`, event.data);
|
|
33945
|
+
if (eventKey === "sdata_alllife_event_response") {
|
|
33946
|
+
let eventOperateKey = event.data.eventOperateKey;
|
|
33947
|
+
let eventAction = window.sdataEventActions[eventOperateKey];
|
|
33948
|
+
//删除缓存方法
|
|
33949
|
+
delete window.sdataEventActions[eventOperateKey];
|
|
33950
|
+
if (eventAction) await eventAction(event.data.data, event);
|
|
33951
|
+
} else {
|
|
33952
|
+
let eventAction = window.sdataEventActions[eventKey];
|
|
33953
|
+
let responseData = {
|
|
33954
|
+
eventKey: "sdata_alllife_event_response",
|
|
33955
|
+
eventOperateKey: event.data.eventOperateKey,
|
|
33956
|
+
data: {}
|
|
33957
|
+
};
|
|
33958
|
+
if (eventAction) {
|
|
33959
|
+
let resultData = await eventAction(event.data.data, event);
|
|
33960
|
+
responseData.data = resultData;
|
|
33961
|
+
}
|
|
33962
|
+
event.source.postMessage(responseData, eventSourceKey);
|
|
33963
|
+
}
|
|
33964
|
+
});
|
|
33965
|
+
window.isFrameWindowInited = true;
|
|
33966
|
+
};
|
|
33967
|
+
const sendWindowMessage = async (targetWindow, originKey, eventKey, data, callback) => {
|
|
33968
|
+
let timestamp = new Date().getTime();
|
|
33969
|
+
let randomNum = Math.floor(Math.random() * 10000) + 1;
|
|
33970
|
+
let eventOperateKey = `${eventKey}_${timestamp}_${randomNum}`;
|
|
33971
|
+
addEventAction(eventOperateKey, callback);
|
|
33972
|
+
let postData = {
|
|
33973
|
+
eventOperateKey: eventOperateKey,
|
|
33974
|
+
eventKey: eventKey,
|
|
33975
|
+
data: data
|
|
33976
|
+
};
|
|
33977
|
+
targetWindow.postMessage(postData, originKey);
|
|
33978
|
+
};
|
|
33979
|
+
;// ./src/api/chat/ChatClientMgr.js
|
|
33980
|
+
|
|
33981
|
+
|
|
34164
33982
|
|
|
34165
|
-
|
|
34166
|
-
|
|
34167
|
-
|
|
33983
|
+
class ChatClientMgr {
|
|
33984
|
+
constructor(params, handler) {
|
|
33985
|
+
this.handler = handler;
|
|
33986
|
+
this.actionKey = params.actionKey;
|
|
33987
|
+
this.appSKID = params.appSKID;
|
|
33988
|
+
this.imType = params.imType;
|
|
33989
|
+
this.groupID = params.groupID;
|
|
33990
|
+
this.userID = params.userID;
|
|
33991
|
+
this.chatType = params.chatType || 0;
|
|
33992
|
+
this.singleChatID = params.singleChatID || "";
|
|
33993
|
+
this.customParams = params.customParams || {};
|
|
33994
|
+
this.chartOrigin = params.chartOrigin;
|
|
33995
|
+
// console.log("ChatClientMgr init:", this.actionKey);
|
|
34168
33996
|
}
|
|
34169
|
-
|
|
34170
|
-
|
|
34171
|
-
|
|
34172
|
-
|
|
34173
|
-
|
|
34174
|
-
|
|
34175
|
-
|
|
34176
|
-
|
|
34177
|
-
|
|
34178
|
-
|
|
34179
|
-
|
|
34180
|
-
|
|
34181
|
-
|
|
33997
|
+
makeKey(key) {
|
|
33998
|
+
return `${key}-${this.actionKey}`;
|
|
33999
|
+
}
|
|
34000
|
+
async init() {
|
|
34001
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_access_token`), async data => {
|
|
34002
|
+
return await this.handler.getPortalAccessToken(data);
|
|
34003
|
+
});
|
|
34004
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_user_info`), async data => {
|
|
34005
|
+
return await this.handler.getPortalUserInfo(data);
|
|
34006
|
+
});
|
|
34007
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_user_sig`), async data => {
|
|
34008
|
+
let userID = data.userID;
|
|
34009
|
+
let platType = data.im_type;
|
|
34010
|
+
let groupID = data.group_id;
|
|
34011
|
+
return await this.handler.getPortalUserSig(userID, platType, groupID);
|
|
34012
|
+
});
|
|
34013
|
+
this.handler.addChatListener(this.makeKey(`sdata_add_im_mapping`), async data => {
|
|
34014
|
+
let userID = data.userID;
|
|
34015
|
+
let platType = data.im_type;
|
|
34016
|
+
let userSig = data.userSig;
|
|
34017
|
+
return await this.handler.addIMMapping(userID, platType, userSig, this.groupID);
|
|
34018
|
+
});
|
|
34019
|
+
this.handler.addChatListener(this.makeKey(`sdata_update_im_mapping`), async data => {
|
|
34020
|
+
return await this.handler.updateIMMapping(data);
|
|
34021
|
+
});
|
|
34022
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_users_by_group_id`), async data => {
|
|
34023
|
+
return await this.handler.getAllUserInfosByGroupID(data);
|
|
34024
|
+
});
|
|
34025
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_dpts_by_group_id`), async data => {
|
|
34026
|
+
return await this.handler.getChildrenOfficeInfosByID(data);
|
|
34027
|
+
});
|
|
34028
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_project_dpts_by_user_group_id`), async data => {
|
|
34029
|
+
return await this.handler.getPojectDptsByUserAndGroupID(data);
|
|
34030
|
+
});
|
|
34031
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_ai_robot_infos`), async data => {
|
|
34032
|
+
let groupID = data.groupID;
|
|
34033
|
+
let userID = data.userID;
|
|
34034
|
+
if (this.userID == userID && this.groupID == groupID) {
|
|
34035
|
+
return this.getAIRobotInfos();
|
|
34182
34036
|
}
|
|
34183
|
-
|
|
34184
|
-
}
|
|
34037
|
+
return [];
|
|
34038
|
+
});
|
|
34039
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_test_user_sig`), async data => {
|
|
34040
|
+
let sdkAppID = data.SDKAppID;
|
|
34041
|
+
let userID = data.userID;
|
|
34042
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
34043
|
+
SDKAppID: sdkAppID,
|
|
34044
|
+
userID: userID
|
|
34045
|
+
});
|
|
34046
|
+
let sigID = sigIDObject.userSig;
|
|
34047
|
+
return sigID;
|
|
34048
|
+
});
|
|
34049
|
+
this.handler.addChatListener(this.makeKey(`sdata_send_message_to_chat_server`), async (data, event) => {
|
|
34050
|
+
let message = data.message;
|
|
34051
|
+
let robotID = message.from;
|
|
34052
|
+
let result = await this.sendMessageToChatServer(robotID, message);
|
|
34053
|
+
return result;
|
|
34054
|
+
});
|
|
34055
|
+
this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
|
|
34056
|
+
return this.handler.closeWindow();
|
|
34057
|
+
});
|
|
34058
|
+
this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
|
|
34059
|
+
return this.handler.getPortalDocmentInfo(data);
|
|
34060
|
+
});
|
|
34061
|
+
this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
|
|
34062
|
+
return this.handler.onAIAgentEvent(data, event);
|
|
34063
|
+
});
|
|
34064
|
+
this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
|
|
34065
|
+
console.log("recive chat regist event data:", data);
|
|
34066
|
+
this.appSKID = data.appid;
|
|
34067
|
+
this.imType = data.im_type;
|
|
34068
|
+
await this.initChatAIs();
|
|
34069
|
+
let charParams = {
|
|
34070
|
+
type: this.getChatTypeKey(this.chatType),
|
|
34071
|
+
singleChatID: this.singleChatID,
|
|
34072
|
+
customParams: this.customParams
|
|
34073
|
+
};
|
|
34074
|
+
this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
|
|
34075
|
+
if (result) {
|
|
34076
|
+
console.log("chat init finished:", result);
|
|
34077
|
+
this.handler.onChatInitFinished();
|
|
34078
|
+
}
|
|
34079
|
+
});
|
|
34080
|
+
});
|
|
34185
34081
|
}
|
|
34186
|
-
|
|
34187
|
-
|
|
34188
|
-
|
|
34189
|
-
|
|
34190
|
-
|
|
34191
|
-
|
|
34082
|
+
getChatTypeKey(type) {
|
|
34083
|
+
switch (type) {
|
|
34084
|
+
case 0:
|
|
34085
|
+
return "IM_MULTIPLE_MODE";
|
|
34086
|
+
case 1:
|
|
34087
|
+
return "IM_SINGLE_MODE";
|
|
34088
|
+
case 2:
|
|
34089
|
+
return "IM_EMBED_MODE";
|
|
34090
|
+
case 3:
|
|
34091
|
+
return "IM_MOBILE_MULTIPLE_EMBED_MODE";
|
|
34092
|
+
case 4:
|
|
34093
|
+
return "IM_MOBILE_SINGLE_EMBED_MODE";
|
|
34094
|
+
default:
|
|
34095
|
+
return "IM_MULTIPLE_MODE";
|
|
34096
|
+
}
|
|
34192
34097
|
}
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
newValue = element.getAttribute("oldValue");
|
|
34208
|
-
if (!newValue) {
|
|
34209
|
-
newValue = element.innerHTML;
|
|
34098
|
+
async initChatAIs() {
|
|
34099
|
+
if (window.imClient) {
|
|
34100
|
+
this.chatAIClient = window.imClient;
|
|
34101
|
+
} else {
|
|
34102
|
+
let classDatas = await this.handler.getChatClientClasses();
|
|
34103
|
+
const {
|
|
34104
|
+
TencentCloudChat,
|
|
34105
|
+
TIMUploadPlugin
|
|
34106
|
+
} = classDatas;
|
|
34107
|
+
window.imClient = TencentCloudChat.create({
|
|
34108
|
+
SDKAppID: this.appSKID,
|
|
34109
|
+
// 替换为你的 SDKAppID
|
|
34110
|
+
storage: {
|
|
34111
|
+
enable: true // 启用存储(可选,根据需求)
|
|
34210
34112
|
}
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
}
|
|
34113
|
+
});
|
|
34114
|
+
window.imClient.registerPlugin({
|
|
34115
|
+
"tim-upload-plugin": TIMUploadPlugin
|
|
34116
|
+
});
|
|
34117
|
+
window.imClient.on(TencentCloudChat.EVENT.SDK_READY, this.onChatAIReady.bind(this));
|
|
34118
|
+
window.imClient.charAIs = {};
|
|
34119
|
+
this.chatAIClient = window.imClient;
|
|
34120
|
+
}
|
|
34121
|
+
if (!this.chatAIClient.charAIs) {
|
|
34122
|
+
this.chatAIClient.charAIs = {};
|
|
34123
|
+
}
|
|
34124
|
+
let robotInfos = await this.handler.getAIRobotInfos(this.userID, this.groupID);
|
|
34125
|
+
if (robotInfos && robotInfos.length > 0) {
|
|
34126
|
+
robotInfos.forEach(async robot => {
|
|
34127
|
+
let robotKey = robot.id;
|
|
34128
|
+
if (!this.chatAIClient.charAIs[robotKey]) {
|
|
34129
|
+
robot.chatID = robotKey;
|
|
34130
|
+
let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
|
|
34131
|
+
if (!userSig) {
|
|
34132
|
+
userSig = await this.generateUserSigAndAdd(robotKey);
|
|
34133
|
+
}
|
|
34134
|
+
robot.userSig = userSig;
|
|
34135
|
+
this.chatAIClient.charAIs[robotKey] = {
|
|
34136
|
+
robot: robot,
|
|
34137
|
+
messageCache: []
|
|
34138
|
+
};
|
|
34139
|
+
}
|
|
34140
|
+
});
|
|
34217
34141
|
}
|
|
34218
34142
|
}
|
|
34219
|
-
|
|
34220
|
-
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34227
|
-
|
|
34228
|
-
|
|
34229
|
-
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
|
|
34234
|
-
|
|
34235
|
-
|
|
34236
|
-
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
|
|
34240
|
-
scriptFunction: innerHTMLMatch ? innerHTMLMatch.scriptFunction || null : null,
|
|
34241
|
-
isAttibuteAction: attrCheckResult.result,
|
|
34242
|
-
attrFunction: attrCheckResult.scriptFunction || null
|
|
34243
|
-
});
|
|
34244
|
-
// console.log("添加后元素缓冲数:",window.i18nElementsMap.size);
|
|
34245
|
-
applyTranslation(element);
|
|
34246
|
-
return true;
|
|
34247
|
-
}
|
|
34248
|
-
function unProcessElement(element) {
|
|
34249
|
-
if (element && element.nodeType !== 1) {
|
|
34250
|
-
return;
|
|
34143
|
+
async generateUserSigAndUpdate(robotKey) {
|
|
34144
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
34145
|
+
SDKAppID: this.appSKID,
|
|
34146
|
+
userID: robotKey
|
|
34147
|
+
});
|
|
34148
|
+
let userSig = sigIDObject.userSig;
|
|
34149
|
+
if (userSig) {
|
|
34150
|
+
await this.chatAIClient.login({
|
|
34151
|
+
userID: robotKey,
|
|
34152
|
+
userSig: userSig
|
|
34153
|
+
});
|
|
34154
|
+
await this.chatAIClient.logout();
|
|
34155
|
+
let data = {
|
|
34156
|
+
userID: robotKey,
|
|
34157
|
+
userSig: userSig,
|
|
34158
|
+
im_type: this.imType,
|
|
34159
|
+
group_id: this.groupID
|
|
34160
|
+
};
|
|
34161
|
+
await this.handler.updateIMMapping(data);
|
|
34162
|
+
}
|
|
34163
|
+
return userSig;
|
|
34251
34164
|
}
|
|
34252
|
-
|
|
34253
|
-
|
|
34254
|
-
|
|
34255
|
-
|
|
34256
|
-
|
|
34165
|
+
async generateUserSigAndAdd(robotKey) {
|
|
34166
|
+
let sigIDObject = await this.handler.genTestUserSig({
|
|
34167
|
+
SDKAppID: this.appSKID,
|
|
34168
|
+
userID: robotKey
|
|
34169
|
+
});
|
|
34170
|
+
let userSig = sigIDObject.userSig;
|
|
34171
|
+
if (userSig) {
|
|
34172
|
+
await this.chatAIClient.login({
|
|
34173
|
+
userID: robotKey,
|
|
34174
|
+
userSig: userSig
|
|
34175
|
+
});
|
|
34176
|
+
await this.chatAIClient.logout();
|
|
34177
|
+
await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
|
|
34257
34178
|
}
|
|
34179
|
+
return userSig;
|
|
34258
34180
|
}
|
|
34259
|
-
|
|
34260
|
-
|
|
34261
|
-
|
|
34262
|
-
|
|
34181
|
+
onChatAIReady(event) {
|
|
34182
|
+
let robotID = this.chatAIClient.lastRobotID;
|
|
34183
|
+
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
34184
|
+
console.log(`[AI chat] ${robotInfo.name}已经就绪:`, event);
|
|
34185
|
+
if (this.chatAIClient) {
|
|
34186
|
+
let messages = this.getAIRobotCacheMessagesByID(robotID);
|
|
34187
|
+
console.log(`[AI chat] ${robotInfo.name}就绪后查到的缓存信息:`, messages);
|
|
34188
|
+
console.log(`[AI chat] ${robotInfo.name}所有信息仓:`, this.chatAIClient.charAIs);
|
|
34189
|
+
if (messages && messages.length > 0) {
|
|
34190
|
+
const newMessages = [...messages];
|
|
34191
|
+
messages.splice(0, messages.length);
|
|
34192
|
+
newMessages.forEach(message => {
|
|
34193
|
+
console.log(`[AI chat] ${robotInfo.name}发送缓存消息:`, message);
|
|
34194
|
+
this.sendMessageToChatServer(robotID, message);
|
|
34195
|
+
});
|
|
34196
|
+
}
|
|
34197
|
+
}
|
|
34263
34198
|
}
|
|
34264
|
-
|
|
34265
|
-
|
|
34266
|
-
|
|
34267
|
-
|
|
34268
|
-
|
|
34269
|
-
|
|
34270
|
-
// }
|
|
34271
|
-
window.i18nElementsMap.delete(localDomID);
|
|
34272
|
-
// console.log("移除后元素缓冲数:",window.i18nElementsMap.size);
|
|
34199
|
+
getAIRobotInfos() {
|
|
34200
|
+
let resultRobots = [];
|
|
34201
|
+
for (let key in this.chatAIClient.charAIs) {
|
|
34202
|
+
resultRobots.push(this.chatAIClient.charAIs[key].robot);
|
|
34203
|
+
}
|
|
34204
|
+
return resultRobots;
|
|
34273
34205
|
}
|
|
34274
|
-
|
|
34275
|
-
|
|
34276
|
-
/**
|
|
34277
|
-
* 应用翻译到单个元素
|
|
34278
|
-
* @param {HTMLElement} element - 要更新的DOM元素
|
|
34279
|
-
* @param {string} lang - 语言标识符
|
|
34280
|
-
*/
|
|
34281
|
-
const applyTranslation = async element => {
|
|
34282
|
-
let parentNode = element.parentNode;
|
|
34283
|
-
if (!parentNode) {
|
|
34284
|
-
unProcessElement(element);
|
|
34285
|
-
console.log("元素已无父节点,移除缓存");
|
|
34286
|
-
return;
|
|
34206
|
+
getAIRobotInfoByID(robotID) {
|
|
34207
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].robot : null;
|
|
34287
34208
|
}
|
|
34288
|
-
|
|
34289
|
-
|
|
34290
|
-
const elementId = element.getAttribute("localDomID");
|
|
34291
|
-
const cachedItem = window.i18nElementsMap.get(elementId);
|
|
34292
|
-
if (!cachedItem) return;
|
|
34293
|
-
// 处理属性
|
|
34294
|
-
if (cachedItem.isAttibuteAction) {
|
|
34295
|
-
cachedItem.attrFunction(appID, lang);
|
|
34209
|
+
getAIRobotCacheMessagesByID(robotID) {
|
|
34210
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].messageCache : [];
|
|
34296
34211
|
}
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
|
|
34301
|
-
|
|
34302
|
-
|
|
34303
|
-
// 创建正则表达式匹配所有 $L{...} 格式
|
|
34304
|
-
const regex = /\$L\{([^}]+)\}/g;
|
|
34305
|
-
// 替换所有 $L{...} 占位符为翻译文本
|
|
34306
|
-
let newValue = oldValue;
|
|
34307
|
-
let match;
|
|
34308
|
-
while ((match = regex.exec(oldValue)) !== null) {
|
|
34309
|
-
const fullMatch = match[0];
|
|
34310
|
-
const placeholderKey = match[1];
|
|
34311
|
-
const translation = i18n(placeholderKey, appID, lang);
|
|
34312
|
-
newValue = newValue.replace(fullMatch, translation);
|
|
34212
|
+
async sendMessageToChatServer(robotID, messageOption) {
|
|
34213
|
+
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
34214
|
+
if (this.chatAIClient.lastRobotID != robotID) {
|
|
34215
|
+
console.log(`[AI chat]需要新机器人回答,切换到新机器人${robotInfo.name}`);
|
|
34216
|
+
if (this.chatAIClient.lastRobotID) {
|
|
34217
|
+
await this.chatAIClient.logout();
|
|
34313
34218
|
}
|
|
34314
|
-
|
|
34315
|
-
|
|
34316
|
-
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
};
|
|
34321
|
-
|
|
34322
|
-
|
|
34323
|
-
|
|
34324
|
-
|
|
34325
|
-
|
|
34326
|
-
|
|
34327
|
-
|
|
34328
|
-
|
|
34329
|
-
|
|
34330
|
-
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
// 创建观察器实例
|
|
34336
|
-
const observer = new MutationObserver(mutations => {
|
|
34337
|
-
mutations.forEach(mutation => {
|
|
34338
|
-
if (mutation.type === 'childList') {
|
|
34339
|
-
// 节点添加
|
|
34340
|
-
if (mutation.addedNodes.length > 0) {
|
|
34341
|
-
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
34342
|
-
let node = mutation.addedNodes[i];
|
|
34343
|
-
// console.log(`处理新增节点:`,node);
|
|
34344
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
34345
|
-
node = node.parentNode;
|
|
34346
|
-
}
|
|
34347
|
-
processElement(node);
|
|
34348
|
-
}
|
|
34349
|
-
}
|
|
34350
|
-
// 节点移除
|
|
34351
|
-
if (mutation.removedNodes.length > 0) {
|
|
34352
|
-
for (let i = 0; i < mutation.removedNodes.length; i++) {
|
|
34353
|
-
let node = mutation.removedNodes[i];
|
|
34354
|
-
// console.log(`处理移除节点:`,node);
|
|
34355
|
-
unProcessElement(node);
|
|
34356
|
-
}
|
|
34357
|
-
}
|
|
34358
|
-
} else if (mutation.type === 'characterData') {
|
|
34359
|
-
// 处理文本变化
|
|
34360
|
-
const oldValue = mutation.oldValue;
|
|
34361
|
-
const targetNode = mutation.target;
|
|
34362
|
-
const newValue = targetNode.data;
|
|
34363
|
-
// 创建日志条目并显示
|
|
34364
|
-
console.log(`文本修改: ${oldValue} → ${newValue}`);
|
|
34365
|
-
const parentElement = targetNode.parentNode;
|
|
34366
|
-
if (parentElement) {
|
|
34367
|
-
let localDomID = parentElement.getAttribute("localDomID");
|
|
34368
|
-
// 如果有localDomID,说明之前处理过,先移除缓存
|
|
34369
|
-
if (localDomID) {
|
|
34370
|
-
unProcessElement(parentElement);
|
|
34219
|
+
try {
|
|
34220
|
+
await this.chatAIClient.login({
|
|
34221
|
+
userID: robotID,
|
|
34222
|
+
userSig: robotInfo.userSig
|
|
34223
|
+
});
|
|
34224
|
+
} catch (err) {
|
|
34225
|
+
console.log(`[AI chat]${robotInfo.name}登录失败`, err);
|
|
34226
|
+
let code = err.code;
|
|
34227
|
+
if (code == 70001) {
|
|
34228
|
+
console.log(`[AI chat]${robotInfo.name}UserSig过期,重新生成userSig`);
|
|
34229
|
+
let newUserSig = await this.generateUserSigAndUpdate(robotID);
|
|
34230
|
+
try {
|
|
34231
|
+
await this.chatAIClient.login({
|
|
34232
|
+
userID: robotID,
|
|
34233
|
+
userSig: newUserSig
|
|
34234
|
+
});
|
|
34235
|
+
this.sendMessageToChatServer(robotID, messageOption);
|
|
34236
|
+
return;
|
|
34237
|
+
} catch (err) {
|
|
34238
|
+
console.log(`[AI chat]${robotInfo.name}重新登录失败`, err);
|
|
34239
|
+
return;
|
|
34371
34240
|
}
|
|
34372
34241
|
}
|
|
34373
|
-
processElement(parentElement);
|
|
34374
34242
|
}
|
|
34375
|
-
}
|
|
34376
|
-
|
|
34243
|
+
}
|
|
34244
|
+
this.chatAIClient.lastRobotID = robotID;
|
|
34245
|
+
if (this.chatAIClient && this.chatAIClient.isReady()) {
|
|
34246
|
+
let new_message = await this.chatAIClient.createTextMessage(messageOption);
|
|
34247
|
+
this.chatAIClient.sendMessage(new_message).then(res => {
|
|
34248
|
+
console.log(`[AI chat]${robotInfo.name}发送信息成功`, res);
|
|
34249
|
+
}, err => {
|
|
34250
|
+
console.log(`[AI chat]${robotInfo.name}发送失败`, err);
|
|
34251
|
+
});
|
|
34252
|
+
} else {
|
|
34253
|
+
let messageCache = this.getAIRobotCacheMessagesByID(robotID);
|
|
34254
|
+
messageCache.push(messageOption);
|
|
34255
|
+
console.log(`[AI chat]${robotInfo.name}未就绪,缓存后消息:`, messageCache);
|
|
34256
|
+
}
|
|
34257
|
+
}
|
|
34258
|
+
converToAIServerParams(message, robotInfo, param) {
|
|
34259
|
+
let prompt = "";
|
|
34260
|
+
let type = message.type;
|
|
34261
|
+
switch (type) {
|
|
34262
|
+
case "TIMTextElem":
|
|
34263
|
+
prompt = message.payload?.text || "";
|
|
34264
|
+
break;
|
|
34265
|
+
case "TIMImageElem":
|
|
34266
|
+
break;
|
|
34267
|
+
case "TIMSoundElem":
|
|
34268
|
+
break;
|
|
34269
|
+
case "TIMVideoFileElem":
|
|
34270
|
+
break;
|
|
34271
|
+
case "TIMFileElem":
|
|
34272
|
+
break;
|
|
34273
|
+
default:
|
|
34274
|
+
break;
|
|
34275
|
+
}
|
|
34276
|
+
let cloudCustomData = message.cloudCustomData || {};
|
|
34277
|
+
let conversation_id = cloudCustomData.conversation_id || "";
|
|
34278
|
+
let params = {
|
|
34279
|
+
prompt: prompt,
|
|
34280
|
+
params: param || {},
|
|
34281
|
+
robotKey: robotInfo.password,
|
|
34282
|
+
conversation_id: conversation_id || "",
|
|
34283
|
+
userID: message.from || ""
|
|
34284
|
+
};
|
|
34285
|
+
return params;
|
|
34286
|
+
}
|
|
34287
|
+
abort() {
|
|
34288
|
+
this.chatAIClient = null;
|
|
34289
|
+
}
|
|
34290
|
+
}
|
|
34291
|
+
;// ./src/api/chat.js
|
|
34377
34292
|
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
|
|
34385
|
-
|
|
34386
|
-
|
|
34387
|
-
// 不观察文本内容变化
|
|
34388
|
-
characterDataOldValue: true
|
|
34293
|
+
|
|
34294
|
+
|
|
34295
|
+
|
|
34296
|
+
const getRobotInfoByID = async (robotID, groupID) => {
|
|
34297
|
+
let queryData = {
|
|
34298
|
+
"param": {
|
|
34299
|
+
"id": robotID,
|
|
34300
|
+
"groupID": groupID
|
|
34301
|
+
}
|
|
34389
34302
|
};
|
|
34390
|
-
|
|
34391
|
-
|
|
34392
|
-
|
|
34393
|
-
observer.observe(targetNode, config);
|
|
34303
|
+
let result = await request.post(`/dataservice/rest/orchestration/getRobotInfoByID`, queryData);
|
|
34304
|
+
let robotInfo = result.data.robotInfo;
|
|
34305
|
+
return robotInfo;
|
|
34394
34306
|
};
|
|
34395
|
-
const
|
|
34396
|
-
|
|
34397
|
-
|
|
34398
|
-
|
|
34399
|
-
|
|
34400
|
-
|
|
34401
|
-
|
|
34402
|
-
|
|
34403
|
-
|
|
34404
|
-
|
|
34405
|
-
|
|
34307
|
+
const getIMHanlder = customerHanlder => {
|
|
34308
|
+
let handler = {
|
|
34309
|
+
genTestUserSig: async data => {
|
|
34310
|
+
// return genTestUserSig(data);
|
|
34311
|
+
},
|
|
34312
|
+
getChatClientClasses: async () => {
|
|
34313
|
+
return [];
|
|
34314
|
+
},
|
|
34315
|
+
getAIRobotInfos: async (user_id, groupID) => {
|
|
34316
|
+
return getAIRobotInfos(user_id, groupID);
|
|
34317
|
+
},
|
|
34318
|
+
getPortalUserSig: async (robotKey, platType, groupID) => {
|
|
34319
|
+
return getPortalUserSig(robotKey, platType, groupID);
|
|
34320
|
+
},
|
|
34321
|
+
addIMMapping: async (robotKey, platType, userSig, groupID) => {
|
|
34322
|
+
return addIMMapping(robotKey, platType, groupID, userSig);
|
|
34323
|
+
},
|
|
34324
|
+
updateIMMapping: async data => {
|
|
34325
|
+
let robotKey = data.userID;
|
|
34326
|
+
let platType = data.im_type;
|
|
34327
|
+
let groupID = data.group_id;
|
|
34328
|
+
let userSig = data.userSig;
|
|
34329
|
+
return updateIMMapping(robotKey, platType, groupID, userSig);
|
|
34330
|
+
},
|
|
34331
|
+
getPortalAccessToken: async data => {
|
|
34332
|
+
let appKey = data.appKey;
|
|
34333
|
+
let appSecret = data.appSecret;
|
|
34334
|
+
return getPortalAccessToken(appKey, appSecret);
|
|
34335
|
+
},
|
|
34336
|
+
getPortalUserInfo: async data => {
|
|
34337
|
+
let code = data.code;
|
|
34338
|
+
let access_token = data.access_token;
|
|
34339
|
+
return getPortalUserInfo(code, access_token);
|
|
34340
|
+
},
|
|
34341
|
+
getAllUserInfosByGroupID: async data => {
|
|
34342
|
+
let groupID = data.groupID;
|
|
34343
|
+
return getAllUserInfosByGroupID(groupID);
|
|
34344
|
+
},
|
|
34345
|
+
getChildrenOfficeInfosByID: async data => {
|
|
34346
|
+
let groupID = data.groupID;
|
|
34347
|
+
return getChildrenOfficeInfosByID(groupID);
|
|
34348
|
+
},
|
|
34349
|
+
getPojectDptsByUserAndGroupID: async data => {
|
|
34350
|
+
let groupID = data.groupID;
|
|
34351
|
+
let userID = data.userID;
|
|
34352
|
+
return getPojectDptsByUserAndGroupID(userID, groupID);
|
|
34353
|
+
},
|
|
34354
|
+
closeWindow: () => {
|
|
34355
|
+
// this.visable = false;
|
|
34356
|
+
return true;
|
|
34357
|
+
},
|
|
34358
|
+
addChatListener: async (listenerKey, handler) => {
|
|
34359
|
+
await addEventAction(listenerKey, handler);
|
|
34360
|
+
},
|
|
34361
|
+
fireEventToChatWindow: async (event, chart_origin, key, params, handler) => {
|
|
34362
|
+
await sendWindowMessage(event.source, chart_origin, key, params, handler);
|
|
34363
|
+
},
|
|
34364
|
+
onChatInitFinished: async () => {
|
|
34365
|
+
// this.chatInitFinish = true;
|
|
34366
|
+
},
|
|
34367
|
+
onAIAgentEvent: async (data, event) => {
|
|
34368
|
+
// this.onAIAgentEvent(data,event);
|
|
34369
|
+
},
|
|
34370
|
+
getPortalDocmentInfo: async data => {
|
|
34371
|
+
let kb_doc_id = data.kb_doc_id;
|
|
34372
|
+
let doc_info = await getPortalDocmentInfo(kb_doc_id);
|
|
34373
|
+
let urlStr = doc_info?.summary;
|
|
34374
|
+
if (urlStr) {
|
|
34375
|
+
let urlObj = JSON.parse(urlStr);
|
|
34376
|
+
if (urlObj) {
|
|
34377
|
+
let url = urlObj[0].url;
|
|
34378
|
+
let home_page = window.smardaten_api_context_path;
|
|
34379
|
+
let finalUrl = `${home_page}/storage_area/public${url}`;
|
|
34380
|
+
let fileSize = await getFileSize(finalUrl);
|
|
34381
|
+
doc_info.fileSize = fileSize;
|
|
34406
34382
|
}
|
|
34407
34383
|
}
|
|
34408
|
-
|
|
34409
|
-
|
|
34410
|
-
|
|
34411
|
-
// 配置观察选项
|
|
34412
|
-
const config = {
|
|
34413
|
-
childList: true,
|
|
34414
|
-
// 观察子节点变化
|
|
34415
|
-
subtree: true,
|
|
34416
|
-
// 观察所有后代节点
|
|
34417
|
-
attributes: false,
|
|
34418
|
-
// 不观察属性变化
|
|
34419
|
-
characterData: true,
|
|
34420
|
-
// 不观察文本内容变化
|
|
34421
|
-
characterDataOldValue: true
|
|
34384
|
+
return doc_info;
|
|
34385
|
+
}
|
|
34422
34386
|
};
|
|
34423
|
-
|
|
34424
|
-
|
|
34425
|
-
|
|
34426
|
-
|
|
34387
|
+
handler = {
|
|
34388
|
+
...handler,
|
|
34389
|
+
...customerHanlder
|
|
34390
|
+
};
|
|
34391
|
+
return handler;
|
|
34427
34392
|
};
|
|
34428
34393
|
|
|
34429
|
-
|
|
34430
|
-
|
|
34431
|
-
|
|
34432
|
-
|
|
34433
|
-
|
|
34434
|
-
|
|
34435
|
-
|
|
34436
|
-
|
|
34437
|
-
|
|
34438
|
-
|
|
34439
|
-
|
|
34440
|
-
if (hasChildren) {
|
|
34441
|
-
let children = element.children;
|
|
34442
|
-
for (let i = 0; i < children.length; i++) {
|
|
34443
|
-
let child = children[i];
|
|
34444
|
-
processViewElement(child);
|
|
34445
|
-
}
|
|
34446
|
-
}
|
|
34447
|
-
let checkState = element.getAttribute("viewDomID");
|
|
34448
|
-
// 已经处理过的元素跳过
|
|
34449
|
-
if (checkState) {
|
|
34450
|
-
return false;
|
|
34394
|
+
;// ./src/api/dify.js
|
|
34395
|
+
|
|
34396
|
+
|
|
34397
|
+
const sendPostToAIAgent = async (queryData, successCallback, errorCallback) => {
|
|
34398
|
+
let appid = getPoratlAppID();
|
|
34399
|
+
let appCustomData = await getAppCustomData(appid);
|
|
34400
|
+
let aiAgentServerIP = appCustomData?.aiAgentServerIP || "";
|
|
34401
|
+
if (!aiAgentServerIP) {
|
|
34402
|
+
console.error("没有配置AI Agent服务地址,请联系管理员");
|
|
34403
|
+
if (errorCallback) errorCallback("没有配置AI Agent服务地址,请联系管理员");
|
|
34404
|
+
return;
|
|
34451
34405
|
}
|
|
34452
|
-
|
|
34453
|
-
|
|
34454
|
-
|
|
34455
|
-
|
|
34406
|
+
let serverUrl = `${aiAgentServerIP}/addAndCleanDocument`;
|
|
34407
|
+
request.post(serverUrl, JSON.stringify(queryData)).then(res => {
|
|
34408
|
+
console.log("发送消息成功:", res);
|
|
34409
|
+
if (successCallback) successCallback(res);
|
|
34410
|
+
}).catch(error => {
|
|
34411
|
+
console.error("发送消息失败:", error);
|
|
34412
|
+
if (errorCallback) errorCallback(error);
|
|
34413
|
+
});
|
|
34414
|
+
};
|
|
34415
|
+
const getDifyFileType = fileType => {
|
|
34416
|
+
let typeOptions = {
|
|
34417
|
+
"DOCX": "document",
|
|
34418
|
+
"TXT": "document",
|
|
34419
|
+
"MD": "document",
|
|
34420
|
+
"MARKDOWN": "document",
|
|
34421
|
+
"MDX": "document",
|
|
34422
|
+
"PDF": "document",
|
|
34423
|
+
"HTML": "document",
|
|
34424
|
+
"XLSX": "document",
|
|
34425
|
+
"XLS": "document",
|
|
34426
|
+
"VTT": "document",
|
|
34427
|
+
"DOC": "document",
|
|
34428
|
+
"CSV": "document",
|
|
34429
|
+
"EML": "document",
|
|
34430
|
+
"MSG": "document",
|
|
34431
|
+
"PPTX": "document",
|
|
34432
|
+
"PPT": "document",
|
|
34433
|
+
"XML": "document",
|
|
34434
|
+
"EPUB": "document",
|
|
34435
|
+
"JPG": "image",
|
|
34436
|
+
"JPEG": "image",
|
|
34437
|
+
"PNG": "image",
|
|
34438
|
+
"GIF": "image",
|
|
34439
|
+
"WEBP": "image",
|
|
34440
|
+
"MP3": "audio",
|
|
34441
|
+
"M4A": "audio",
|
|
34442
|
+
"WAV": "audio",
|
|
34443
|
+
"WEBM": "audio",
|
|
34444
|
+
"MPGA": "audio",
|
|
34445
|
+
"MP4": "video",
|
|
34446
|
+
"MOV": "video",
|
|
34447
|
+
"MPEG": "video"
|
|
34448
|
+
};
|
|
34449
|
+
let key = fileType.toUpperCase();
|
|
34450
|
+
return typeOptions[key] || "custom";
|
|
34451
|
+
};
|
|
34452
|
+
|
|
34453
|
+
/**
|
|
34454
|
+
* 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
|
|
34455
|
+
* @param {string} url - 文件 URL
|
|
34456
|
+
* @returns {string} - 提取的文件名
|
|
34457
|
+
*/
|
|
34458
|
+
const dify_extractFilenameFromUrl = url => {
|
|
34459
|
+
try {
|
|
34460
|
+
const urlObj = new URL(url);
|
|
34461
|
+
// 从路径中获取最后一个部分(文件名)
|
|
34462
|
+
return urlObj.pathname.split("/").pop() || "downloaded_file";
|
|
34463
|
+
} catch (e) {
|
|
34464
|
+
return "downloaded_file"; // URL 解析失败时的默认文件名
|
|
34456
34465
|
}
|
|
34457
|
-
|
|
34458
|
-
return true;
|
|
34459
|
-
}
|
|
34466
|
+
};
|
|
34460
34467
|
;// ./src/main.js
|
|
34461
34468
|
|
|
34462
34469
|
|