@mpxjs/api-proxy 2.9.65 → 2.9.67

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 (32) hide show
  1. package/package.json +3 -11
  2. package/src/platform/api/animation/animation.react.js +281 -0
  3. package/src/platform/api/animation/index.ios.js +5 -0
  4. package/src/platform/api/create-intersection-observer/index.ali.js +3 -0
  5. package/src/platform/api/create-intersection-observer/index.ios.js +9 -0
  6. package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +239 -0
  7. package/src/platform/api/request/index.web.js +8 -5
  8. package/src/platform/api/route/index.ios.js +1 -16
  9. package/src/platform/api/system/rnSystem.js +4 -45
  10. package/src/platform/api/system/rnWindowInfo.js +42 -0
  11. package/src/platform/index.js +2 -2
  12. package/src/platform/api/action-sheet/index.android.js +0 -1
  13. package/src/platform/api/app/index.android.js +0 -1
  14. package/src/platform/api/base/index.android.js +0 -1
  15. package/src/platform/api/clipboard-data/index.android.js +0 -1
  16. package/src/platform/api/create-selector-query/index.android.js +0 -1
  17. package/src/platform/api/device/network/index.android.js +0 -1
  18. package/src/platform/api/keyboard/index.android.js +0 -1
  19. package/src/platform/api/location/index.android.js +0 -1
  20. package/src/platform/api/make-phone-call/index.android.js +0 -1
  21. package/src/platform/api/modal/index.android.js +0 -1
  22. package/src/platform/api/next-tick/index.android.js +0 -1
  23. package/src/platform/api/request/index.android.js +0 -1
  24. package/src/platform/api/route/index.android.js +0 -1
  25. package/src/platform/api/screen-brightness/index.android.js +0 -1
  26. package/src/platform/api/set-navigation-bar/index.android.js +0 -1
  27. package/src/platform/api/socket/index.android.js +0 -1
  28. package/src/platform/api/storage/index.android.js +0 -1
  29. package/src/platform/api/system/index.android.js +0 -1
  30. package/src/platform/api/toast/index.android.js +0 -1
  31. package/src/platform/api/vibrate/index.android.js +0 -1
  32. package/src/platform/api/window/index.android.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.65",
3
+ "version": "2.9.67",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -37,15 +37,13 @@
37
37
  },
38
38
  "homepage": "https://github.com/didi/mpx#readme",
39
39
  "dependencies": {
40
- "@mpxjs/utils": "^2.9.65",
40
+ "@mpxjs/utils": "^2.9.67",
41
41
  "axios": "^1.7.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@ant-design/react-native": "^5.1.3",
45
45
  "@react-native-async-storage/async-storage": "^1.23.1",
46
46
  "@react-native-community/netinfo": "^11.2.1",
47
- "expo-brightness": "~11.8.0",
48
- "expo-clipboard": "~6.0.3",
49
47
  "react-native-device-info": "^10.13.2",
50
48
  "react-native-get-location": "^4.0.1",
51
49
  "react-native-haptic-feedback": "^2.3.3",
@@ -55,9 +53,6 @@
55
53
  "@react-native-async-storage/async-storage": {
56
54
  "optional": true
57
55
  },
58
- "expo-clipboard": {
59
- "optional": true
60
- },
61
56
  "@react-native-community/netinfo": {
62
57
  "optional": true
63
58
  },
@@ -73,12 +68,9 @@
73
68
  "@ant-design/react-native": {
74
69
  "optional": true
75
70
  },
76
- "expo-brightness": {
77
- "optional": true
78
- },
79
71
  "react-native-haptic-feedback": {
80
72
  "optional": true
81
73
  }
82
74
  },
83
- "gitHead": "24efa90e90b4d42c285ca61739cb9e4d0696976c"
75
+ "gitHead": "b23d3850c16543c5998811b8d1d8e6ee7988c0f8"
84
76
  }
