@mpxjs/api-proxy 2.9.69-beta.2 → 2.9.69-beta.6

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/@types/index.d.ts CHANGED
@@ -98,6 +98,7 @@ export const clearStorage: WechatMiniprogram.Wx['clearStorage']
98
98
  export const clearStorageSync: WechatMiniprogram.Wx['clearStorageSync']
99
99
  export const getSystemInfo: WechatMiniprogram.Wx['getSystemInfo']
100
100
  export const getSystemInfoSync: WechatMiniprogram.Wx['getSystemInfoSync']
101
+ export const getWindowInfo: WechatMiniprogram.Wx['getWindowInfo']
101
102
  export const setTabBarItem: WechatMiniprogram.Wx['setTabBarItem']
102
103
  export const setTabBarStyle: WechatMiniprogram.Wx['setTabBarStyle']
103
104
  export const showTabBar: WechatMiniprogram.Wx['showTabBar']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.69-beta.2",
3
+ "version": "2.9.69-beta.6",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -10,6 +10,13 @@ import Animated, {
10
10
 
11
11
  function showActionSheet (options = {}) {
12
12
  const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
13
+ if (itemList.length > 6) {
14
+ const result = {
15
+ errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
16
+ }
17
+ failHandle(result, fail, complete)
18
+ return
19
+ }
13
20
  const windowInfo = getWindowInfo()
14
21
  const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
15
22
  let actionSheetKey = null
@@ -33,15 +33,27 @@ function resolvePath (relative, base) {
33
33
  }
34
34
  return stack.join('/')
35
35
  }
36
+ function isLock(navigationHelper, type, options) {
37
+ if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
38
+ const res = { errMsg: `${type}:fail the previous routing event didn't complete` }
39
+ failHandle(res, options.fail, options.complete)
40
+ return true
41
+ }
42
+ setTimeout(() => {
43
+ if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
44
+ navigationHelper.lastFailCallback('timeout')
45
+ navigationHelper.lastFailCallback = null
46
+ }
47
+ }, 350)
48
+ return false
49
+ }
36
50
 
