fastman3-dfyjapp-request 1.1.0 → 1.1.3

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
@@ -51,6 +51,23 @@
51
51
 
52
52
  1. 解决章鱼app为传递vtDeviceId,导致token长时间未用失效的bug
53
53
 
54
+ ### v 1.0.12 - 2022.05.27
55
+
56
+ 1. 将内部 getVersion 函数调用一律通过 fastman3-common-helper 库内函数来实现,去除了本地自己实现的 getVersion
57
+
54
58
  ### v 1.1.0 - 2022.06.05
55
59
 
56
60
  1. 支持统一部署方案
61
+
62
+ ### v 1.1.1 - 2022.06.06
63
+
64
+ 1. restful接口支持POST请求
65
+
66
+ ### v 1.1.2 - 2022.06.27
67
+
68
+ 1. restful 接口 token 不需要缓存,解决登录态失效 机构户 登录页面不正常提示问题
69
+
70
+ ### v 1.1.3 - 2022.06.27
71
+
72
+ 1. 1.1.2版本变更 添加注释
73
+
@@ -54,8 +54,13 @@ var endProductInterceptor = function endProductInterceptor(chain) {
54
54
  var isServerSessionExpired = code >= 3000 && code <= 3019 || code === 3030 || code === 10026 || code === 5200;
55
55
 
56
56
  if (code === 0) {
57
- // 本地存储或覆盖token
58
- storeToken(tempToken);
57
+ // restful 接口 token 不需要缓存,解决登录态失效 机构户 登录页面不正常提示问题
58
+ if (RESTFUL_PATH_BY_FASTMAN3) {// 暂不处理
59
+ } else {
60
+ // 本地存储或覆盖token
61
+ storeToken(tempToken);
62
+ }
63
+
59
64
  return __assign({
60
65
  header: header
61
66
  }, data);
@@ -42,6 +42,9 @@ var securityInterceptor = function securityInterceptor(chain) {
42
42
  if (RESTFUL_PATH_BY_FASTMAN3) {
43
43
  if (method == "GET") {
44
44
  requestParams.data = null;
45
+ } else {
46
+ // restful 接口post类型,重新组装 入参data
47
+ requestParams.data = JSON.parse(requestParams.data).payload;
45
48
  }
46
49
  } else {
47
50
  requestParams.data = JSON.stringify(e);
@@ -22,8 +22,9 @@ var __assign = this && this.__assign || function () {
22
22
 
23
23
 
24
24
  import { AppAuthorize } from "fastman3-dfyjapp-jsbridge";
25
- import { getVersion, guid } from "../utils";
25
+ import { guid } from "../utils";
26
26
  import { isFromApp, isFromWeiXin, isFromIos, isFromAndroid } from "fastman3-common-helper/es/OS.h5";
27
+ import { getVersion } from "fastman3-common-helper/es/version.web";
27
28
  import { setStorageSync, getStorageSync } from "fastman3-dfyjapp-syncstorage";
28
29
  import { DEVICE_ID_KEY, TOKEN_KEY } from "../constants";
29
30
 
@@ -49,7 +50,7 @@ var transformInterceptor = function transformInterceptor(chain) {
49
50
  var body = {
50
51
  header: {
51
52
  appId: process.env.APP_ID,
52
- ver: getVersion() || "1.0",
53
+ ver: getVersion() || "1.0.0",
53
54
  // @ts-ignore
54
55
  channel: process.env.CHANNEL(_system, process.env.APP_TYPE) || "1",
55
56
  funcNo: FUNCNO_POWER_BY_FASTMAN3,
package/es/request.js CHANGED
@@ -8,7 +8,7 @@ import { addInterceptor, request } from "@tarojs/taro"; // import interceptors f
8
8
 
9
9
  import { endProductInterceptor, transformInterceptor, logInterceptor, securityInterceptor, httpStatusInterceptor, timeoutInterceptor } from "./interceptors";
10
10
  import { isFromApp } from "fastman3-common-helper";
11
- import { storeToken, storeDeviceId, createRestfulGetPath, exceptionCodeOrInfoHandle } from "./utils";
11
+ import { storeToken, storeDeviceId, createRestfulGetPath, createRestfulGetPathNew, exceptionCodeOrInfoHandle } from "./utils";
12
12
  import { AppAuthorize } from "fastman3-dfyjapp-jsbridge";
13
13
 
14
14
  var fetch =
@@ -139,7 +139,7 @@ function () {
139
139
 
140
140
  fetch.prototype.getRest = function (restfulPath, data) {
141
141
  var params = {
142
- RESTFUL_PATH_BY_FASTMAN3: createRestfulGetPath(restfulPath, data)
142
+ RESTFUL_PATH_BY_FASTMAN3: createRestfulGetPathNew(restfulPath, data)
143
143
  };
144
144
  return this.baseOptions(params, "GET");
145
145
  };
package/es/utils.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * 获取APP版本号
3
- */
4
- export declare const getVersion: () => any;
5
1
  /**
6
2
  * rc4Key
7
3
  */
@@ -23,6 +19,13 @@ export declare const storeDeviceId: (deviceId: string) => void;
23
19
  * @returns
24
20
  */
25
21
  export declare const createRestfulGetPath: (path: string, param: any) => any;
22
+ /**
23
+ * 拼接path,组合成一个完整的restful-get请求路径 新版本
24
+ * @param path 路径path /xxx/xx
25
+ * @param param 参数 {a:1,...}
26
+ * @returns
27
+ */
28
+ export declare var createRestfulGetPathNew: (path: any, param: any) => string;
26
29
  /**
27
30
  * 统一接口异常 code info 处理 (中台新版 restful请求 使用)
28
31
  * @param code 1xxx 3xxx
package/es/utils.js CHANGED
@@ -4,22 +4,8 @@
4
4
  * @Company: orientsec.com.cn
5
5
  * @Description: 工具包,计划移入 packages 中统一管理,每一个迭代升版一次
6
6
  */
7
- import Taro from "@tarojs/taro";
8
7
  import { setStorageSync, getStorageSync } from "fastman3-dfyjapp-syncstorage";
9
8
  import { TOKEN_KEY, DEVICE_ID_KEY } from "./constants";
10
- /**
11
- * 获取APP版本号
12
- */
13
-
14
- export var getVersion = function getVersion() {
15
- var groups = Taro.getEnv() !== Taro.ENV_TYPE.WEB || navigator.userAgent.toLowerCase().match(/DFYJ\/([\d.]+)/i);
16
-
17
- if (!groups) {
18
- return undefined;
19
- } else {
20
- return groups[1];
21
- }
22
- };
23
9
  /**
24
10
  * rc4Key
25
11
  */
@@ -73,6 +59,24 @@ export var createRestfulGetPath = function createRestfulGetPath(path, param) {
73
59
  pathLink = path + "?" + (pathLink === null || pathLink === void 0 ? void 0 : pathLink.substr(1));
74
60
  return pathLink.replace(" ", "");
75
61
  };
62
+ /**
63
+ * 拼接path,组合成一个完整的restful-get请求路径 新版本
64
+ * @param path 路径path /xxx/xx
65
+ * @param param 参数 {a:1,...}
66
+ * @returns
67
+ */
68
+
69
+ export var createRestfulGetPathNew = function createRestfulGetPath(path, param) {
70
+ var pathLink = "";
71
+
72
+ for (var k in param) {
73
+ pathLink += k + "=" + param[k] + "&";
74
+ }
75
+
76
+ pathLink = pathLink.substring(0, pathLink.length - 1);
77
+ pathLink = path + "?" + pathLink;
78
+ return pathLink.replace(" ", "");
79
+ };
76
80
  /**
77
81
  * 统一接口异常 code info 处理 (中台新版 restful请求 使用)
78
82
  * @param code 1xxx 3xxx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastman3-dfyjapp-request",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "description": "a network request for dfyj app",
5
5
  "main": "es/request.js",
6
6
  "scripts": {