@@ -0,0 +1,281 @@
1
+ class Animation {
2
+ constructor (
3
+ {
4
+ duration = 400,
5
+ delay = 0,
6
+ timingFunction = 'linear',
7
+ transformOrigin = '50% 50% 0'
8
+ } = {}
9
+ ) {
10
+ // 默认值
11
+ this._setDefault(duration, delay, timingFunction, transformOrigin)
12
+ this.id = 0
13
+ }
14
+
15
+ _transformUnit (...args) {
16
+ return args.map(each => {
17
+ return global.__formatValue(each)
18
+ })
19
+ }
20
+
21
+ _formatTransformOrigin (transformOrigin) {
22
+ const transformOriginArr = transformOrigin.trim().split(/\s+/, 3).map(item => global.__formatValue(item))
23
+ switch (transformOriginArr.length) {
24
+ case 0:
25
+ transformOriginArr.push('50%', '50%', 0)
26
+ break
27
+ case 1:
28
+ transformOriginArr.push('50%', 0)
29
+ break
30
+ case 2:
31
+ transformOriginArr.push(0)
32
+ break
33
+ }
34
+ return transformOriginArr
35
+ }
36
+
37
+ // 设置默认值
38
+ _setDefault (duration, delay, timingFunction, transformOrigin) {
39
+ this.DEFAULT = { duration, delay, timingFunction, transformOrigin }
40
+ }
41
+
42
+ // 属性组合
43
+ rules = new Map()
44
+ // transform 对象
45
+ transform = new Map()
46
+ // 组合动画
47
+ steps = []
48
+
49
+ matrix (a, b, c, d, tx, ty) { // Todo
50
+ console.error('React Native 不支持 matrix 动画')
51
+ // this.transform.set('matrix', [a, b, c, d, tx, ty])
52
+ return this
53
+ }
54
+
55
+ matrix3d (a1, b1, c1, d1,
56
+ a2, b2, c2, d2,
57
+ a3, b3, c3, d3,
58
+ a4, b4, c4, d4
59
+ ) {
60
+ console.error('React Native 不支持 matrix3d 动画')
61
+ // this.transform.set('matrix3d', [ // Todo
62
+ // a1, b1, c1, d1,
63
+ // a2, b2, c2, d2,
64
+ // a3, b3, c3, d3,
65
+ // a4, b4, c4, d4
66
+ // ])
67
+ return this
68
+ }
69
+
70
+ rotate (angle) { // 旋转变换
71
+ this.transform.set('rotate', `${angle}deg`)
72
+ return this
73
+ }
74
+
75
+ rotate3d (x, y, z, angle) {
76
+ if (typeof y !== 'number') {
77
+ this.transform.set('rotate3d', x)
78
+ } else {
79
+ // this.transform.set('rotate3d', [x, y, z, angle])
80
+ this.rotateX(x)
81
+ this.rotateY(y)
82
+ this.rotateZ(z)
83
+ this.rotate(angle)
84
+ }
85
+ return this
86
+ }
87
+
88
+ rotateX (angle) {
89
+ this.transform.set('rotateX', `${angle}deg`)
90
+ return this
91
+ }
92
+
93
+ rotateY (angle) {
94
+ this.transform.set('rotateY', `${angle}deg`)
95
+ return this
96
+ }
97
+
98
+ rotateZ (angle) {
99
+ this.transform.set('rotateZ', `${angle}deg`)
100
+ return this
101
+ }
102
+
103
+ scale (x, y) {
104
+ const scaleY = (typeof y !== 'undefined' && y !== null) ? y : x
105
+ this.scaleX(x)
106
+ this.scaleY(scaleY)
107
+ // this.transform.set('scale', [x, scaleY])
108
+ return this
109
+ }
110
+
111
+ scaleX (scale) {
112
+ this.transform.set('scaleX', scale)
113
+ return this
114
+ }
115
+
116
+ scaleY (scale) {
117
+ this.transform.set('scaleY', scale)
118
+ return this
119
+ }
120
+
121
+ scaleZ (scale) { // Todo Invariant Violation: Invalid transform scaleZ: {"scaleZ":0}
122
+ console.error('React Native 不支持 transform scaleZ')
123
+ // this.transform.set('scaleZ', scale)
124
+ return this
125
+ }
126
+
127
+ scale3d (x, y, z) { // Todo Invariant Violation: Invalid transform scaleZ: {"scaleZ":0}
128
+ console.error('React Native 不支持 transform scaleZ,故不支持 scale3d')
129
+ // this.scaleX(x)
130
+ // this.scaleY(y)
131
+ // this.scaleZ(z)
132
+ return this
133
+ }
134
+
135
+ skew (x, y) {
136
+ // this.transform.set('skew', [x, y])
137
+ this.skewX(x)
138
+ this.skewY(y)
139
+ return this
140
+ }
141
+
142
+ skewX (angle) {
143
+ this.transform.set('skewX', `${angle}deg`)
144
+ return this
145
+ }
146
+
147
+ skewY (angle) {
148
+ this.transform.set('skewY', `${angle}deg`)
149
+ return this
150
+ }
151
+
152
+ translate (x, y) {
153
+ [x, y] = this._transformUnit(x, y)
154
+ // this.transform.set('translate', [x, y])
155
+ this.translateX(x)
156
+ this.translateY(y)
157
+ return this
158
+ }
159
+
160
+ translateX (translate) {
161
+ [translate] = this._transformUnit(translate)
162
+ this.transform.set('translateX', translate)
163
+ return this
164
+ }
165
+
166
+ translateY (translate) {
167
+ [translate] = this._transformUnit(translate)
168
+ this.transform.set('translateY', translate)
169
+ return this
170
+ }
171
+
172
+ translateZ (translate) { // Todo Invariant Violation: Invalid transform translateZ: {"translateZ":0}
173
+ console.error('React Native 不支持 transform translateZ')
174
+ // [translate] = this._transformUnit(translate)
175
+ // this.transform.set('translateZ', translate)
176
+ return this
177
+ }
178
+
179
+ translate3d (x, y, z) { // Todo Invariant Violation: Invalid transform translateZ: {"translateZ":0}
180
+ console.error('React Native 不支持 transform translateZ,故无法支持 translate3d')
181
+ // [x, y, z] = this._transformUnit(x, y, z)
182
+ // // this.transform.set('translate3d', [x, y, z])
183
+ // this.translateX(x)
184
+ // this.translateY(y)
185
+ // this.translateZ(z)
186
+ return this
187
+ }
188
+
189
+ opacity (value) {
190
+ this.rules.set('opacity', value)
191
+ return this
192
+ }
193
+
194
+ backgroundColor (value) {
195
+ this.rules.set('backgroundColor', value)
196
+ return this
197
+ }
198
+
199
+ width (value) {
200
+ [value] = this._transformUnit(value)
201
+ this.rules.set('width', value)
202
+ return this
203
+ }
204
+
205
+ height (value) {
206
+ [value] = this._transformUnit(value)
207
+ this.rules.set('height', value)
208
+ return this
209
+ }
210
+
211
+ top (value) {
212
+ [value] = this._transformUnit(value)
213
+ this.rules.set('top', value)
214
+ return this
215
+ }
216
+
217
+ right (value) {
218
+ [value] = this._transformUnit(value)
219
+ this.rules.set('right', value)
220
+ return this
221
+ }
222
+
223
+ bottom (value) {
224
+ [value] = this._transformUnit(value)
225
+ this.rules.set('bottom', value)
226
+ return this
227
+ }
228
+
229
+ left (value) {
230
+ [value] = this._transformUnit(value)
231
+ this.rules.set('left', value)
232
+ return this
233
+ }
234
+
235
+ // 关键帧载入
236
+ step (arg = {}) {
237
+ const { DEFAULT } = this
238
+ let {
239
+ duration = DEFAULT.duration,
240
+ delay = DEFAULT.delay,
241
+ timingFunction = DEFAULT.timingFunction,
242
+ transformOrigin = DEFAULT.transformOrigin
243
+ } = arg
244
+ if (typeof transformOrigin !== 'string') {
245
+ console.error('Value of transformOrigin only support string type, please check again')
246
+ transformOrigin = DEFAULT.transformOrigin
247
+ }
248
+ this.steps.push({
249
+ animatedOption: {
250
+ duration,
251
+ delay,
252
+ timingFunction,
253
+ transformOrigin: this._formatTransformOrigin(transformOrigin)
254
+ },
255
+ rules: this.rules,
256
+ transform: this.transform
257
+ })
258
+ // 清空 rules 和 transform
259
+ this.rules = new Map()
260
+ this.transform = new Map()
261
+ return this
262
+ }
263
+
264
+ // 数据
265
+ createAnimationData () {
266
+ const steps = this.steps
267
+ this.steps = []
268
+ return steps
269
+ }
270
+
271
+ // 动画数据产出
272
+ export () {
273
+ this.id++
274
+ return {
275
+ id: this.id,
276
+ actions: this.createAnimationData()
277
+ }
278
+ }
279
+ }
280
+
281
+ export default Animation
@@ -0,0 +1,5 @@
1
+ import Animation from './animation.react'
2
+
3
+ export const createAnimation = (option) => {
4
+ return new Animation(option)
5
+ }
@@ -1,6 +1,9 @@
1
1
  import { ENV_OBJ } from '../../../common/js'
