autobots-commonlib 1.3.2 → 1.3.4

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.
@@ -4,8 +4,11 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="30c1af58-4d10-4799-8434-f7c14eade97a" name="Default Changelist" comment="">
7
+ <list default="true" id="30c1af58-4d10-4799-8434-f7c14eade97a" name="Default Changelist" comment="更新版本号到1.3.3">
8
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/lib/QCRNetworkModule.js" beforeDir="false" afterPath="$PROJECT_DIR$/lib/QCRNetworkModule.js" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
9
12
  </list>
10
13
  <option name="SHOW_DIALOG" value="false" />
11
14
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -314,7 +317,9 @@
314
317
  <workItem from="1711957837006" duration="34498000" />
315
318
  <workItem from="1712496026818" duration="14011000" />
316
319
  <workItem from="1712919421559" duration="73000" />
317
- <workItem from="1713170876054" duration="7231000" />
320
+ <workItem from="1713170876054" duration="10998000" />
321
+ <workItem from="1715841212364" duration="699000" />
322
+ <workItem from="1716272524681" duration="8375000" />
318
323
  </task>
319
324
  <task id="LOCAL-00001" summary="1、增加新组件NewNavbar;&#10;2、修改jump方法,增加一个参数;">
320
325
  <created>1561551696357</created>
@@ -491,7 +496,15 @@
491
496
  <option name="project" value="LOCAL" />
492
497
  <updated>1713235627988</updated>
493
498
  </task>
494
- <option name="localTasksCounter" value="24" />
499
+ <task id="LOCAL-00024" summary="更新版本号到1.3.3">
500
+ <option name="closed" value="true" />
501
+ <created>1716277032014</created>
502
+ <option name="number" value="00024" />
503
+ <option name="presentableId" value="LOCAL-00024" />
504
+ <option name="project" value="LOCAL" />
505
+ <updated>1716277032014</updated>
506
+ </task>
507
+ <option name="localTasksCounter" value="25" />
495
508
  <servers />
496
509
  </component>
497
510
  <component name="TimeTrackingManager">
@@ -612,7 +625,8 @@
612
625
  <MESSAGE value="js端的网络访问demo方法提交,更新版本号" />
613
626
  <MESSAGE value="修改主软件网络库的js桥接代码,增加fetch支持缓存接口数据" />
614
627
  <MESSAGE value="修改主软件网络库的js桥接代码,兼容js的fetch缓存方法" />
615
- <option name="LAST_COMMIT_MESSAGE" value="修改主软件网络库的js桥接代码,兼容js的fetch缓存方法" />
628
+ <MESSAGE value="更新版本号到1.3.3" />
629
+ <option name="LAST_COMMIT_MESSAGE" value="更新版本号到1.3.3" />
616
630
  </component>
617
631
  <component name="editorHistoryManager">
618
632
  <entry file="file://$PROJECT_DIR$/window.js">
package/README.md CHANGED
@@ -1,4 +1,11 @@
1
1
  autobots commonlib
2
+
3
+ "1.3.4"
4
+ 处理asyncFetch和asyncPostForm传递的参数为null的场景
5
+
6
+ "1.3.3"
7
+ 支持android下fetch接口json数组数据并兼容旧版本
8
+
2
9
  "1.3.2"
3
10
  兼容js的fetch缓存方法修改异常情况
4
11
 
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
  import { NativeModules, Platform } from 'react-native';
3
+ import Utils from "../util/utils";
3
4
 
4
5
  var QCRRNNetworkModule = NativeModules.QCRRNNetworkModule;
5
6
 
6
7
  var NetworkModule = {
7
8
  fetch(url: String, config: Object, params: Object, cacheFunction: Function) {
8
9
  return new Promise(function (resolve, reject) {
9
- if (QCRRNNetworkModule) {
10
+ if (QCRRNNetworkModule && !Utils.isChooseOldNetApi(params)) {
10
11
  asyncFetch(url, config, params, cacheFunction, resolve, reject);
11
12
  } else {
12
13
  asyncFromFetch(url, config, params, resolve, reject);
@@ -135,7 +136,7 @@ async function asyncFetch(url: String, config: Object, params: Object, cacheFunc
135
136
  const stringifiedParams = {};
136
137
  if (params) {
137
138
  Object.keys(params).forEach(key => {
138
- if (typeof params[key] === 'undefined') {
139
+ if (typeof params[key] === 'undefined' || params[key] === null) {
139
140
  stringifiedParams[key] = ""; // 将undefined值设为""
140
141
  } else {
141
142
  stringifiedParams[key] = String(params[key]);
@@ -240,7 +241,7 @@ async function asyncPostForm(url: String, headers: Object, form: Object, resolve
240
241
  const stringifiedForms = {};
241
242
  if (form) {
242
243
  Object.keys(form).forEach(key => {
243
- if (typeof form[key] === 'undefined') {
244
+ if (typeof form[key] === 'undefined' || form[key] === null) {
244
245
  stringifiedForms[key] = ""; // 将undefined值设为""
245
246
  } else {
246
247
  stringifiedForms[key] = String(form[key]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autobots-commonlib",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "autobots common lib",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "react-native-deprecated-custom-components": "^0.1.2",
23
23
  "react-native-root-siblings": "1.2.1",
24
24
  "react-native-root-toast": "3.0.2",
25
- "react-native-storage": "^0.2.3"
25
+ "react-native-storage": "^0.2.3",
26
+ "react-native-device-info": "^1.1.0"
26
27
  }
27
28
  }
package/util/utils.js ADDED
@@ -0,0 +1,50 @@
1
+ import DeviceInfo from "react-native-device-info";
2
+ import { Platform } from 'react-native';
3
+
4
+ /**
5
+ * 是否使用旧版网络接口
6
+ * @param params
7
+ * @returns {boolean}
8
+ */
9
+ function isChooseOldNetApi(params) {
10
+ if (Platform.OS === 'ios' || params == null || !Array.isArray(params)) {
11
+ return false;
12
+ } else {
13
+ let currentVersion = DeviceInfo.getVersion();
14
+ let versioncompare = compareVersion(currentVersion, '5.8.1');
15
+ return versioncompare < 1;
16
+ }
17
+ }
18
+
19
+ /**
20
+ * 比较版本号
21
+ * @param {string} version1
22
+ * @param {string} version2
23
+ * @return {number} 大于返回1,小于返回-1,等于返回0
24
+ */
25
+ function compareVersion(version1, version2) {
26
+ let v1 = version1.split('.');
27
+ let v2 = version2.split('.');
28
+
29
+ let maxLen = Math.max(v1.length, v2.length);
30
+ for (let i = 0; i < maxLen; i++) {
31
+ // eslint-disable-next-line no-undefined
32
+ v1[i] = v1[i] === undefined ? 0 : Number(v1[i]);
33
+ // eslint-disable-next-line no-undefined
34
+ v2[i] = v2[i] === undefined ? 0 : Number(v2[i]);
35
+ }
36
+
37
+ for (let i = 0; i < maxLen; i++) {
38
+ if (v1[i] < v2[i]) return -1;
39
+ if (v1[i] > v2[i]) return 1;
40
+ }
41
+
42
+ return 0;
43
+ }
44
+
45
+ const Utils = {
46
+ isChooseOldNetApi,
47
+ compareVersion
48
+ };
49
+
50
+ export default Utils;