fastman3-dfyjapp-request 1.1.17 → 1.2.0

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/README.md CHANGED
@@ -126,4 +126,12 @@
126
126
 
127
127
  ### v 1.1.17 - 2025.03.26
128
128
 
129
- 1. gateway url增加func参数
129
+ 1. gateway url增加func参数
130
+
131
+ ### v 1.1.18 - 2025.04.02
132
+
133
+ 1. 支持简繁体转换
134
+
135
+ ### v 1.2.0 - 2026.02.13
136
+
137
+ 1. token改为内存变量机制,废弃LocalStorage机制
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Created by dfzq on 2017/3/24.
3
+ */
4
+ export default function chineseInterceptor(chain: any): any;
@@ -0,0 +1,32 @@
1
+ /*
2
+ * @Author: jiangxin
3
+ * @Date: 2025-04-01 09:09:36
4
+ * @Company: orientsec.com.cn
5
+ * @Description:
6
+ */
7
+ /**
8
+ * Created by dfzq on 2017/3/24.
9
+ */
10
+ // const noTransformList = ["IF016200", "IF016208", "IF016043", "IF016027"];
11
+ export default function chineseInterceptor(chain) {
12
+ // @ts-ignore
13
+ var Chinese = window === null || window === void 0 ? void 0 : window.Chinese;
14
+ // 没有打包进来的 繁简转换脚本则不转换
15
+ if (!Chinese) return chain.proceed(chain.requestParams);
16
+ var requestParams = chain.requestParams;
17
+ // 转 简体
18
+ requestParams.data = Chinese.t2s(requestParams.data);
19
+ var p = chain.proceed(requestParams);
20
+ var res = p.then(function (res) {
21
+ // 转繁体
22
+ if (res.payload) {
23
+ res.payload = Chinese.walk(res.payload, "s2t");
24
+ }
25
+ if (res.data) {
26
+ res.data = Chinese.walk(res.data, "s2t");
27
+ }
28
+ return res;
29
+ });
30
+ if (typeof p.abort === "function") res.abort = p.abort;
31
+ return res;
32
+ }
@@ -1,3 +1,12 @@
1
+ /*
2
+ * @Author: shenzhiwei
3
+ * @Date: 2021-03-28 14:19:34
4
+ * @Company: orientsec.com.cn
5
+ * @Description: UI交互上的最终处理 chain
6
+ */
7
+ // import { removeStorageSync } from "fastman3-dfyjapp-syncstorage";
8
+ // import { TOKEN_KEY } from "../constants";
9
+ // import { storeToken } from "../utils";
1
10
  var __assign = this && this.__assign || function () {
2
11
  __assign = Object.assign || function (t) {
3
12
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -8,15 +17,6 @@ var __assign = this && this.__assign || function () {
8
17
  };
9
18
  return __assign.apply(this, arguments);
10
19
  };
11
- /*
12
- * @Author: shenzhiwei
13
- * @Date: 2021-03-28 14:19:34
14
- * @Company: orientsec.com.cn
15
- * @Description: UI交互上的最终处理 chain
16
- */
17
- import { removeStorageSync } from "fastman3-dfyjapp-syncstorage";
18
- import { TOKEN_KEY } from "../constants";
19
- import { storeToken } from "../utils";
20
20
  var endProductInterceptor = function endProductInterceptor(chain) {
21
21
  var requestParams = chain.requestParams;
22
22
  if (requestParams === null || requestParams === void 0 ? void 0 : requestParams.isNative) return chain.proceed(requestParams);
@@ -30,7 +30,7 @@ var endProductInterceptor = function endProductInterceptor(chain) {
30
30
  var code = payload.code,
31
31
  info = payload.info,
32
32
  data = payload.data;
33
- var tempToken = header.token;
33
+ // const tempToken = header.token;
34
34
  // token 不暴露给上层
35
35
  header.token = "***";
36
36
  // restful 接口==>自定义字段RESTFUL_PATH_BY_FASTMAN3存在时重新赋值赋值
@@ -47,8 +47,8 @@ var endProductInterceptor = function endProductInterceptor(chain) {
47
47
  if (RESTFUL_PATH_BY_FASTMAN3) {
48
48
  // 暂不处理
49
49
  } else {
50
- // 本地存储或覆盖token
51
- storeToken(tempToken);
50
+ // // 本地存储或覆盖token
51
+ // storeToken(tempToken);
52
52
  }
53
53
  return __assign({
54
54
  header: header
@@ -59,7 +59,7 @@ var endProductInterceptor = function endProductInterceptor(chain) {
59
59
  info: "\u670D\u52A1\u5668\u53D1\u751F\u9519\u8BEF(".concat(code, ")")
60
60
  });
61
61
  } else if (isServerSessionExpired) {
62
- removeStorageSync(TOKEN_KEY);
62
+ // removeStorageSync(TOKEN_KEY);
63
63
  return Promise.reject({
64
64
  code: 3000,
65
65
  info: "\u672A\u767B\u5F55\u6216\u767B\u5F55\u6001\u5DF2\u5931\u6548(".concat(code, ")")
@@ -4,9 +4,11 @@ import httpStatusInterceptor from "./httpStatusInterceptor";
4
4
  import endProductInterceptor from "./endProductInterceptor";
5
5
  import logInterceptor from "./logInterceptor";
6
6
  import { timeoutInterceptor } from "./timeoutInterceptor";
7
+ import chineseInterceptor from "./chineseInterceptor";
7
8
  /**
8
9
  * 遵循洋葱模型规则:先进后出,请开发者注意数组中拦截器的注册顺序
9
10
  */
10
11
  export { endProductInterceptor, transformInterceptor, // 先 request 后 response
11
12
  logInterceptor, securityInterceptor, // 后 reuqest 先 response
12
- httpStatusInterceptor, timeoutInterceptor, };
13
+ httpStatusInterceptor, timeoutInterceptor, // 注:超时拦截器必须放在所有拦截器的最后加入
14
+ chineseInterceptor, };
@@ -10,6 +10,7 @@ import httpStatusInterceptor from "./httpStatusInterceptor";
10
10
  import endProductInterceptor from "./endProductInterceptor";
11
11
  import logInterceptor from "./logInterceptor";
12
12
  import { timeoutInterceptor } from "./timeoutInterceptor";
13
+ import chineseInterceptor from "./chineseInterceptor";
13
14
  /**
14
15
  * 遵循洋葱模型规则:先进后出,请开发者注意数组中拦截器的注册顺序
15
16
  */
@@ -17,5 +18,7 @@ export { endProductInterceptor, transformInterceptor,
17
18
  // 先 request 后 response
18
19
  logInterceptor, securityInterceptor,
19
20
  // 后 reuqest 先 response
20
- httpStatusInterceptor, timeoutInterceptor // 注:超时拦截器必须放在所有拦截器的最后加入
21
+ httpStatusInterceptor, timeoutInterceptor,
22
+ // 注:超时拦截器必须放在所有拦截器的最后加入
23
+ chineseInterceptor // 注:超时拦截器必须放在所有拦截器的最后加入
21
24
  };
@@ -19,7 +19,7 @@ import { guid } from "../utils";
19
19
  import { isFromApp, isFromWeiXin, isFromWhichPlatform } from "fastman3-common-helper/es/OS.h5";
20
20
  import { getVersion } from "fastman3-common-helper/es/version.web";
21
21
  import { setStorageSync, getStorageSync } from "fastman3-dfyjapp-syncstorage";
22
- import { DEVICE_ID_KEY, TOKEN_KEY } from "../constants";
22
+ import { DEVICE_ID_KEY } from "../constants";
23
23
  var _system;
24
24
  var transformInterceptor = function transformInterceptor(chain) {
25
25
  var requestParams = chain.requestParams;
@@ -56,7 +56,9 @@ var transformInterceptor = function transformInterceptor(chain) {
56
56
  body.header["auth"] = AppAuthorize.newAuthSign;
57
57
  }
58
58
  // 微信授权机制 //
59
- var tokenStorage = getStorageSync(TOKEN_KEY);
59
+ // 2026-2-13: 改用内存变量形式来恢复token
60
+ // var tokenStorage = getStorageSync(TOKEN_KEY);
61
+ var tokenStorage = AppAuthorize.token;
60
62
  if (!!tokenStorage) {
61
63
  body.header["token"] = tokenStorage;
62
64
  }
package/es/request.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { addInterceptor, request } from "@tarojs/taro";
8
8
  // import interceptors from "./interceptors";
9
- import { endProductInterceptor, transformInterceptor, logInterceptor, securityInterceptor, httpStatusInterceptor, timeoutInterceptor } from "./interceptors";
9
+ import { endProductInterceptor, transformInterceptor, logInterceptor, securityInterceptor, httpStatusInterceptor, timeoutInterceptor, chineseInterceptor } from "./interceptors";
10
10
  import { isFromApp } from "fastman3-common-helper";
11
11
  import { storeToken, storeDeviceId, createRestfulGetPath, createRestfulGetPathNew, exceptionCodeOrInfoHandle } from "./utils";
12
12
  import { AppAuthorize } from "fastman3-dfyjapp-jsbridge";
@@ -22,6 +22,7 @@ var fetch = /** @class */function () {
22
22
  if (!this.init) {
23
23
  addInterceptor(endProductInterceptor);
24
24
  addInterceptor(transformInterceptor);
25
+ addInterceptor(chineseInterceptor);
25
26
  addInterceptor(logInterceptor);
26
27
  if (process.env.APP_ENV !== "mock") {
27
28
  addInterceptor(securityInterceptor);
@@ -173,6 +174,7 @@ var fetch = /** @class */function () {
173
174
  addInterceptor(endProductInterceptor);
174
175
  addInterceptor(transformInterceptor);
175
176
  addInterceptor(logInterceptor);
177
+ addInterceptor(chineseInterceptor);
176
178
  if (process.env.APP_ENV !== "mock") {
177
179
  addInterceptor(securityInterceptor);
178
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastman3-dfyjapp-request",
3
- "version": "1.1.17",
3
+ "version": "1.2.0",
4
4
  "description": "a network request for dfyj app",
5
5
  "prepublishOnly": "npm run build",
6
6
  "main": "es/request.js",