autobots-commonlib 1.3.2 → 1.3.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.
@@ -4,9 +4,7 @@
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="">
8
- <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
- </list>
7
+ <list default="true" id="30c1af58-4d10-4799-8434-f7c14eade97a" name="Default Changelist" comment="" />
10
8
  <option name="SHOW_DIALOG" value="false" />
11
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
12
10
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -314,7 +312,9 @@
314
312
  <workItem from="1711957837006" duration="34498000" />
315
313
  <workItem from="1712496026818" duration="14011000" />
316
314
  <workItem from="1712919421559" duration="73000" />
317
- <workItem from="1713170876054" duration="7231000" />
315
+ <workItem from="1713170876054" duration="10998000" />
316
+ <workItem from="1715841212364" duration="699000" />
317
+ <workItem from="1716272524681" duration="1971000" />
318
318
  </task>
319
319
  <task id="LOCAL-00001" summary="1、增加新组件NewNavbar;&#10;2、修改jump方法,增加一个参数;">
320
320
  <created>1561551696357</created>
@@ -491,7 +491,15 @@
491
491
  <option name="project" value="LOCAL" />
492
492
  <updated>1713235627988</updated>
493
493
  </task>
494
- <option name="localTasksCounter" value="24" />
494
+ <task id="LOCAL-00024" summary="更新版本号到1.3.3">
495
+ <option name="closed" value="true" />
496
+ <created>1716277032014</created>
497
+ <option name="number" value="00024" />
498
+ <option name="presentableId" value="LOCAL-00024" />
499
+ <option name="project" value="LOCAL" />
500
+ <updated>1716277032014</updated>
501
+ </task>
502
+ <option name="localTasksCounter" value="25" />
495
503
  <servers />
496
504
  </component>
497
505
  <component name="TimeTrackingManager">
@@ -612,7 +620,8 @@
612
620
  <MESSAGE value="js端的网络访问demo方法提交,更新版本号" />
613
621
  <MESSAGE value="修改主软件网络库的js桥接代码,增加fetch支持缓存接口数据" />
614
622
  <MESSAGE value="修改主软件网络库的js桥接代码,兼容js的fetch缓存方法" />
615
- <option name="LAST_COMMIT_MESSAGE" value="修改主软件网络库的js桥接代码,兼容js的fetch缓存方法" />
623
+ <MESSAGE value="更新版本号到1.3.3" />
624
+ <option name="LAST_COMMIT_MESSAGE" value="更新版本号到1.3.3" />
616
625
  </component>
617
626
  <component name="editorHistoryManager">
618
627
  <entry file="file://$PROJECT_DIR$/window.js">
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  autobots commonlib
2
+
3
+ "1.3.3"
4
+ 支持android下fetch接口json数组数据并兼容旧版本
5
+
2
6
  "1.3.2"
3
7
  兼容js的fetch缓存方法修改异常情况
4
8
 
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autobots-commonlib",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
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;