@mpxjs/api-proxy 2.7.0-beta.1 → 2.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.7.0-beta.1",
3
+ "version": "2.7.1",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -15,6 +15,7 @@
15
15
  "@types",
16
16
  "README.md"
17
17
  ],
18
+ "main": "src/index.js",
18
19
  "repository": {
19
20
  "type": "git",
20
21
  "url": "git@github.com/didi/mpx.git"
@@ -38,5 +39,5 @@
38
39
  "dependencies": {
39
40
  "axios": "^0.21.1"
40
41
  },
41
- "gitHead": "7f65fd0558d535329892d99ddaeebe675127314b"
42
+ "gitHead": "a672cdbf1689bb4d7f1a0fbcb1037d9f99e5d015"
42
43
  }
@@ -8,7 +8,15 @@ function webHandleFail (result, fail, complete) {
8
8
  typeof complete === 'function' && complete(result)
9
9
  }
10
10
 
11
+ function isTabBarPage (url, router) {
12
+ const tabBarPagesMap = global.__tabBarPagesMap
13
+ if (!tabBarPagesMap || !url) return false
14
+ const path = router.match(url, router.history.current).path
15
+ return !!tabBarPagesMap[path.slice(1)]
16
+ }
17
+
11
18
  export {
12
19
  webHandleSuccess,
13
- webHandleFail
20
+ webHandleFail,
21
+ isTabBarPage
14
22
  }
@@ -1,5 +1,5 @@
1
1
  .__mpx_actionsheet__
2
- display none
2
+ display none
3
3
  &.show
4
4
  display block
5
5
  .__mpx_mask__
@@ -49,4 +49,4 @@
49
49
  color #000000
50
50
  background-color #FCFCFD
51
51
  padding 10px 0
52
- margin-top 6px
52
+ margin-top 6px
@@ -1,9 +1,14 @@
1
- import { webHandleSuccess, webHandleFail } from '../../../common/js'
1
+ import { webHandleSuccess, webHandleFail, isTabBarPage } from '../../../common/js'
2
2
  import { EventChannel } from '../event-channel'
3
3
 
4
4
  function redirectTo (options = {}) {
5
5
  const router = global.__mpxRouter
6
6
  if (router) {
7
+ if (isTabBarPage(options.url, router)) {
8
+ const res = { errMsg: 'redirectTo:fail can not redirectTo a tabBar page' }
9
+ webHandleFail(res, options.fail, options.complete)
10
+ return Promise.reject(res)
11
+ }
7
12
  router.__mpxAction = { type: 'redirect' }
8
13
  return new Promise((resolve, reject) => {
9
14
  router.replace(
@@ -28,6 +33,11 @@ function redirectTo (options = {}) {
28
33
  function navigateTo (options = {}) {
29
34
  const router = global.__mpxRouter
30
35
  if (router) {
36
+ if (isTabBarPage(options.url, router)) {
37
+ const res = { errMsg: 'navigateTo:fail can not navigateTo a tabBar page' }
38
+ webHandleFail(res, options.fail, options.complete)
39
+ return Promise.reject(res)
40
+ }
31
41
  const eventChannel = new EventChannel()
32
42
  router.__mpxAction = {
33
43
  type: 'to',
@@ -71,11 +81,13 @@ function navigateBack (options = {}) {
71
81
  }
72
82
  }
73
83
 
84
+ let reLaunchCount = 0
85
+
74
86
  function reLaunch (options = {}) {
75
87
  const router = global.__mpxRouter
76
88
  if (router) {
89
+ if (reLaunchCount === 0 && router.currentRoute.query.reLaunchCount) reLaunchCount = router.currentRoute.query.reLaunchCount
77
90
  const delta = router.stack.length - 1
78
- let reLaunchCount = router.currentRoute.query.reLaunchCount || 0
79
91
  router.__mpxAction = {
80
92
  type: 'reLaunch',
81
93
  path: options.url,
@@ -120,7 +132,7 @@ function switchTab (options = {}) {
120
132
  const toRoute = router.match(options.url, router.history.current)
121
133
  const currentRoute = router.currentRoute
122
134
  if (toRoute.path !== currentRoute.path) {
123
- if (toRoute.redirectedFrom) {
135
+ if (!isTabBarPage(options.url, router)) {
124
136
  const res = { errMsg: 'switchTab:fail can not switch to no-tabBar page!' }
125
137
  webHandleFail(res, options.fail, options.complete)
126
138
  return Promise.reject(res)