@mpxjs/api-proxy
Advanced tools
Comparing version 2.7.0-beta.1 to 2.7.0-beta.6
{ | ||
"name": "@mpxjs/api-proxy", | ||
"version": "2.7.0-beta.1", | ||
"version": "2.7.0-beta.6", | ||
"description": "convert miniprogram API at each end", | ||
@@ -18,2 +18,3 @@ "module": "src/index.js", | ||
], | ||
"main": "src/index.js", | ||
"repository": { | ||
@@ -42,3 +43,3 @@ "type": "git", | ||
}, | ||
"gitHead": "7f65fd0558d535329892d99ddaeebe675127314b" | ||
"gitHead": "c04233503af0b1c7b4410fd03582d9dd883182d9" | ||
} |
@@ -11,5 +11,13 @@ function webHandleSuccess (result, success, complete) { | ||
function isTabBarPage (url, router) { | ||
const tabBarPagesMap = global.__tabBarPagesMap | ||
if (!tabBarPagesMap || !url) return false | ||
const path = router.match(url, router.history.current).path | ||
return !!tabBarPagesMap[path.slice(1)] | ||
} | ||
export { | ||
webHandleSuccess, | ||
webHandleFail | ||
webHandleFail, | ||
isTabBarPage | ||
} |
@@ -1,2 +0,2 @@ | ||
import { webHandleSuccess, webHandleFail } from '../../../common/js' | ||
import { webHandleSuccess, webHandleFail, isTabBarPage } from '../../../common/js' | ||
import { EventChannel } from '../event-channel' | ||
@@ -7,2 +7,7 @@ | ||
if (router) { | ||
if (isTabBarPage(options.url, router)) { | ||
const res = { errMsg: 'redirectTo:fail can not redirectTo a tabBar page' } | ||
webHandleFail(res, options.fail, options.complete) | ||
return Promise.reject(res) | ||
} | ||
router.__mpxAction = { type: 'redirect' } | ||
@@ -32,2 +37,7 @@ return new Promise((resolve, reject) => { | ||
if (router) { | ||
if (isTabBarPage(options.url, router)) { | ||
const res = { errMsg: 'navigateTo:fail can not navigateTo a tabBar page' } | ||
webHandleFail(res, options.fail, options.complete) | ||
return Promise.reject(res) | ||
} | ||
const eventChannel = new EventChannel() | ||
@@ -76,7 +86,9 @@ router.__mpxAction = { | ||
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 | ||
let reLaunchCount = router.currentRoute.query.reLaunchCount || 0 | ||
router.__mpxAction = { | ||
@@ -126,3 +138,3 @@ type: 'reLaunch', | ||
if (toRoute.path !== currentRoute.path) { | ||
if (toRoute.redirectedFrom) { | ||
if (!isTabBarPage(options.url, router)) { | ||
const res = { errMsg: 'switchTab:fail can not switch to no-tabBar page!' } | ||
@@ -129,0 +141,0 @@ webHandleFail(res, options.fail, options.complete) |
Sorry, the diff of this file is not supported yet
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
115367
3007