@mpxjs/api-proxy
Advanced tools
Comparing version 2.9.0-beta.2 to 2.9.0-beta.3
{ | ||
"name": "@mpxjs/api-proxy", | ||
"version": "2.9.0-beta.2", | ||
"version": "2.9.0-beta.3", | ||
"description": "convert miniprogram API at each end", | ||
@@ -42,3 +42,3 @@ "module": "src/index.js", | ||
}, | ||
"gitHead": "2d61bab77c50eccb7470b9b9bd644e7bd6510467" | ||
"gitHead": "521f0cec1231962f9c071c8b70499772a0a81fda" | ||
} |
@@ -100,12 +100,4 @@ import { nextTick } from '../next-tick' | ||
const { left = 0, right = 0, top = 0, bottom = 0 } = marginsTemp | ||
this._root = document.querySelector('html') | ||
const viewportWidth = window.innerWidth || document.documentElement.clientWidth | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight | ||
const rootWidth = this._root.offsetWidth || 0 | ||
const rootHeight = this._root.offsetHeight || 0 | ||
if (rootHeight >= viewportHeight) { | ||
this._rootMargin = `${top}px ${viewportWidth - rootWidth + right}px ${viewportHeight - rootHeight + bottom}px ${left}px` | ||
} else { | ||
this._rootMargin = `${top}px ${right}px ${bottom}px ${left}px` | ||
} | ||
this._root = null | ||
this._rootMargin = `${top}px ${right}px ${bottom}px ${left}px` | ||
this._relativeInfo.push({ selector: null, margins }) | ||
@@ -112,0 +104,0 @@ }) |
@@ -78,3 +78,3 @@ import NodesRef from './NodesRef' | ||
_handleFields (fields, el, selector) { | ||
if (!el) return null | ||
if (!el || (el && !el.getBoundingClientRect)) return null | ||
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [], node } = fields | ||
@@ -81,0 +81,0 @@ const { left, right, top, bottom, width, height } = el.getBoundingClientRect() |
@@ -42,3 +42,13 @@ import axios from 'axios' | ||
timeout, | ||
cancelToken: source.token | ||
cancelToken: source.token, | ||
transitional: { | ||
// silent JSON parsing mode | ||
// `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour) | ||
// `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json') | ||
silentJSONParsing: true, // default value for the current Axios version | ||
// try to parse the response string as JSON even if `responseType` is not 'json' | ||
forcedJSONParsing: false, | ||
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
clarifyTimeoutError: false | ||
} | ||
} | ||
@@ -53,3 +63,3 @@ | ||
let data = res.data | ||
if (responseType === 'text' && dataType === 'json') { | ||
if (dataType === 'json' && typeof data === 'string') { | ||
try { | ||
@@ -56,0 +66,0 @@ data = JSON.parse(data) |
import { webHandleSuccess, webHandleFail, isTabBarPage, throwSSRWarning, isBrowser } from '../../../common/js' | ||
import { EventChannel } from '../event-channel' | ||
let routeCount = 0 | ||
function redirectTo (options = {}) { | ||
@@ -15,7 +18,13 @@ if (!isBrowser) { | ||
} | ||
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 | ||
} | ||
}, | ||
@@ -57,6 +66,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 | ||
} | ||
}, | ||
@@ -85,3 +98,7 @@ () => { | ||
if (router) { | ||
const delta = options.delta || 1 | ||
let delta = options.delta || 1 | ||
const stackLength = router.stack.length | ||
if (stackLength > 1 && delta >= stackLength) { | ||
delta = stackLength - 1 | ||
} | ||
router.__mpxAction = { | ||
@@ -98,4 +115,2 @@ type: 'back', | ||
let reLaunchCount = 0 | ||
function reLaunch (options = {}) { | ||
@@ -108,10 +123,10 @@ if (!isBrowser) { | ||
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操作,避免部分浏览器的表现不一致 | ||
@@ -127,3 +142,3 @@ if (delta > 0) { | ||
query: { | ||
reLaunchCount | ||
routeCount | ||
} | ||
@@ -165,3 +180,2 @@ }, | ||
} | ||
const delta = router.stack.length - 1 | ||
router.__mpxAction = { | ||
@@ -172,2 +186,3 @@ type: 'switch', | ||
} | ||
const delta = router.stack.length - 1 | ||
if (delta > 0) { | ||
@@ -174,0 +189,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
125981
3336