fastman3-dfyjapp-request 1.1.4 → 1.1.7

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/es/request.js +26 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -75,3 +75,15 @@
75
75
  ### v 1.1.4 - 2022.07.14
76
76
 
77
77
  1. 统一 channel 处理逻辑
78
+
79
+ ### v 1.1.5 - 2022.07.22
80
+
81
+ 1. 设置credentials 具体类型,restful 接口get post请求option内不传该字段
82
+
83
+ ### v 1.1.6 - 2022.07.26
84
+
85
+ 1. 修改请求失败的错误文案
86
+
87
+ ### v 1.1.7 - 2022.07.29
88
+
89
+ 1. restful接口 /chart/v1/finance/fund 生产环境变更资源域
package/es/request.js CHANGED
@@ -51,7 +51,14 @@ function () {
51
51
  if (process.env.APP_ENV === "mock" && !RESTFUL_PATH_BY_FASTMAN3) {
52
52
  url = process.env.GATEWAY_URL + "/" + FUNCNO_POWER_BY_FASTMAN3;
53
53
  } else if (RESTFUL_PATH_BY_FASTMAN3 && process.env.APP_ENV != "mock") {
54
- url = process.env.GATEWAY_RESTFUL_URL + RESTFUL_PATH_BY_FASTMAN3;
54
+ console.log("当前restful路径 RESTFUL_PATH_BY_FASTMAN3 :", RESTFUL_PATH_BY_FASTMAN3);
55
+
56
+ if (RESTFUL_PATH_BY_FASTMAN3.indexOf("/chart/v1/finance/fund") != -1 && process.env.APP_ENV == "prod") {
57
+ console.log("当前restful路径 RESTFUL_PATH_BY_FASTMAN3 ==>:", RESTFUL_PATH_BY_FASTMAN3);
58
+ url = "https://dfyjres-v2.dfzq.com.cn" + RESTFUL_PATH_BY_FASTMAN3;
59
+ } else {
60
+ url = process.env.GATEWAY_RESTFUL_URL + RESTFUL_PATH_BY_FASTMAN3;
61
+ }
55
62
  } else if (RESTFUL_PATH_BY_FASTMAN3 && process.env.APP_ENV === "mock") {
56
63
  url = process.env.GATEWAY_URL + RESTFUL_PATH_BY_FASTMAN3;
57
64
  } else {
@@ -65,13 +72,28 @@ function () {
65
72
  header: {
66
73
  "Content-Type": "application/json"
67
74
  },
68
- // 是否携带 cookie
69
- credentials: !isFromApp() ? "omit" : /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/.test(location.hostname) || location.hostname === "localhost" ? "omit" : "include",
75
+ // 是否携带 cookie 注释不用
76
+ // credentials: !isFromApp()
77
+ // ? "omit"
78
+ // : /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/.test(location.hostname) || location.hostname === "localhost"
79
+ // ? "omit"
80
+ // : "include",
70
81
  FUNCNO_POWER_BY_FASTMAN3: FUNCNO_POWER_BY_FASTMAN3,
71
82
  RESTFUL_PATH_BY_FASTMAN3: RESTFUL_PATH_BY_FASTMAN3,
72
83
  mode: "cors",
73
84
  timeout: process.env.TIME_OUT || 15000
74
85
  };
86
+ /**
87
+ * 设置credentials 具体类型,restful接口 get post请求不传该字段,否则正常设置
88
+ */
89
+
90
+ if (!RESTFUL_PATH_BY_FASTMAN3) {
91
+ // 是否携带 cookie
92
+ //@ts-ignore
93
+ option.credentials = !isFromApp() ? "omit" : /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/.test(location.hostname) || location.hostname === "localhost" ? "omit" : "include";
94
+ }
95
+
96
+ console.log("request --- options =>", option);
75
97
  return new Promise(function (resolve, reject) {
76
98
  // @ts-ignore
77
99
  request(option).then(function (res) {
@@ -81,7 +103,7 @@ function () {
81
103
  if (err.message === "Failed to fetch") {
82
104
  reject({
83
105
  code: -1,
84
- info: "请求失败"
106
+ info: "当前网络不可用,请检查您的网络设置"
85
107
  });
86
108
  } // 网络请求超时
87
109
  else if (err.message === "网络链接超时,请稍后再试!") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastman3-dfyjapp-request",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "description": "a network request for dfyj app",
5
5
  "main": "es/request.js",
6
6
  "scripts": {