hifun-tools 1.4.48 → 1.4.50
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/init/index.js +65 -50
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/init/index.js
CHANGED
|
@@ -341,7 +341,7 @@ class InitCls {
|
|
|
341
341
|
* 直接传入域名
|
|
342
342
|
*/
|
|
343
343
|
switchAddressLine(line) {
|
|
344
|
-
this.domainBaseUrl = line;
|
|
344
|
+
this.domainBaseUrl = toStandardUrl(line);
|
|
345
345
|
console.log("切换线路为:", line);
|
|
346
346
|
}
|
|
347
347
|
/** 手动更新线路速度延迟 */
|
|
@@ -372,64 +372,79 @@ class InitCls {
|
|
|
372
372
|
const tenantDictList = this.getTenantDictList().filter((a) => !this.ErrorDomainUrl.includes(a.lineGroup));
|
|
373
373
|
this.domainBaseUrl = this.defaultBaseUrl;
|
|
374
374
|
console.info(`✅ defaultBaseUrl 可用,响应时间: ${this.speedDelay}ms`);
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
originBaseUrlRetrieved = true;
|
|
384
|
-
console.info("✅ 使用传入的 lineAddressData 设置 OriginBaseUrl");
|
|
385
|
-
}
|
|
386
|
-
catch (err) {
|
|
387
|
-
console.info("⚠️ 传入的 lineAddressData 解析失败,尝试其他方式");
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
// 2. 尝试获取远程 lineAddress.txt
|
|
391
|
-
if (!originBaseUrlRetrieved) {
|
|
392
|
-
try {
|
|
393
|
-
console.info("🌐 尝试获取远程 lineAddress.txt 设置 OriginBaseUrl...");
|
|
394
|
-
const response = await fetch(`/lineAddress.txt?t=${Date.now()}`);
|
|
395
|
-
if (response.ok) {
|
|
396
|
-
const configText = await response.text();
|
|
397
|
-
const originBaseUrl = JSON.parse(AesDecrypt(configText));
|
|
375
|
+
// 立即返回结果,同时在后台执行后续逻辑
|
|
376
|
+
(async () => {
|
|
377
|
+
// 尝试获取 OriginBaseUrl 数据,不用于测速,仅用于设置 OriginBaseUrl
|
|
378
|
+
let originBaseUrlRetrieved = false;
|
|
379
|
+
// 1. 尝试使用传入的 lineAddressData
|
|
380
|
+
if (lineAddressData && !originBaseUrlRetrieved) {
|
|
381
|
+
try {
|
|
382
|
+
const originBaseUrl = JSON.parse(AesDecrypt(lineAddressData));
|
|
398
383
|
this.OriginBaseUrl = filterSmartLines(tenantDictList, originBaseUrl);
|
|
399
384
|
if (this.OriginBaseUrl.length > 0)
|
|
400
385
|
originBaseUrlRetrieved = true;
|
|
401
|
-
console.info("✅
|
|
386
|
+
console.info("✅ 使用传入的 lineAddressData 设置 OriginBaseUrl");
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
console.info("⚠️ 传入的 lineAddressData 解析失败,尝试其他方式");
|
|
402
390
|
}
|
|
403
391
|
}
|
|
404
|
-
|
|
405
|
-
|
|
392
|
+
// 2. 尝试获取远程 lineAddress.txt
|
|
393
|
+
if (!originBaseUrlRetrieved) {
|
|
394
|
+
try {
|
|
395
|
+
console.info("🌐 尝试获取远程 lineAddress.txt 设置 OriginBaseUrl...");
|
|
396
|
+
const response = await fetch(`/lineAddress.txt?t=${Date.now()}`);
|
|
397
|
+
if (response.ok) {
|
|
398
|
+
const configText = await response.text();
|
|
399
|
+
const originBaseUrl = JSON.parse(AesDecrypt(configText));
|
|
400
|
+
if (tenantDictList.length > 1) {
|
|
401
|
+
this.OriginBaseUrl = filterSmartLines(tenantDictList, originBaseUrl);
|
|
402
|
+
if (this.OriginBaseUrl.length > 0)
|
|
403
|
+
originBaseUrlRetrieved = true;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
this.OriginBaseUrl = originBaseUrl;
|
|
407
|
+
originBaseUrlRetrieved = true;
|
|
408
|
+
}
|
|
409
|
+
console.info("✅ 使用远程 lineAddress.txt 设置 OriginBaseUrl");
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch (err) {
|
|
413
|
+
console.info("⚠️ 获取远程 lineAddress.txt 失败,尝试备用地址");
|
|
414
|
+
}
|
|
406
415
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
this.backupAddress
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
// 3. 尝试备用地址
|
|
417
|
+
if (!originBaseUrlRetrieved) {
|
|
418
|
+
try {
|
|
419
|
+
console.info("🚑 尝试备用地址设置 OriginBaseUrl...");
|
|
420
|
+
if (this.tenant === "t1sport")
|
|
421
|
+
this.backupAddress = t1BackGateWay;
|
|
422
|
+
const backupRaw = await this.fetchTxtFile(this.backupAddress);
|
|
423
|
+
if (backupRaw) {
|
|
424
|
+
const backupList = JSON.parse(AesDecrypt(backupRaw));
|
|
425
|
+
this.backupAddressList = backupList || [];
|
|
426
|
+
if (tenantDictList.length > 1) {
|
|
427
|
+
this.OriginBaseUrl = filterSmartLines(tenantDictList, this.backupAddressList);
|
|
428
|
+
if (this.OriginBaseUrl.length > 0)
|
|
429
|
+
originBaseUrlRetrieved = true;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this.OriginBaseUrl = this.backupAddressList;
|
|
433
|
+
originBaseUrlRetrieved = true;
|
|
434
|
+
}
|
|
435
|
+
console.info("✅ 使用备用地址设置 OriginBaseUrl");
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
console.info("⚠️ 备用地址获取失败");
|
|
422
440
|
}
|
|
423
441
|
}
|
|
424
|
-
|
|
425
|
-
|
|
442
|
+
// 如果所有方式都失败了,至少保留 defaultBaseUrl
|
|
443
|
+
if (!originBaseUrlRetrieved) {
|
|
444
|
+
this.OriginBaseUrl = [this.defaultBaseUrl];
|
|
445
|
+
console.info("📋 使用 defaultBaseUrl 设置 OriginBaseUrl(兜底方案)");
|
|
426
446
|
}
|
|
427
|
-
}
|
|
428
|
-
// 如果所有方式都失败了,至少保留 defaultBaseUrl
|
|
429
|
-
if (!originBaseUrlRetrieved) {
|
|
430
|
-
this.OriginBaseUrl = [this.defaultBaseUrl];
|
|
431
|
-
console.info("📋 使用 defaultBaseUrl 设置 OriginBaseUrl(兜底方案)");
|
|
432
|
-
}
|
|
447
|
+
})(); // 立即执行,但不等待
|
|
433
448
|
return this.domainBaseUrl;
|
|
434
449
|
}
|
|
435
450
|
else {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.4.
|
|
1
|
+
export declare const VERSION = "1.4.49";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.4.
|
|
1
|
+
export const VERSION = "1.4.49";
|