37
- let toPending = false
38
- function navigateTo (options = {}) {
39
- if (toPending) {
51
+ function navigateTo (options = {}) {
52
+ const navigationHelper = global.__navigationHelper
53
+ if (isLock(navigationHelper, 'navigateTo', options)) {
40
54
  return
41
55
  }
42
- toPending = true
43
56
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
44
- const navigationHelper = global.__navigationHelper
45
57
  if (navigation && navigationHelper) {
46
58
  const { path, queryObj } = parseUrl(options.url)
47
59
  const basePath = getBasePath(navigation)
@@ -55,19 +67,15 @@ function navigateTo (options = {}) {
55
67
  const res = { errMsg: `navigateTo:fail ${msg}` }
56
68
  failHandle(res, options.fail, options.complete)
57
69
  }
58
- navigationHelper.transitionEndCallback = () => {
59
- toPending = false
60
- }
61
70
  }
62
71
  }
63
- let redirectPending = false
72
+
64
73
  function redirectTo (options = {}) {
65
- if (redirectPending) {
66
- return
67
- }
68
- redirectPending = true
69
74
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
70
75
  const navigationHelper = global.__navigationHelper
76
+ if (isLock(navigationHelper, 'redirectTo', options)) {
77
+ return
78
+ }
71
79
  if (navigation && navigationHelper) {
72
80
  const { path, queryObj } = parseUrl(options.url)
73
81
  const basePath = getBasePath(navigation)
@@ -81,52 +89,43 @@ function redirectTo (options = {}) {
81
89
  const res = { errMsg: `redirectTo:fail ${msg}` }
82
90
  failHandle(res, options.fail, options.complete)
83
91
  }
84
- navigationHelper.transitionEndCallback = () => {
85
- redirectPending = false
86
- }
87
92
  }
88
93
  }
89
- let backPending = false
94
+
90
95
  function navigateBack (options = {}) {
91
- if (backPending) {
92
- return
93
- }
94
- backPending = true
95
96
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
96
97
  const navigationHelper = global.__navigationHelper
98
+ if (isLock(navigationHelper, 'navigateBack', options)) {
99
+ return
100
+ }
97
101
  if (navigation && navigationHelper) {
98
102
  const delta = options.delta || 1
99
103
  const routeLength = navigation.getState().routes.length
104
+ navigationHelper.lastSuccessCallback = () => {
105
+ const res = { errMsg: 'navigateBack:ok' }
106
+ successHandle(res, options.success, options.complete)
107
+ }
108
+ navigationHelper.lastFailCallback = (msg) => {
109
+ const res = { errMsg: `navigateBack:fail ${msg}` }
110
+ failHandle(res, options.fail, options.complete)
111
+ }
100
112
  if (delta >= routeLength && global.__mpx?.config.rnConfig.onAppBack?.(delta - routeLength + 1)) {
101
113
  nextTick(() => {
102
- backPending = false
103
114
  const res = { errMsg: 'navigateBack:ok' }
104
115
  successHandle(res, options.success, options.complete)
105
116
  })
106
117
  } else {
107
118
  navigation.pop(delta)
108
- navigationHelper.lastSuccessCallback = () => {
109
- const res = { errMsg: 'navigateBack:ok' }
110
- successHandle(res, options.success, options.complete)
111
- }
112
- navigationHelper.lastFailCallback = (msg) => {
113
- const res = { errMsg: `navigateBack:fail ${msg}` }
114
- failHandle(res, options.fail, options.complete)
115
- }
116
- }
117
- navigationHelper.transitionEndCallback = () => {
118
- backPending = false
119
119
  }
120
120
  }
121
121
  }
122
- let reLaunchPending = false
122
+
123
123
  function reLaunch (options = {}) {
124
- if (reLaunchPending) {
125
- return
126
- }
127
- reLaunchPending = true
128
124
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
129
125
  const navigationHelper = global.__navigationHelper
126
+ if (isLock(navigationHelper, 'reLaunch', options)) {
127
+ return
128
+ }
130
129
  if (navigation && navigationHelper) {
131
130
  const { path, queryObj } = parseUrl(options.url)
132
131
  const basePath = getBasePath(navigation)
@@ -148,9 +147,6 @@ function reLaunch (options = {}) {
148
147
  const res = { errMsg: `redirectTo:fail ${msg}` }
149
148
  failHandle(res, options.fail, options.complete)
150
149
  }
151
- navigationHelper.transitionEndCallback = () => {
152
- reLaunchPending = false
153
- }
154
150
  }
155
151
  }
156
152
 
@@ -139,7 +139,7 @@ const getLaunchOptionsSync = function () {
139
139
  throwSSRWarning('getLaunchOptionsSync API is running in non browser environments')
140
140
  return
141
141
  }
142
- return global.__mpxEnterOptions || {}
142
+ return global.__mpxLaunchOptions || {}
143
143
  }
144
144
 
145
145
  export {
@@ -42,18 +42,11 @@ const getWindowInfo = function () {
42
42
  }
43
43
 
44
44
  const getLaunchOptionsSync = function () {
45
- const options = global.__mpxEnterOptions || {}
46
- const { path, scene, query } = options
47
- return {
48
- path,
49
- scene,
50
- query
51
- }
45
+ return global.__mpxLaunchOptions || {}
52
46
  }
53
47
 
54
48
  const getEnterOptionsSync = function () {
55
- const result = getLaunchOptionsSync()
56
- return result
49
+ return global.__mpxEnterOptions || {}
57
50
  }
58
51
 
59
52
  export {
@@ -6,7 +6,7 @@ let toastKey
6
6
  let isLoadingShow
7
7
  const dimensionsScreen = Dimensions.get('screen')
8
8
  const screenHeight = dimensionsScreen.height
9
- const contentTop = parseInt(screenHeight * 0.35)
9
+ const contentTop = parseInt(screenHeight * 0.4)
10
10
  let tId // show duration 计时id
11
11
  const styles = StyleSheet.create({
12
12
  toastContent: {