@mpxjs/api-proxy
Advanced tools
Comparing version 2.8.44 to 2.8.46
{ | ||
"name": "@mpxjs/api-proxy", | ||
"version": "2.8.44", | ||
"version": "2.8.46", | ||
"description": "convert miniprogram API at each end", | ||
@@ -42,3 +42,3 @@ "module": "src/index.js", | ||
}, | ||
"gitHead": "cd1f38bc84aca8b2a2e5ec890aa1e2f2693f26e3" | ||
"gitHead": "dcf6f000660d56207ff414cb776e8bc6d5ce651f" | ||
} |
import { webHandleSuccess, webHandleFail, isTabBarPage } from '../../../common/js' | ||
import { EventChannel } from '../event-channel' | ||
let routeCount = 0 | ||
function redirectTo (options = {}) { | ||
@@ -12,7 +14,13 @@ const router = global.__mpxRouter | ||
} | ||
router.__mpxAction = { type: 'redirect' } | ||
router.__mpxAction = { | ||
type: 'redirect' | ||
} | ||
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount | ||
return new Promise((resolve, reject) => { | ||
router.replace( | ||
{ | ||
path: options.url | ||
path: options.url, | ||
query: { | ||
routeCount: ++routeCount | ||
} | ||
}, | ||
@@ -50,6 +58,10 @@ () => { | ||
} | ||
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount | ||
return new Promise((resolve, reject) => { | ||
router.push( | ||
{ | ||
path: options.url | ||
path: options.url, | ||
query: { | ||
routeCount: ++routeCount | ||
} | ||
}, | ||
@@ -86,15 +98,13 @@ () => { | ||
let reLaunchCount = 0 | ||
function reLaunch (options = {}) { | ||
const router = global.__mpxRouter | ||
if (router) { | ||
if (reLaunchCount === 0 && router.currentRoute.query.reLaunchCount) reLaunchCount = router.currentRoute.query.reLaunchCount | ||
const delta = router.stack.length - 1 | ||
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount | ||
router.__mpxAction = { | ||
type: 'reLaunch', | ||
path: options.url, | ||
reLaunchCount: ++reLaunchCount, | ||
routeCount: ++routeCount, | ||
replaced: false | ||
} | ||
const delta = router.stack.length - 1 | ||
// 在需要操作后退时,先操作后退,在beforeEach中基于当前action通过next()进行replace操作,避免部分浏览器的表现不一致 | ||
@@ -110,3 +120,3 @@ if (delta > 0) { | ||
query: { | ||
reLaunchCount | ||
routeCount | ||
} | ||
@@ -144,3 +154,2 @@ }, | ||
} | ||
const delta = router.stack.length - 1 | ||
router.__mpxAction = { | ||
@@ -151,2 +160,3 @@ type: 'switch', | ||
} | ||
const delta = router.stack.length - 1 | ||
if (delta > 0) { | ||
@@ -153,0 +163,0 @@ router.go(-delta) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120615
3173