hifun-tools 1.3.26 → 1.3.27

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.
@@ -27,10 +27,12 @@ declare class InitCls {
27
27
  private getTenantInfoStrictSync;
28
28
  /** 严格初始化(必须在应用启动时调用) */
29
29
  private initialize;
30
- InitConfig({ fileType, defaultBaseUrl, localPath, }: {
31
- fileType: string[];
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;
@@ -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
- const tenantInfo = await this.getTenantInfoStrictSync();
97
- this.tenant = tenantInfo.tenant;
98
- this.tenantConfig = getResource(`${tenantInfo.tenant}/config.json`);
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.includes("lineDict")) {
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.includes("lineAddress")) {
133
+ if (fileType?.includes("lineAddress")) {
123
134
  console.log("初始化 lineAddress...");
124
135
  const res2 = await this.LoadGatewayConfig();
125
136
  results.push(res2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hifun-tools",
3
- "version": "1.3.26",
3
+ "version": "1.3.27",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",