hifun-tools 1.4.28 → 1.4.35
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.d.ts +1 -1
- package/dist/init/index.js +41 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/init/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class InitCls {
|
|
|
30
30
|
appGateway?: string;
|
|
31
31
|
backupAddress?: string[];
|
|
32
32
|
retry?: boolean;
|
|
33
|
+
lineDictData?: string;
|
|
33
34
|
}): Promise<(string | null)[]>;
|
|
34
35
|
getOnlyBackup(): boolean;
|
|
35
36
|
setOnlyBackup(value: boolean): void;
|
|
@@ -49,7 +50,6 @@ declare class InitCls {
|
|
|
49
50
|
getImgPath(imgName: string): string;
|
|
50
51
|
/** 严格初始化租户信息 */
|
|
51
52
|
private _initializeTenant;
|
|
52
|
-
/** 严格同步获取租户信息 */
|
|
53
53
|
private _getTenantInfoStrictSync;
|
|
54
54
|
/** 匹配默认租户 */
|
|
55
55
|
private _matchDefaultTenant;
|
package/dist/init/index.js
CHANGED
|
@@ -27,7 +27,8 @@ class InitCls {
|
|
|
27
27
|
tenantDictList = [];
|
|
28
28
|
/** 初始化配置入口 */
|
|
29
29
|
async InitConfig(options) {
|
|
30
|
-
const { fileType, defaultBaseUrl, localPath, appLine, appTenant, appGateway = "", backupAddress, retry,
|
|
30
|
+
const { fileType, defaultBaseUrl, localPath, appLine, appTenant, appGateway = "", backupAddress, retry, lineDictData, // 提取这个参数
|
|
31
|
+
} = options;
|
|
31
32
|
if (defaultBaseUrl)
|
|
32
33
|
this.defaultBaseUrl = defaultBaseUrl;
|
|
33
34
|
if (localPath)
|
|
@@ -44,7 +45,7 @@ class InitCls {
|
|
|
44
45
|
const results = [];
|
|
45
46
|
if (fileType?.includes("lineDict")) {
|
|
46
47
|
console.info("初始化 lineDict...");
|
|
47
|
-
results.push(await this._initializeTenant());
|
|
48
|
+
results.push(await this._initializeTenant(lineDictData)); // 将参数传递给初始化方法
|
|
48
49
|
}
|
|
49
50
|
if (fileType?.includes("lineAddress")) {
|
|
50
51
|
console.info("初始化 lineAddress...");
|
|
@@ -102,11 +103,11 @@ class InitCls {
|
|
|
102
103
|
return getResource(`${this.tenant}/image/${imgName}`);
|
|
103
104
|
}
|
|
104
105
|
/** 严格初始化租户信息 */
|
|
105
|
-
async _initializeTenant() {
|
|
106
|
+
async _initializeTenant(lineDictData) {
|
|
106
107
|
if (this.initialized)
|
|
107
108
|
return this.tenant;
|
|
108
109
|
try {
|
|
109
|
-
const tenantInfo = await this._getTenantInfoStrictSync();
|
|
110
|
+
const tenantInfo = await this._getTenantInfoStrictSync(lineDictData);
|
|
110
111
|
this.tenant = tenantInfo.tenant;
|
|
111
112
|
this.tenantConfig = getResource(`${this.tenant}/config.json`);
|
|
112
113
|
this.initialized = true;
|
|
@@ -118,8 +119,39 @@ class InitCls {
|
|
|
118
119
|
throw err;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
async _getTenantInfoStrictSync(lineDictData) {
|
|
123
|
+
// 尝试使用传入的lineDictData进行匹配
|
|
124
|
+
if (lineDictData) {
|
|
125
|
+
try {
|
|
126
|
+
const data = JSON.parse(AesDecrypt(lineDictData));
|
|
127
|
+
const host = location.host;
|
|
128
|
+
if (this.getIsApp()) {
|
|
129
|
+
this.tenantDict = {
|
|
130
|
+
browserCheck: [],
|
|
131
|
+
line: host,
|
|
132
|
+
lineGroup: this.appLine,
|
|
133
|
+
tenant: this.appTenant,
|
|
134
|
+
};
|
|
135
|
+
this.tenantDictList = [...data, this.tenantDict];
|
|
136
|
+
console.info("🏠 匹配 App 租户:", this.tenantDict);
|
|
137
|
+
return { tenant: this.appTenant };
|
|
138
|
+
}
|
|
139
|
+
const matched = data.find((item) => isDomainMatch([item.line], host));
|
|
140
|
+
if (matched) {
|
|
141
|
+
this.tenantDictList = [...data];
|
|
142
|
+
this.tenantDict = matched;
|
|
143
|
+
console.info("🏠 匹配租户:", matched.tenant);
|
|
144
|
+
return { tenant: matched.tenant };
|
|
145
|
+
}
|
|
146
|
+
// 如果传入的数据没有匹配到,继续执行下面的原始逻辑
|
|
147
|
+
console.info("⚠️ 传入的 lineDictData 未匹配到租户,尝试原始逻辑");
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
console.warn("⚠️ 解析传入的 lineDictData 失败:", err);
|
|
151
|
+
// 如果传入的数据解析失败,也继续执行下面的原始逻辑
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// 如果没有传入数据或传入数据匹配失败,执行原始逻辑
|
|
123
155
|
try {
|
|
124
156
|
const rawText = await this._fetchLineDict();
|
|
125
157
|
const data = JSON.parse(AesDecrypt(rawText));
|
|
@@ -319,10 +351,10 @@ class InitCls {
|
|
|
319
351
|
const tenantDictList = this.getTenantDictList().filter((a) => !this.ErrorDomainUrl.includes(a.lineGroup));
|
|
320
352
|
const currentLineGroup = this.getTenantDict()?.lineGroup;
|
|
321
353
|
let baseUrlList = filterSmartLines(tenantDictList, originBaseUrl, this.ErrorDomainUrl?.length === 0 ? currentLineGroup : "");
|
|
322
|
-
console.log("++++++++++");
|
|
323
354
|
/** 3️⃣ 主线路测速 */
|
|
324
355
|
try {
|
|
325
356
|
await setBaseUrl(baseUrlList);
|
|
357
|
+
localStorage.removeItem("retryHttpTime");
|
|
326
358
|
console.info("✅ 成功加载生产环境配置:", this.domainBaseUrl);
|
|
327
359
|
}
|
|
328
360
|
catch {
|
|
@@ -331,6 +363,7 @@ class InitCls {
|
|
|
331
363
|
if (this.ErrorDomainUrl?.length == 0) {
|
|
332
364
|
const fallbackList = filterSmartLines(tenantDictList.filter((a) => a.lineGroup !== currentLineGroup), originBaseUrl);
|
|
333
365
|
await setBaseUrl(fallbackList);
|
|
366
|
+
localStorage.removeItem("retryHttpTime");
|
|
334
367
|
}
|
|
335
368
|
else {
|
|
336
369
|
await loadBackupAddress();
|
|
@@ -342,6 +375,7 @@ class InitCls {
|
|
|
342
375
|
}
|
|
343
376
|
catch {
|
|
344
377
|
this.domainBaseUrl = toStandardUrl(originBaseUrl[0]);
|
|
378
|
+
localStorage.removeItem("retryHttpTime");
|
|
345
379
|
console.warn("⚠️ 备选测速失败,使用备用配置:", this.domainBaseUrl);
|
|
346
380
|
this.onlyBackUp = true;
|
|
347
381
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.4.
|
|
1
|
+
export declare const VERSION = "1.4.34";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.4.
|
|
1
|
+
export const VERSION = "1.4.34";
|