2
2
 
3
3
  function createIntersectionObserver (component, options = {}) {
4
+ if (options.observeAll) {
5
+ options.selectAll = options.observeAll
6
+ }
4
7
  return ENV_OBJ.createIntersectionObserver(options)
5
8
  }
6
9
 
@@ -0,0 +1,9 @@
1
+ import IntersectionObserver from './rnIntersectionObserver'
2
+
3
+ function createIntersectionObserver (comp, opt, config) {
4
+ return new IntersectionObserver(comp, opt, config)
5
+ }
6
+
7
+ export {
8
+ createIntersectionObserver
9
+ }
@@ -0,0 +1,239 @@
1
+ import { isArray, isObject, isString, noop } from '@mpxjs/utils'
2
+ import throttle from 'lodash/throttle'
3
+ import { Dimensions } from 'react-native'
4
+ import { getFocusedNavigation } from '../../../common/js'
5
+
6
+ const WindowRefStr = 'window'
7
+ const IgnoreTarget = 'ignore'
8
+ const DefaultMargin = { top: 0, bottom: 0, left: 0, right: 0 }
9
+ let idCount = 0
10
+
11
+ class RNIntersectionObserver {
12
+ constructor (component, options, intersectionCtx) {
13
+ this.id = idCount++
14
+ this.component = component
15
+ this.options = options
16
+ this.thresholds = options.thresholds.sort((a, b) => a - b) || [0]
17
+ this.initialRatio = options.initialRatio || 0
18
+ this.observeAll = options.observeAll || false
19
+
20
+ // 组件上挂载对应的observers,用于在组件销毁的时候进行批量disconnect
21
+ this.component._intersectionObservers = this.component.__intersectionObservers || []
22
+ this.component._intersectionObservers.push(this)
23
+
24
+ this.observerRefs = null
25
+ this.relativeRef = null
26
+ this.margins = DefaultMargin
27
+ this.callback = noop
28
+
29
+ this.throttleMeasure = this.getThrottleMeasure(options.throttleTime || 100)
30
+
31
+ // 记录上一次相交的比例
32
+ this.previousIntersectionRatio = []
33
+
34
+ // 添加实例添加到上下文中,滚动组件可以获取到上下文内的实例从而触发滚动
35
+ if (intersectionCtx && isObject(intersectionCtx)) {
36
+ this.intersectionCtx = intersectionCtx
37
+ this.intersectionCtx[this.id] = this
38
+ }
39
+ return this
40
+ }
41
+
42
+ // 支持传递ref 或者 selector
43
+ relativeTo (selector, margins = {}) {
44
+ let relativeRef
45
+ if (isString(selector)) {
46
+ relativeRef = this.component.__selectRef(selector, 'node')
47
+ }
48
+ if (isObject(selector)) {
49
+ relativeRef = selector.nodeRefs?.[0]
50
+ }
51
+ if (relativeRef) {
52
+ this.relativeRef = relativeRef
53
+ this.margins = Object.assign({}, DefaultMargin, margins)
54
+ } else {
55
+ console.warn(`node ${selector}is not found. The relative node for intersection observer will be ignored`)
56
+ }
57
+ return this
58
+ }
59
+
60
+ relativeToViewport (margins = {}) {
61
+ this.relativeRef = WindowRefStr
62
+ this.margins = Object.assign({}, DefaultMargin, margins)
63
+ return this
64
+ }
65
+
66
+ observe (selector, callback) {
67
+ if (this.observerRefs) {
68
+ console.error('"observe" call can be only called once in IntersectionObserver')
69
+ return
70
+ }
71
+ let targetRef = null
72
+ if (this.observeAll) {
73
+ targetRef = this.component.__selectRef(selector, 'node', true)
74
+ } else {
75
+ targetRef = this.component.__selectRef(selector, 'node')
76
+ }
77
+ if (!targetRef || targetRef.length === 0) {
78
+ console.error('intersection observer target not found')
79
+ return
80
+ }
81
+ this.observerRefs = isArray(targetRef) ? targetRef : [targetRef]
82
+ this.callback = callback
83
+ this._measureTarget(true)
84
+ }
85
+
86
+ _getWindowRect () {
87
+ if (this.windowRect) return this.windowRect
88
+ const navigation = getFocusedNavigation()
89
+ const screen = Dimensions.get('screen')
90
+ const navigationLayout = navigation.layout || {
91
+ x: 0,
92
+ y: 0,
93
+ width: screen.width,
94
+ height: screen.height
95
+ }
96
+
97
+ const windowRect = {
98
+ top: navigationLayout.y + this.margins.top,
99
+ left: navigationLayout.x + this.margins.left,
100
+ right: navigationLayout.width - this.margins.right,
101
+ bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom
102
+ }
103
+
104
+ this.windowRect = windowRect
105
+ return this.windowRect
106
+ }
107
+
108
+ _getReferenceRect (targetRef) {
109
+ const targetRefs = isArray(targetRef) ? targetRef : [targetRef]
110
+ const targetPromiseQueue = []
111
+ targetRefs.forEach((targetRefItem) => {
112
+ if (targetRefItem === WindowRefStr) {
113
+ targetPromiseQueue.push(this._getWindowRect())
114
+ return
115
+ }
116
+ // 当节点前面存在后面移除的时候可能会存在拿不到target的情况,此处直接忽略留一个占位不用做计算即可
117
+ // 测试节点移除之后 targetRefItem.getNodeInstance().nodeRef都存在,只是current不存在了
118
+ if (!targetRefItem || !targetRefItem.getNodeInstance().nodeRef.current) {
119
+ targetPromiseQueue.push(Promise.resolve(IgnoreTarget))
120
+ return
121
+ }
122
+ const target = targetRefItem.getNodeInstance().nodeRef.current
123
+ targetPromiseQueue.push(new Promise((resolve) => {
124
+ target.measureInWindow(
125
+ (x, y, width, height) => {
126
+ const boundingClientRect = {
127
+ left: x,
128
+ top: y,
129
+ right: x + width,
130
+ bottom: y + height,
131
+ width: width,
132
+ height: height
133
+ }
134
+ resolve(boundingClientRect)
135
+ }
136
+ )
137
+ }))
138
+ })
139
+
140
+ if (isArray(targetRef)) {
141
+ return Promise.all(targetPromiseQueue)
142
+ } else {
143
+ return targetPromiseQueue[0]
144
+ }
145
+ }
146
+
147
+ _restrictValueInRange (start = 0, end = 0, value = 0) {
148
+ return Math.min(Math.max(start, value), end)
149
+ }
150
+
151
+ _isInsectedFn (intersectionRatio, previousIntersectionRatio, thresholds) {
152
+ // console.log('nowintersectionRatio, previousIntersectionRatio', [intersectionRatio, previousIntersectionRatio])
153
+ let nowIndex = -1
154
+ let previousIndex = -1
155
+ thresholds.forEach((item, index) => {
156
+ if (intersectionRatio >= item) {
157
+ nowIndex = index
158
+ }
159
+ if (previousIntersectionRatio >= item) {
160
+ previousIndex = index
161
+ }
162
+ })
163
+ return !(nowIndex === previousIndex)
164
+ }
165
+
166
+ // 计算相交区域
167
+ _measureIntersection ({ observeRect, relativeRect, observeIndex, isInit }) {
168
+ const visibleRect = {
169
+ left: this._restrictValueInRange(relativeRect.left, relativeRect.right, observeRect.left),
170
+ top: this._restrictValueInRange(relativeRect.top, relativeRect.bottom, observeRect.top),
171
+ right: this._restrictValueInRange(relativeRect.left, relativeRect.right, observeRect.right),
172
+ bottom: this._restrictValueInRange(relativeRect.top, relativeRect.bottom, observeRect.bottom)
173
+ }
174
+
175
+ const targetArea = (observeRect.bottom - observeRect.top) * (observeRect.right - observeRect.left)
176
+ const visibleArea = (visibleRect.bottom - visibleRect.top) * (visibleRect.right - visibleRect.left)
177
+ const intersectionRatio = targetArea ? visibleArea / targetArea : 0
178
+
179
+ const isInsected = isInit ? intersectionRatio > this.initialRatio : this._isInsectedFn(intersectionRatio, this.previousIntersectionRatio[observeIndex], this.thresholds)
180
+ this.previousIntersectionRatio[observeIndex] = intersectionRatio
181
+
182
+ return {
183
+ intersectionRatio,
184
+ intersectionRect: {
185
+ top: visibleRect.top,
186
+ bottom: relativeRect.bottom,
187
+ left: visibleRect.left,
188
+ right: relativeRect.right
189
+ },
190
+ isInsected
191
+ }
192
+ }
193
+
194
+ getThrottleMeasure (throttleTime) {
195
+ return throttle(() => {
196
+ this._measureTarget()
197
+ }, throttleTime)
198
+ }
199
+
200
+ // 计算节点的rect信息
201
+ _measureTarget (isInit = false) {
202
+ Promise.all([
203
+ this._getReferenceRect(this.observerRefs),
204
+ this._getReferenceRect(this.relativeRef)
205
+ ]).then(([observeRects, relativeRect]) => {
206
+ if (relativeRect === IgnoreTarget) return
207
+ observeRects.forEach((observeRect, index) => {
208
+ if (observeRect === IgnoreTarget) return
209
+ const { intersectionRatio, intersectionRect, isInsected } = this._measureIntersection({
210
+ observeRect,
211
+ observeIndex: index,
212
+ relativeRect,
213
+ isInit
214
+ })
215
+ // 初次调用的
216
+ if (isInsected) {
217
+ this.callback({
218
+ // index: index,
219
+ id: this.observerRefs[index].getNodeInstance().props?.current?.id,
220
+ dataset: this.observerRefs[index].getNodeInstance().props?.current?.dataset || {},
221
+ intersectionRatio: Math.round(intersectionRatio * 100) / 100,
222
+ intersectionRect,
223
+ boundingClientRect: observeRect,
224
+ relativeRect: relativeRect,
225
+ time: Date.now()
226
+ })
227
+ }
228
+ })
229
+ }).catch((e) => {
230
+ console.log('_measureTarget fail', e)
231
+ })
232
+ }
233
+
234
+ disconnect () {
235
+ if (this.intersectionCtx) delete this.intersectionCtx[this.id]
236
+ }
237
+ }
238
+
239
+ export default RNIntersectionObserver
@@ -1,6 +1,7 @@
1
1
  import axios from 'axios'
