hifun-tools 1.3.26 → 1.3.28
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 +6 -4
- package/dist/init/index.js +19 -8
- package/package.json +1 -1
package/dist/init/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filterSmartLines, isDomainMatch, matchBrowser, TenantDict, toStandardUrl } from "./utils";
|
|
1
|
+
import { filterSmartLines, getOptimalDecodedString, isDomainMatch, matchBrowser, TenantDict, toStandardUrl } from "./utils";
|
|
2
2
|
import { AesDecrypt, AesEncrypt } from "./ende";
|
|
3
3
|
type TenantConfig = {
|
|
4
4
|
PUBLIC_TITLE: string;
|
|
@@ -27,14 +27,16 @@ declare class InitCls {
|
|
|
27
27
|
private getTenantInfoStrictSync;
|
|
28
28
|
/** 严格初始化(必须在应用启动时调用) */
|
|
29
29
|
private initialize;
|
|
30
|
-
InitConfig({ fileType, defaultBaseUrl, localPath, }: {
|
|
31
|
-
fileType
|
|
30
|
+
InitConfig({ fileType, defaultBaseUrl, localPath, appDomain, appTenant, }: {
|
|
31
|
+
fileType?: string[];
|
|
32
32
|
defaultBaseUrl?: string;
|
|
33
33
|
localPath?: string;
|
|
34
|
+
appDomain?: string;
|
|
35
|
+
appTenant?: string;
|
|
34
36
|
}): Promise<any[]>;
|
|
35
37
|
private LoadGatewayConfig;
|
|
36
38
|
AesEncrypt: typeof AesEncrypt;
|
|
37
39
|
AesDecrypt: typeof AesDecrypt;
|
|
38
40
|
}
|
|
39
41
|
declare const HF: InitCls;
|
|
40
|
-
export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, };
|
|
42
|
+
export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, getOptimalDecodedString, };
|
package/dist/init/index.js
CHANGED
|
@@ -89,13 +89,17 @@ class InitCls {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
/** 严格初始化(必须在应用启动时调用) */
|
|
92
|
-
async initialize() {
|
|
92
|
+
async initialize(tenant) {
|
|
93
93
|
if (this.initialized)
|
|
94
94
|
return this.tenant;
|
|
95
95
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (tenant)
|
|
97
|
+
this.tenant = tenant;
|
|
98
|
+
else {
|
|
99
|
+
const tenantInfo = await this.getTenantInfoStrictSync();
|
|
100
|
+
this.tenant = tenantInfo.tenant;
|
|
101
|
+
}
|
|
102
|
+
this.tenantConfig = getResource(`${this.tenant}/config.json`);
|
|
99
103
|
this.initialized = true;
|
|
100
104
|
console.info(`🏢 严格加载租户成功: ${this.tenant}`);
|
|
101
105
|
return this.tenant;
|
|
@@ -105,7 +109,14 @@ class InitCls {
|
|
|
105
109
|
throw error;
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
|
-
async InitConfig({ fileType, defaultBaseUrl, localPath, }) {
|
|
112
|
+
async InitConfig({ fileType, defaultBaseUrl, localPath, appDomain, appTenant, }) {
|
|
113
|
+
if (appDomain && appTenant) {
|
|
114
|
+
this.initialize(appTenant);
|
|
115
|
+
this.domainBaseUrl = appDomain;
|
|
116
|
+
const results = [this.tenant, this.domainBaseUrl];
|
|
117
|
+
console.log("所有初始化完成:", results);
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
109
120
|
if (defaultBaseUrl) {
|
|
110
121
|
this.defaultBaseUrl = defaultBaseUrl;
|
|
111
122
|
}
|
|
@@ -114,12 +125,12 @@ class InitCls {
|
|
|
114
125
|
}
|
|
115
126
|
console.log("加载类型:", fileType);
|
|
116
127
|
const results = [];
|
|
117
|
-
if (fileType
|
|
128
|
+
if (fileType?.includes("lineDict")) {
|
|
118
129
|
console.log("初始化 lineDict...");
|
|
119
130
|
const res1 = await this.initialize();
|
|
120
131
|
results.push(res1);
|
|
121
132
|
}
|
|
122
|
-
if (fileType
|
|
133
|
+
if (fileType?.includes("lineAddress")) {
|
|
123
134
|
console.log("初始化 lineAddress...");
|
|
124
135
|
const res2 = await this.LoadGatewayConfig();
|
|
125
136
|
results.push(res2);
|
|
@@ -174,4 +185,4 @@ class InitCls {
|
|
|
174
185
|
AesDecrypt = AesDecrypt;
|
|
175
186
|
}
|
|
176
187
|
const HF = new InitCls();
|
|
177
|
-
export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, };
|
|
188
|
+
export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, getOptimalDecodedString, };
|