@mpxjs/api-proxy 2.8.44 → 2.8.46
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 +2 -2
- package/src/web/api/route/index.js +20 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.46",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"axios": "^0.21.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "dcf6f000660d56207ff414cb776e8bc6d5ce651f"
|
|
43
43
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { webHandleSuccess, webHandleFail, isTabBarPage } from '../../../common/js'
|
|
2
2
|
import { EventChannel } from '../event-channel'
|
|
3
3
|
|
|
4
|
+
let routeCount = 0
|
|
5
|
+
|
|
4
6
|
function redirectTo (options = {}) {
|
|
5
7
|
const router = global.__mpxRouter
|
|
6
8
|
if (router) {
|
|
@@ -9,11 +11,17 @@ function redirectTo (options = {}) {
|
|
|
9
11
|
webHandleFail(res, options.fail, options.complete)
|
|
10
12
|
return Promise.reject(res)
|
|
11
13
|
}
|
|
12
|
-
router.__mpxAction = {
|
|
14
|
+
router.__mpxAction = {
|
|
15
|
+
type: 'redirect'
|
|
16
|
+
}
|
|
17
|
+
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
13
18
|
return new Promise((resolve, reject) => {
|
|
14
19
|
router.replace(
|
|
15
20
|
{
|
|
16
|
-
path: options.url
|
|
21
|
+
path: options.url,
|
|
22
|
+
query: {
|
|
23
|
+
routeCount: ++routeCount
|
|
24
|
+
}
|
|
17
25
|
},
|
|
18
26
|
() => {
|
|
19
27
|
const res = { errMsg: 'redirectTo:ok' }
|
|
@@ -46,10 +54,14 @@ function navigateTo (options = {}) {
|
|
|
46
54
|
if (options.events) {
|
|
47
55
|
eventChannel._addListeners(options.events)
|
|
48
56
|
}
|
|
57
|
+
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
49
58
|
return new Promise((resolve, reject) => {
|
|
50
59
|
router.push(
|
|
51
60
|
{
|
|
52
|
-
path: options.url
|
|
61
|
+
path: options.url,
|
|
62
|
+
query: {
|
|
63
|
+
routeCount: ++routeCount
|
|
64
|
+
}
|
|
53
65
|
},
|
|
54
66
|
() => {
|
|
55
67
|
const res = { errMsg: 'navigateTo:ok', eventChannel }
|
|
@@ -81,19 +93,17 @@ function navigateBack (options = {}) {
|
|
|
81
93
|
}
|
|
82
94
|
}
|
|
83
95
|
|
|
84
|
-
let reLaunchCount = 0
|
|
85
|
-
|
|
86
96
|
function reLaunch (options = {}) {
|
|
87
97
|
const router = global.__mpxRouter
|
|
88
98
|
if (router) {
|
|
89
|
-
if (
|
|
90
|
-
const delta = router.stack.length - 1
|
|
99
|
+
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
91
100
|
router.__mpxAction = {
|
|
92
101
|
type: 'reLaunch',
|
|
93
102
|
path: options.url,
|
|
94
|
-
|
|
103
|
+
routeCount: ++routeCount,
|
|
95
104
|
replaced: false
|
|
96
105
|
}
|
|
106
|
+
const delta = router.stack.length - 1
|
|
97
107
|
// 在需要操作后退时,先操作后退,在beforeEach中基于当前action通过next()进行replace操作,避免部分浏览器的表现不一致
|
|
98
108
|
if (delta > 0) {
|
|
99
109
|
router.go(-delta)
|
|
@@ -104,7 +114,7 @@ function reLaunch (options = {}) {
|
|
|
104
114
|
{
|
|
105
115
|
path: options.url,
|
|
106
116
|
query: {
|
|
107
|
-
|
|
117
|
+
routeCount
|
|
108
118
|
}
|
|
109
119
|
},
|
|
110
120
|
() => {
|
|
@@ -137,12 +147,12 @@ function switchTab (options = {}) {
|
|
|
137
147
|
webHandleFail(res, options.fail, options.complete)
|
|
138
148
|
return Promise.reject(res)
|
|
139
149
|
}
|
|
140
|
-
const delta = router.stack.length - 1
|
|
141
150
|
router.__mpxAction = {
|
|
142
151
|
type: 'switch',
|
|
143
152
|
path: options.url,
|
|
144
153
|
replaced: false
|
|
145
154
|
}
|
|
155
|
+
const delta = router.stack.length - 1
|
|
146
156
|
if (delta > 0) {
|
|
147
157
|
router.go(-delta)
|
|
148
158
|
} else {
|