hifun-tools 1.4.50 → 1.4.51
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 +43 -38
- package/dist/init/index.js +4 -0
- package/dist/request/index.js +7 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/init/getResource.js
CHANGED
|
@@ -3,45 +3,50 @@
|
|
|
3
3
|
* @param path - 相对路径,如 "tenant/config.json" 或 "tenant/logo.png"
|
|
4
4
|
*/
|
|
5
5
|
export function getResource(path) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
typeof require
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
else if (isVite && import.meta?.glob) {
|
|
14
|
-
// ---------------- VITE ----------------
|
|
15
|
-
const modules = import.meta?.glob([
|
|
16
|
-
"/config/**/*.json",
|
|
17
|
-
"/config/**/*.png",
|
|
18
|
-
"/config/**/*.jpg",
|
|
19
|
-
"/config/**/*.jpeg",
|
|
20
|
-
"/config/**/*.svg",
|
|
21
|
-
"/config/**/*.webp",
|
|
22
|
-
], {
|
|
23
|
-
eager: true,
|
|
24
|
-
import: "default",
|
|
25
|
-
});
|
|
26
|
-
const match = Object.entries(modules).find(([key]) => key.endsWith(path));
|
|
27
|
-
if (!match) {
|
|
28
|
-
console.warn(`[getResource] 未找到文件: ${path}`);
|
|
29
|
-
return null;
|
|
6
|
+
try {
|
|
7
|
+
const isVite = typeof import.meta !== "undefined" && !!import.meta.env;
|
|
8
|
+
const isWebpack = typeof __webpack_require__ === "function" ||
|
|
9
|
+
(typeof require !== "undefined" &&
|
|
10
|
+
typeof require.context === "function");
|
|
11
|
+
if (process.env.__rspack__) {
|
|
12
|
+
return;
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
else if (isVite && import.meta?.glob) {
|
|
15
|
+
// ---------------- VITE ----------------
|
|
16
|
+
const modules = import.meta?.glob([
|
|
17
|
+
"/config/**/*.json",
|
|
18
|
+
"/config/**/*.png",
|
|
19
|
+
"/config/**/*.jpg",
|
|
20
|
+
"/config/**/*.jpeg",
|
|
21
|
+
"/config/**/*.svg",
|
|
22
|
+
"/config/**/*.webp",
|
|
23
|
+
], {
|
|
24
|
+
eager: true,
|
|
25
|
+
import: "default",
|
|
26
|
+
});
|
|
27
|
+
const match = Object.entries(modules).find(([key]) => key.endsWith(path));
|
|
28
|
+
if (!match) {
|
|
29
|
+
console.warn(`[getResource] 未找到文件: ${path}`);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const [, mod] = match;
|
|
33
|
+
return mod;
|
|
42
34
|
}
|
|
43
|
-
|
|
35
|
+
else if (isWebpack) {
|
|
36
|
+
// ---------------- WEBPACK ----------------
|
|
37
|
+
const ctx = require.context("/config", true, /\.(json|png|jpg|jpeg|svg|webp)$/);
|
|
38
|
+
const files = ctx.keys();
|
|
39
|
+
const match = files.find((key) => key.endsWith(path));
|
|
40
|
+
if (!match) {
|
|
41
|
+
console.warn(`[getResource] 未找到文件: ${path}`);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return ctx(match);
|
|
45
|
+
}
|
|
46
|
+
console.error("[getResource] 不支持的构建环境(需要 Vite 或 Webpack)");
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return null;
|
|
44
51
|
}
|
|
45
|
-
console.error("[getResource] 不支持的构建环境(需要 Vite 或 Webpack)");
|
|
46
|
-
return null;
|
|
47
52
|
}
|
package/dist/init/index.js
CHANGED
|
@@ -59,6 +59,10 @@ class InitCls {
|
|
|
59
59
|
// ✨ 将 lineAddressData 传递给加载方法
|
|
60
60
|
results.push(await this._loadGatewayConfig(retry, lineAddressData));
|
|
61
61
|
}
|
|
62
|
+
else if (defaultBaseUrl) {
|
|
63
|
+
this.domainBaseUrl = defaultBaseUrl;
|
|
64
|
+
results.push(this.domainBaseUrl);
|
|
65
|
+
}
|
|
62
66
|
console.info("✅ 所有初始化完成:", results);
|
|
63
67
|
return results;
|
|
64
68
|
}
|
package/dist/request/index.js
CHANGED
|
@@ -160,7 +160,13 @@ export async function HttpServer(endpoint, params = {}, method = "GET", options
|
|
|
160
160
|
// 生成 UDID / 签名 / baseUrl
|
|
161
161
|
const udid = await generateUdid();
|
|
162
162
|
const baseUrl = HF.getBaseUrl();
|
|
163
|
-
|
|
163
|
+
let fullUrl;
|
|
164
|
+
try {
|
|
165
|
+
fullUrl = new URL(endpoint, baseUrl).toString();
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
fullUrl = baseUrl + endpoint;
|
|
169
|
+
}
|
|
164
170
|
const timestamp = Date.now();
|
|
165
171
|
const lang = getParams("lang") || "YN";
|
|
166
172
|
// 组装公共字段(注意:不强制覆盖用户 bodyParams)
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.4.
|
|
1
|
+
export declare const VERSION = "1.4.50";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.4.
|
|
1
|
+
export const VERSION = "1.4.50";
|