diff --git a/docs/api/ui/media-query-observer.md b/docs/api/ui/media-query-observer.md
new file mode 100644
index 0000000000000000000000000000000000000000..8a38859aa93446df86694059efe9723ee728b7e3
--- /dev/null
+++ b/docs/api/ui/media-query-observer.md
@@ -0,0 +1,105 @@
+MediaQueryObserver 对象,用于监听页面 media query 状态的变化,如界面的长宽是不是在某个指定的范围内。
+
+### uni.createMediaQueryObserver([this])
+创建并返回一个 ``MediaQueryObserver`` 对象实例。
+
+**this说明:**
+
+自定义组件实例。**支付宝小程序不支持此参数,传入仅为抹平写法差异**
+
+### MediaQueryObserver 对象的方法列表
+
+|方法|说明|
+|:-|:-|
+|MediaQueryObserver.observe(Object descriptor, function callback)|开始监听页面 media query 变化情况|
+|MediaQueryObserver.disconnect()|停止监听,回调函数将不再触发|
+
+**observe 回调函数包含一个参数**
+
+||类型|说明|
+|:-|:-|:-|
+|intersectionRatio|boolean|页面的当前状态是否满足所指定的 media query|
+
+### 代码示例
+
+```
+
+
+
+ matches: {{matches}}
+
+
+ landscape: {{landscape}}
+
+
+
+
+
+
+
+
+
+```
diff --git a/packages/uni-cli-shared/lib/util.js b/packages/uni-cli-shared/lib/util.js
index ad0dc21820af1a9ea10cb70c8670c3ce6dae8b49..591112a1ee3d99bb07744e162bbd77e1087fe5d9 100644
--- a/packages/uni-cli-shared/lib/util.js
+++ b/packages/uni-cli-shared/lib/util.js
@@ -92,6 +92,8 @@ const NODE_MODULES_REGEX = /(\.\.\/)?node_modules/g
function normalizeNodeModules (str) {
str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules')
+ // HBuilderX 内置模块路径转换
+ str = str.replace(/.*HBuilderX\/plugins\/uniapp-cli\/node[-_]modules/, 'node-modules')
if (process.env.UNI_PLATFORM === 'mp-alipay') {
str = str.replace('node-modules/@', 'node-modules/npm-scope-')
}
@@ -136,4 +138,4 @@ module.exports = {
getTemplatePath () {
return path.join(__dirname, '../template')
}
-}
+}
diff --git a/packages/webpack-uni-mp-loader/lib/plugin/generate-component.js b/packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
index 2db5fd6733b7f663aba60ab03cd55532238a8607..31dea950527f0970676386ed0f70a139020e3237 100644
--- a/packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
+++ b/packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
@@ -89,11 +89,7 @@ module.exports = function generateComponent (compilation) {
let resource = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, '..', modulePath))
const altResource = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, modulePath))
- if (
- /^win/.test(process.platform) &&
- modulePath.includes('@dcloudio') &&
- isBuiltInComponentPath(modulePath)
- ) {
+ if (modulePath.includes('@dcloudio') && isBuiltInComponentPath(modulePath)) {
resource = normalizePath(path.resolve(process.env.UNI_CLI_CONTEXT, modulePath))
}
@@ -234,4 +230,4 @@ function removeUnusedComponent (name) {
fs.renameSync(path.join(process.env.UNI_OUTPUT_DIR, name + '.json'), path.join(process.env.UNI_OUTPUT_DIR, name +
'.bak.json'))
} catch (e) {}
-}
+}
diff --git a/src/core/helpers/protocol/route/route.js b/src/core/helpers/protocol/route/route.js
index 0b98bbebacbafd45e5f606290cf4079df999d0f9..01fb2c5d46b8f7ac13a48bcd6a6dc2ce2944bd1f 100644
--- a/src/core/helpers/protocol/route/route.js
+++ b/src/core/helpers/protocol/route/route.js
@@ -95,7 +95,7 @@ function createValidator (type) {
}
// 主要拦截目标为用户快速点击时触发的多次跳转,该情况,通常前后 url 是一样的
- if (navigatorLock === url) {
+ if (navigatorLock === url && params.openType !== 'appLaunch') {
return `${navigatorLock} locked`
}
// 至少 onLaunch 之后,再启用lock逻辑(onLaunch之前可能开发者手动调用路由API,来提前跳转)
diff --git a/src/core/service/api/context/canvas.js b/src/core/service/api/context/canvas.js
index 2cf64fa65295dbd7685a532276e92b0f82c33f78..4b5ff427c3cba886010c9bf0389272a741309448 100644
--- a/src/core/service/api/context/canvas.js
+++ b/src/core/service/api/context/canvas.js
@@ -328,38 +328,16 @@ export class CanvasContext {
}
}
- measureText (text, callback) {
+ measureText (text) {
const font = this.state.font
+ let width
if (__PLATFORM__ === 'h5') {
- const width = measureText(text, font)
- const textMetrics = new TextMetrics(width)
- if (typeof callback === 'function') {
- setTimeout(() => callback(textMetrics), 0)
- }
- return textMetrics
+ width = measureText(text, font)
} else {
- let textMetrics = new TextMetrics(0)
- if (typeof callback === 'function') {
- const callbackId = canvasEventCallbacks.push(function ({ width }) {
- callback(new TextMetrics(width))
- })
- operateCanvas(this.id, this.pageId, 'measureText', {
- text,
- font,
- callbackId
- })
- } else {
- const webview = plus.webview.getWebviewById(String(this.pageId))
- if (webview && webview.evalJSSync) {
- const js = `(${measureText.toString()})(${JSON.stringify(text)},${JSON.stringify(font)})`
- const width = webview.evalJSSync(js) || 0
- textMetrics = new TextMetrics(width)
- } else {
- console.error('warning: measureText missing required arguments: callback')
- }
- }
- return textMetrics
+ const webview = plus.webview.getWebviewById(String(this.pageId))
+ width = webview.evalJSSync(`(${measureText.toString()})(${JSON.stringify(text)},${JSON.stringify(font)})`)
}
+ return new TextMetrics(width)
}
save () {
diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue
index e3ce4306905b2209c77c27239ba884b30d6ef957..1fafdbf754f1d7f986ce4e52773edad26f261237 100644
--- a/src/core/view/components/canvas/index.vue
+++ b/src/core/view/components/canvas/index.vue
@@ -277,22 +277,6 @@ export default {
}, this.$page.id)
}
},
- measureText ({
- text,
- font,
- callbackId
- }) {
- const canvas = getTempCanvas()
- const c2d = canvas.getContext('2d')
- c2d.font = font
- UniViewJSBridge.publishHandler('onCanvasMethodCallback', {
- callbackId,
- data: {
- errMsg: 'measureText:ok',
- width: c2d.measureText(text).width || 0
- }
- }, this.$page.id)
- },
preloadImage: function (actions) {
var self = this
actions.forEach(function (action) {
diff --git a/src/platforms/mp-alipay/runtime/api/protocols.js b/src/platforms/mp-alipay/runtime/api/protocols.js
index bed4763c2dbe347512a3b7c262af02b0bdb939d0..afd6d8cea580a60830569aeb63e97a47cfb3bbea 100644
--- a/src/platforms/mp-alipay/runtime/api/protocols.js
+++ b/src/platforms/mp-alipay/runtime/api/protocols.js
@@ -3,7 +3,6 @@ import {
} from 'uni-shared'
import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
// 不支持的 API 列表
const todos = [
@@ -478,8 +477,7 @@ const protocols = { // 需要做转换的 API 列表
result.telNumber = info.mobilePhone
result.errMsg = result.resultStatus
}
- },
- createCanvasContext
+ }
}
export {
diff --git a/src/platforms/mp-baidu/runtime/api/protocols.js b/src/platforms/mp-baidu/runtime/api/protocols.js
index 8ecc39ea9caaa0659a80b8b230fc7156f3cb0017..1d2969dd08bf5d602dcb5463ebc61c76f24f2ec9 100644
--- a/src/platforms/mp-baidu/runtime/api/protocols.js
+++ b/src/platforms/mp-baidu/runtime/api/protocols.js
@@ -1,7 +1,6 @@
import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
// 不支持的 API 列表
const todos = [
@@ -120,12 +119,11 @@ const protocols = {
getAccountInfoSync: {
name: 'getEnvInfoSync',
returnValue: _handleEnvInfo
- },
- createCanvasContext
+ }
}
export {
protocols,
todos,
canIUses
-}
+}
diff --git a/src/platforms/mp-kuaishou/runtime/api/protocols.js b/src/platforms/mp-kuaishou/runtime/api/protocols.js
index b4783871de78b9878da26e976621657133234116..b4acb05c0feedb863e8650539a40f5be69c8303e 100644
--- a/src/platforms/mp-kuaishou/runtime/api/protocols.js
+++ b/src/platforms/mp-kuaishou/runtime/api/protocols.js
@@ -1,13 +1,11 @@
import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
export const protocols = {
navigateTo,
redirectTo,
- previewImage,
- createCanvasContext
+ previewImage
}
export const todos = [
'vibrate'
diff --git a/src/platforms/mp-qq/runtime/api/protocols.js b/src/platforms/mp-qq/runtime/api/protocols.js
index dec19a4d7504ccd975b576798456bbb0d56a07f1..a255937eb042b87e755d129524be81b738c2ec4b 100644
--- a/src/platforms/mp-qq/runtime/api/protocols.js
+++ b/src/platforms/mp-qq/runtime/api/protocols.js
@@ -1,13 +1,11 @@
import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
export const protocols = {
navigateTo,
redirectTo,
- previewImage,
- createCanvasContext
+ previewImage
}
export const todos = [
'preloadPage',
diff --git a/src/platforms/mp-toutiao/runtime/api/protocols.js b/src/platforms/mp-toutiao/runtime/api/protocols.js
index e72adbc2e686b8e60ec87c566d9d8ee8ff928b28..5b99a973246d448a246fdf0574eca8a48a23e4ec 100644
--- a/src/platforms/mp-toutiao/runtime/api/protocols.js
+++ b/src/platforms/mp-toutiao/runtime/api/protocols.js
@@ -1,7 +1,6 @@
-import navigateTo from 'uni-helpers/navigate-to'
-import redirectTo from '../../../mp-weixin/helpers/redirect-to'
+import navigateTo from 'uni-helpers/navigate-to'
+import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
// 不支持的 API 列表
const todos = [
@@ -101,8 +100,8 @@ const protocols = {
args: {
sizeType: false
}
- },
- navigateTo,
+ },
+ navigateTo,
redirectTo,
previewImage,
connectSocket: {
@@ -170,8 +169,7 @@ const protocols = {
args: {
digestAlgorithm: false
}
- },
- createCanvasContext
+ }
}
export {
diff --git a/src/platforms/mp-weixin/helpers/create-canvas-context.js b/src/platforms/mp-weixin/helpers/create-canvas-context.js
deleted file mode 100644
index dd6d0535f6c3b723ab8057000e74c4717aa142e8..0000000000000000000000000000000000000000
--- a/src/platforms/mp-weixin/helpers/create-canvas-context.js
+++ /dev/null
@@ -1,12 +0,0 @@
-export default {
- returnValue (fromRes, toRes) {
- const measureText = fromRes.measureText
- toRes.measureText = function (text, callback) {
- const textMetrics = measureText.call(this, text)
- if (typeof callback === 'function') {
- setTimeout(() => callback(textMetrics), 0)
- }
- return textMetrics
- }
- }
-}
diff --git a/src/platforms/mp-weixin/runtime/api/protocols.js b/src/platforms/mp-weixin/runtime/api/protocols.js
index 76fc4ef0748350dcca79b6184e03f3f326d1c2af..cc9b1584ce80401ca2e0e364aa0a562af8fa5c43 100644
--- a/src/platforms/mp-weixin/runtime/api/protocols.js
+++ b/src/platforms/mp-weixin/runtime/api/protocols.js
@@ -1,7 +1,6 @@
-import navigateTo from 'uni-helpers/navigate-to'
+import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../helpers/redirect-to'
import previewImage from '../../helpers/normalize-preview-image'
-import createCanvasContext from '../../helpers/create-canvas-context'
function addSafeAreaInsets (result) {
if (result.safeArea) {
@@ -15,7 +14,7 @@ function addSafeAreaInsets (result) {
}
}
export const protocols = {
- redirectTo,
+ redirectTo,
navigateTo,
previewImage,
getSystemInfo: {
@@ -23,8 +22,7 @@ export const protocols = {
},
getSystemInfoSync: {
returnValue: addSafeAreaInsets
- },
- createCanvasContext
+ }
}
export const todos = [
'vibrate',
@@ -32,4 +30,4 @@ export const todos = [
'unPreloadPage',
'loadSubPackage'
]
-export const canIUses = []
+export const canIUses = []
diff --git a/src/platforms/quickapp-webview/runtime/api/protocols.js b/src/platforms/quickapp-webview/runtime/api/protocols.js
index 03e3bc5a0b413f4f85e2be3895171729d4f5b23d..3c28c70f9e1de0c32a7bb5e454ca403d0cfd03a0 100644
--- a/src/platforms/quickapp-webview/runtime/api/protocols.js
+++ b/src/platforms/quickapp-webview/runtime/api/protocols.js
@@ -1,13 +1,11 @@
import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
-import createCanvasContext from '../../../mp-weixin/helpers/create-canvas-context'
export const protocols = {
navigateTo,
redirectTo,
- previewImage,
- createCanvasContext
+ previewImage
}
export const todos = [
'preloadPage',