hifun-tools 1.4.10 → 1.4.12

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.
@@ -8,7 +8,9 @@ declare class InitCls {
8
8
  private appTenant;
9
9
  private defaultBaseUrl;
10
10
  private domainBaseUrl;
11
+ private ErrorDomainUrl;
11
12
  private initialized;
13
+ isRefreshNow: boolean;
12
14
  private localPath;
13
15
  private tenant;
14
16
  private tenantConfig;
@@ -56,5 +58,6 @@ export type TenantConfig = {
56
58
  SITE_URL: string;
57
59
  USER_TENANT: string;
58
60
  DB_TITLE: string;
61
+ THEME: string;
59
62
  };
60
63
  export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, getOptimalDecodedString, };
@@ -3,6 +3,8 @@ import { getResource } from "./getResource";
3
3
  import { isDomainMatch, filterSmartLines, getOptimalDecodedString, matchBrowser, toStandardUrl, difArr, } from "./utils";
4
4
  import { AesDecrypt, AesEncrypt } from "./ende";
5
5
  import { rewardMsg } from "../msg";
6
+ import { Cache } from "../utils";
7
+ import { difference } from "lodash-es";
6
8
  class InitCls {
7
9
  AesDecrypt = AesDecrypt;
8
10
  AesEncrypt = AesEncrypt;
@@ -11,7 +13,9 @@ class InitCls {
11
13
  appTenant = "";
12
14
  defaultBaseUrl = "";
13
15
  domainBaseUrl = "";
16
+ ErrorDomainUrl = Cache("ErrorDomainUrl") || [];
14
17
  initialized = false;
18
+ isRefreshNow = false;
15
19
  localPath = "";
16
20
  tenant = "";
17
21
  tenantConfig = null;
@@ -154,6 +158,8 @@ class InitCls {
154
158
  await getOptimalDecodedString([this.getBaseUrl()]);
155
159
  }
156
160
  catch (error) {
161
+ this.isRefreshNow = true;
162
+ Cache("ErrorDomainUrl", [...this.ErrorDomainUrl, this.domainBaseUrl]);
157
163
  rewardMsg({
158
164
  title: "提示",
159
165
  text: "网络环境异常,刷新页面以重置",
@@ -180,7 +186,14 @@ class InitCls {
180
186
  try {
181
187
  const response = await fetch(`/lineAddress.txt?t=${Date.now()}`);
182
188
  const configText = await response.text();
183
- const OriginBaseUrl = JSON.parse(AesDecrypt(configText));
189
+ const resArray = JSON.parse(AesDecrypt(configText));
190
+ let OriginBaseUrl = [];
191
+ if (this.ErrorDomainUrl.length < resArray.length) {
192
+ OriginBaseUrl = difference(resArray, this.ErrorDomainUrl);
193
+ }
194
+ else {
195
+ OriginBaseUrl = resArray;
196
+ }
184
197
  const dictList = this.getTenantDictList();
185
198
  const lineGroup = this.getTenantDict()?.lineGroup;
186
199
  let baseUrl = filterSmartLines(dictList, OriginBaseUrl, lineGroup);
@@ -1,4 +1,5 @@
1
1
  export declare function Local(name: string, value?: any, time?: number): any;
2
+ export declare function Cache(name: string, value?: any, time?: number): any;
2
3
  /**
3
4
  * 获取链接参数
4
5
  * @param name
@@ -32,6 +32,40 @@ export function Local(name, value, time) {
32
32
  }
33
33
  }
34
34
  }
35
+ export function Cache(name, value, time) {
36
+ const date = Number(new Date().getTime() / 1000);
37
+ if (value === null) {
38
+ sessionStorage.removeItem(name);
39
+ }
40
+ else if (value !== undefined) {
41
+ if (time) {
42
+ sessionStorage.setItem(name, JSON.stringify({ time: date + time, value }));
43
+ }
44
+ else {
45
+ sessionStorage.setItem(name, JSON.stringify({ value }));
46
+ }
47
+ }
48
+ else {
49
+ const v = sessionStorage.getItem(name);
50
+ if (v) {
51
+ if (JSON.parse(v).time) {
52
+ if (JSON.parse(v).time - date > 0) {
53
+ return JSON.parse(v).value;
54
+ }
55
+ else {
56
+ sessionStorage.removeItem(name);
57
+ return undefined;
58
+ }
59
+ }
60
+ else {
61
+ return JSON.parse(v).value;
62
+ }
63
+ }
64
+ else {
65
+ return undefined;
66
+ }
67
+ }
68
+ }
35
69
  /**
36
70
  * 获取链接参数
37
71
  * @param name
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.4.9";
1
+ export declare const VERSION = "1.4.11";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.4.9";
1
+ export const VERSION = "1.4.11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hifun-tools",
3
- "version": "1.4.10",
3
+ "version": "1.4.12",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,9 +20,11 @@
20
20
  "@babel/core": "^7.28.5",
21
21
  "@babel/preset-typescript": "^7.28.5",
22
22
  "@types/jest": "^30.0.0",
23
+ "@types/lodash-es": "^4.17.12",
23
24
  "jest": "^30.2.0",
24
25
  "jest-environment-jsdom": "^30.2.0",
25
26
  "jscodeshift": "^17.3.0",
27
+ "lodash-es": "^4.17.22",
26
28
  "prettier": "^3.6.2",
27
29
  "ts-jest": "^29.4.5",
28
30
  "typescript": "^5.6.3"