hifun-tools 1.4.9 → 1.4.10

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.
@@ -149,7 +149,7 @@ export async function getOptimalDecodedString(arr, options) {
149
149
  controller.abort();
150
150
  failedUrls.push(url);
151
151
  }, 3000);
152
- fetch(`${toStandardUrl(url)}/health?t=${Date.now()}`, {
152
+ fetch(`${toStandardUrl(url)}/actuator-security/health?t=${Date.now()}`, {
153
153
  signal: controller.signal,
154
154
  })
155
155
  .then(() => {
@@ -2,6 +2,7 @@
2
2
  import md5 from "md5";
3
3
  import { Local, getParams, isMobile } from "../utils/index";
4
4
  import { HF } from "../init";
5
+ import { VERSION } from "../version";
5
6
  /**
6
7
  * 错误类型区分
7
8
  */
@@ -53,20 +54,6 @@ const globalConfig = {
53
54
  errorInterceptors: [],
54
55
  debug: false,
55
56
  };
56
- /** 导出用于设置全局配置的 API(在 app 启动处调用) */
57
- export function setHttpClientConfig(cfg) {
58
- Object.assign(globalConfig, cfg);
59
- }
60
- /** 导出注册拦截器方便使用 */
61
- export function useRequestInterceptor(fn) {
62
- globalConfig.requestInterceptors.push(fn);
63
- }
64
- export function useResponseInterceptor(fn) {
65
- globalConfig.responseInterceptors.push(fn);
66
- }
67
- export function useErrorInterceptor(fn) {
68
- globalConfig.errorInterceptors.push(fn);
69
- }
70
57
  /** 缓存(简单实现:sessionStorage,key = url+params md5;value 存储 { ts, ttl, data }) */
71
58
  function cacheKeyFor(url, params) {
72
59
  try {
@@ -105,6 +92,20 @@ function getCache(key) {
105
92
  return null;
106
93
  }
107
94
  }
95
+ /** 导出用于设置全局配置的 API(在 app 启动处调用) */
96
+ export function setHttpClientConfig(cfg) {
97
+ Object.assign(globalConfig, cfg);
98
+ }
99
+ /** 导出注册拦截器方便使用 */
100
+ export function useRequestInterceptor(fn) {
101
+ globalConfig.requestInterceptors.push(fn);
102
+ }
103
+ export function useResponseInterceptor(fn) {
104
+ globalConfig.responseInterceptors.push(fn);
105
+ }
106
+ export function useErrorInterceptor(fn) {
107
+ globalConfig.errorInterceptors.push(fn);
108
+ }
108
109
  /** 生成或获取 UDID */
109
110
  export async function generateUdid() {
110
111
  const udidFromUrl = getParams("udid");
@@ -166,12 +167,8 @@ export async function HttpServer(endpoint, params = {}, method = "GET", options
166
167
  const baseFields = {
167
168
  language: lang,
168
169
  timestamp,
169
- currentUserAppVersion: "2.0.5",
170
- channel: "",
171
- version: "1.0.0",
170
+ version: VERSION,
172
171
  os: isMobile() ? "5" : "6",
173
- platForm: isMobile() ? "h5" : "pc",
174
- deviceType: "1",
175
172
  udid,
176
173
  };
177
174
  const sign = globalConfig.signFn
@@ -0,0 +1 @@
1
+ export declare const VERSION = "1.4.9";
@@ -0,0 +1 @@
1
+ export const VERSION = "1.4.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hifun-tools",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "access": "public"
9
9
  },
10
10
  "scripts": {
11
- "build": "tsc",
11
+ "build": "node scripts/generate-version.js && tsc",
12
12
  "pub": "npm run build && npm version patch && npm publish --access public",
13
13
  "test": "jest",
14
14
  "test:watch": "jest --watch"