hifun-tools 1.4.50 → 1.4.54

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.
@@ -3,45 +3,50 @@
3
3
  * @param path - 相对路径,如 "tenant/config.json" 或 "tenant/logo.png"
4
4
  */
5
5
  export function getResource(path) {
6
- const isVite = typeof import.meta !== "undefined" && !!import.meta.env;
7
- const isWebpack = typeof __webpack_require__ === "function" ||
8
- (typeof require !== "undefined" &&
9
- typeof require.context === "function");
10
- if (process.env.__rspack__) {
11
- return;
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
- const [, mod] = match;
32
- return mod;
33
- }
34
- else if (isWebpack) {
35
- // ---------------- WEBPACK ----------------
36
- const ctx = require.context("/config", true, /\.(json|png|jpg|jpeg|svg|webp)$/);
37
- const files = ctx.keys();
38
- const match = files.find((key) => key.endsWith(path));
39
- if (!match) {
40
- console.warn(`[getResource] 未找到文件: ${path}`);
41
- return null;
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
- return ctx(match);
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
  }
@@ -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
  }
@@ -203,9 +207,6 @@ class InitCls {
203
207
  console.info("🏠 匹配默认租户 t1sport");
204
208
  return { tenant: "t1sport" };
205
209
  }
206
- else {
207
- return { tenant: "t1sport" };
208
- }
209
210
  throw new Error("无法获取有效的租户信息");
210
211
  }
211
212
  getHostUrl() {
@@ -258,7 +259,7 @@ class InitCls {
258
259
  return true;
259
260
  }
260
261
  catch (err) {
261
- loadingText("正在为您检测最优线路,请稍等...");
262
+ loadingText("We are detecting the best route for you, please wait...");
262
263
  log(`${label}:请求失败 ❌`);
263
264
  return false;
264
265
  }
@@ -289,8 +290,9 @@ class InitCls {
289
290
  Cache("ErrorDomainUrl", uniq([...this.ErrorDomainUrl, nowLineGroup]));
290
291
  closeLoadingText();
291
292
  rewardMsg({
292
- title: "提示",
293
- text: "优选线路超时,刷新页面以重置" + (nowLineGroup ? "" : "..."),
293
+ title: "prompt",
294
+ text: "Preferred route timed out, refresh the page to reset." +
295
+ (nowLineGroup ? "" : "..."),
294
296
  onSubmit() {
295
297
  location.reload();
296
298
  },
@@ -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
- const fullUrl = new URL(endpoint, baseUrl).toString();
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.49";
1
+ export declare const VERSION = "1.4.53";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.4.49";
1
+ export const VERSION = "1.4.53";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hifun-tools",
3
- "version": "1.4.50",
3
+ "version": "1.4.54",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",