2
2
  import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
  import RequestTask from './RequestTask'
4
+ import { serialize, buildUrl } from '@mpxjs/utils'
4
5
 
5
6
  function request (options = { url: '' }) {
6
7
  const CancelToken = axios.CancelToken
@@ -8,6 +9,7 @@ function request (options = { url: '' }) {
8
9
  const requestTask = new RequestTask(source.cancel)
9
10
 
10
11
  let {
12
+ url,
11
13
  data = {},
12
14
  method = 'GET',
13
15
  dataType = 'json',
@@ -18,8 +20,11 @@ function request (options = { url: '' }) {
18
20
  fail = null,
19
21
  complete = null
20
22
  } = options
21
-
22
23
  method = method.toUpperCase()
24
+ if (method === 'GET') {
25
+ url = buildUrl(url, data)
26
+ data = {}
27
+ }
23
28
 
24
29
  if (
25
30
  method === 'POST' &&
@@ -27,9 +32,7 @@ function request (options = { url: '' }) {
27
32
  (header['Content-Type'] === 'application/x-www-form-urlencoded' ||
28
33
  header['content-type'] === 'application/x-www-form-urlencoded')
29
34
  ) {
30
- data = Object.keys(data).reduce((pre, curKey) => {
31
- return `${pre}&${encodeURIComponent(curKey)}=${encodeURIComponent(data[curKey])}`
32
- }, '').slice(1)
35
+ data = serialize(data)
33
36
  }
34
37
 
35
38
  /**
@@ -58,7 +61,7 @@ function request (options = { url: '' }) {
58
61
  */
59
62
  const rOptions = Object.assign(options, {
60
63
  method,
61
- url: options.url,
64
+ url,
62
65
  data,
63
66
  headers: header,
64
67
  responseType,
@@ -1,20 +1,5 @@
1
1
  import { successHandle, failHandle } from '../../../common/js'
2
- import { parseQuery } from '@mpxjs/utils'
3
-
4
- function parseUrl (url) {
5
- let path = url
6
- let query = ''
7
- const queryIndex = url.indexOf('?')
8
- if (queryIndex >= 0) {
9
- path = url.slice(0, queryIndex)
10
- query = url.slice(queryIndex)
11
- }
12
- const queryObj = parseQuery(query || '?')
13
- return {
14
- path,
15
- queryObj
16
- }
17
- }
2
+ import { parseUrlQuery as parseUrl } from '@mpxjs/utils'
18
3
 
19
4
  function getBasePath (navigation) {
20
5
  if (navigation) {
@@ -1,48 +1,7 @@
1
1
  import DeviceInfo from 'react-native-device-info'
2
- import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
3
- import { initialWindowMetrics } from 'react-native-safe-area-context'
4
- import { successHandle, failHandle, defineUnsupportedProps, getFocusedNavigation } from '../../../common/js'
5
-
6
- const getWindowInfo = function () {
7
- const dimensionsScreen = Dimensions.get('screen')
8
- const navigation = getFocusedNavigation()
9
- const insets = {
10
- ...initialWindowMetrics?.insets,
11
- ...navigation?.insets
12
- }
13
- let safeArea = {}
14
- let { top = 0, bottom = 0, left = 0, right = 0 } = insets
15
- if (Platform.OS === 'android') {
16
- top = StatusBar.currentHeight || 0
17
- }
18
- const screenHeight = dimensionsScreen.height
19
- const screenWidth = dimensionsScreen.width
20
- const layout = navigation?.layout || {}
21
- const layoutHeight = layout.height || 0
22
- const layoutWidth = layout.width || 0
23
- const windowHeight = layoutHeight || screenHeight
24
- try {
25
- safeArea = {
26
- left,
27
- right: screenWidth - right,
28
- top,
29
- bottom: screenHeight - bottom,
30
- height: screenHeight - top - bottom,
31
- width: screenWidth - left - right
32
- }
33
- } catch (error) {
34
- }
35
- const result = {
36
- pixelRatio: PixelRatio.get(),
37
- windowWidth: layoutWidth || screenWidth,
38
- windowHeight, // 取不到layout的时候有个兜底
39
- screenWidth: screenWidth,
40
- screenHeight: screenHeight,
41
- screenTop: screenHeight - windowHeight,
42
- safeArea
43
- }
44
- return result
45
- }
2
+ import { PixelRatio } from 'react-native'
3
+ import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
4
+ import { getWindowInfo } from './rnWindowInfo'
46
5
 
47
6
  const getSystemInfoSync = function () {
48
7
  const windowInfo = getWindowInfo()
@@ -101,7 +60,7 @@ const getSystemInfo = function (options = {}) {
101
60
 
102
61
  const getDeviceInfo = function () {
103
62
  const deviceInfo = {}
104
- if (Platform.OS === 'android') {
63
+ if (__mpx_mode__ === 'android') {
105
64
  const deviceAbi = DeviceInfo.supported64BitAbisSync() || []
106
65
  deviceInfo.deviceAbi = deviceAbi[0] || null
107
66
  }
@@ -0,0 +1,42 @@
1
+ import { PixelRatio, Dimensions } from 'react-native'
2
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
3
+ import { getFocusedNavigation } from '../../../common/js'
4
+
5
+ const getWindowInfo = function () {
6
+ const dimensionsScreen = Dimensions.get('screen')
7
+ const navigation = getFocusedNavigation()
8
+ const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets)
9
+ let safeArea = {}
10
+ const { top = 0, bottom = 0, left = 0, right = 0 } = insets
11
+ const screenHeight = dimensionsScreen.height
12
+ const screenWidth = dimensionsScreen.width
13
+ const layout = navigation?.layout || {}
14
+ const layoutHeight = layout.height || 0
15
+ const layoutWidth = layout.width || 0
16
+ const windowHeight = layoutHeight || screenHeight
17
+ try {
18
+ safeArea = {
19
+ left,
20
+ right: screenWidth - right,
21
+ top,
22
+ bottom: screenHeight - bottom,
23
+ height: screenHeight - top - bottom,
24
+ width: screenWidth - left - right
25
+ }
26
+ } catch (error) {
27
+ }
28
+ const result = {
29
+ pixelRatio: PixelRatio.get(),
30
+ windowWidth: layoutWidth || screenWidth,
31
+ windowHeight, // 取不到layout的时候有个兜底
32
+ screenWidth: screenWidth,
33
+ screenHeight: screenHeight,
34
+ screenTop: screenHeight - windowHeight,
35
+ safeArea
36
+ }
37
+ return result
38
+ }
39
+
40
+ export {
41
+ getWindowInfo
42
+ }
@@ -26,7 +26,7 @@ export * from './api/canvas'
26
26
  export * from './api/check-session'
27
27
 
28
28
  // setClipboardData, getClipboardData
29
- export * from './api/clipboard-data'
29
+ // export * from './api/clipboard-data'
30
30
 
31
31
  // createIntersectionObserver
32
32
  export * from './api/create-intersection-observer'
@@ -77,7 +77,7 @@ export * from './api/route'
77
77
  export * from './api/scan-code'
78
78
 
79
79
  // setScreenBrightness, getScreenBrightness
80
- export * from './api/screen-brightness'
80
+ // export * from './api/screen-brightness'
81
81
 
82
82
  // setNavigationBarTitle, setNavigationBarColor
83
83
  export * from './api/set-navigation-bar'
@@ -1 +0,0 @@
1
- export * from './rnActionSheet'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './rnClipboard'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnNetwork'
@@ -1 +0,0 @@
1
- export * from './index'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnMakePhone'
@@ -1 +0,0 @@
1
- export * from './rnModal'
@@ -1 +0,0 @@
1
- export * from './index.ali'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnScreenBrightness'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './rnStorage'
@@ -1 +0,0 @@
1
- export * from './rnSystem'
@@ -1 +0,0 @@
1
- export * from './rnToast'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnWindow'