hifun-tools 1.3.25 → 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.
package/dist/init/getResource.js
CHANGED
|
@@ -7,7 +7,10 @@ export function getResource(path) {
|
|
|
7
7
|
const isWebpack = typeof __webpack_require__ === "function" ||
|
|
8
8
|
(typeof require !== "undefined" &&
|
|
9
9
|
typeof require.context === "function");
|
|
10
|
-
if (
|
|
10
|
+
if (process.env.__rspack__) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
else if (isVite) {
|
|
11
14
|
// ---------------- VITE ----------------
|
|
12
15
|
const modules = import.meta.glob([
|
|
13
16
|
"/config/**/*.json",
|
|
@@ -28,7 +31,7 @@ export function getResource(path) {
|
|
|
28
31
|
const [, mod] = match;
|
|
29
32
|
return mod;
|
|
30
33
|
}
|
|
31
|
-
if (isWebpack) {
|
|
34
|
+
else if (isWebpack) {
|
|
32
35
|
// ---------------- WEBPACK ----------------
|
|
33
36
|
const ctx = require.context("/config", true, /\.(json|png|jpg|jpeg|svg|webp)$/);
|
|
34
37
|
const files = ctx.keys();
|
package/dist/init/index.d.ts
CHANGED
|
@@ -27,10 +27,12 @@ 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;
|
package/dist/init/index.js
CHANGED
|
@@ -89,15 +89,19 @@ 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
|
-
console.info(`🏢 严格加载租户成功: ${this.tenant}
|
|
104
|
+
console.info(`🏢 严格加载租户成功: ${this.tenant}`);
|
|
101
105
|
return this.tenant;
|
|
102
106
|
}
|
|
103
107
|
catch (error) {
|
|
@@ -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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function viteLoadSync(path: string): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// viteResource.ts
|
|
2
|
+
export function viteLoadSync(path) {
|
|
3
|
+
const modules = import.meta.glob([
|
|
4
|
+
"/config/**/*.json",
|
|
5
|
+
"/config/**/*.png",
|
|
6
|
+
"/config/**/*.jpg",
|
|
7
|
+
"/config/**/*.jpeg",
|
|
8
|
+
"/config/**/*.svg",
|
|
9
|
+
"/config/**/*.webp",
|
|
10
|
+
], { eager: true, import: "default" });
|
|
11
|
+
const match = Object.entries(modules).find(([key]) => key.endsWith(path));
|
|
12
|
+
return match ? match[1] : null;
|
|
13
|
+
}
|