提交 e30ae5e9 编写于 作者: Q qiang

feat: 支持 offKeyboardHeightChange 方法

上级 9d217c26
...@@ -131,6 +131,7 @@ const device = [ ...@@ -131,6 +131,7 @@ const device = [
const keyboard = [ const keyboard = [
'hideKeyboard', 'hideKeyboard',
'onKeyboardHeightChange', 'onKeyboardHeightChange',
'offKeyboardHeightChange',
'getSelectedTextRange' 'getSelectedTextRange'
] ]
......
...@@ -162,7 +162,8 @@ ...@@ -162,7 +162,8 @@
"uni.createIntersectionObserver": true, "uni.createIntersectionObserver": true,
"uni.createMediaQueryObserver": true, "uni.createMediaQueryObserver": true,
"uni.hideKeyboard": true, "uni.hideKeyboard": true,
"uni.onKeyboardHeightChange": true "uni.onKeyboardHeightChange": true,
"uni.offKeyboardHeightChange": true
} }
}, { }, {
"name": "event", "name": "event",
......
...@@ -275,6 +275,10 @@ export function invokeCallbackHandler (invokeCallbackId, res, extras) { ...@@ -275,6 +275,10 @@ export function invokeCallbackHandler (invokeCallbackId, res, extras) {
return res return res
} }
export function removeCallbackHandler (invokeCallbackId) {
delete invokeCallbacks[invokeCallbackId]
}
export function wrapperUnimplemented (name) { export function wrapperUnimplemented (name) {
return function todo (args) { return function todo (args) {
console.error('API `' + name + '` is not yet implemented') console.error('API `' + name + '` is not yet implemented')
......
import { import {
invoke invoke,
remove
} from 'uni-core/service/bridge' } from 'uni-core/service/bridge'
import { import {
...@@ -15,5 +16,12 @@ onMethod('onKeyboardHeightChange', res => { ...@@ -15,5 +16,12 @@ onMethod('onKeyboardHeightChange', res => {
}) })
export function onKeyboardHeightChange (callbackId) { export function onKeyboardHeightChange (callbackId) {
// 与微信小程序一致仅保留最后一次监听
remove(callback)
callback = callbackId callback = callbackId
} }
export function offKeyboardHeightChange () {
// 与微信小程序一致移除最后一次监听
callback = null
}
export function pack (args) { export function pack (args) {
return args return args
} }
export function unpack (args) { export function unpack (args) {
return args return args
} }
export function invoke (...args) { export function invoke (...args) {
return UniServiceJSBridge.invokeCallbackHandler(...args) return UniServiceJSBridge.invokeCallbackHandler(...args)
}
export function remove (args) {
return UniServiceJSBridge.removeCallbackHandler(args)
} }
...@@ -8,7 +8,8 @@ export const once = Emitter.$once.bind(Emitter) ...@@ -8,7 +8,8 @@ export const once = Emitter.$once.bind(Emitter)
export const emit = Emitter.$emit.bind(Emitter) export const emit = Emitter.$emit.bind(Emitter)
export { export {
invokeCallbackHandler invokeCallbackHandler,
removeCallbackHandler
} }
from 'uni-helpers/api' from 'uni-helpers/api'
...@@ -30,4 +31,4 @@ export function subscribeHandler (event, args, pageId) { ...@@ -30,4 +31,4 @@ export function subscribeHandler (event, args, pageId) {
export { export {
publishHandler publishHandler
} }
from 'uni-platform/service/bridge' from 'uni-platform/service/bridge'
...@@ -3,7 +3,8 @@ import { ...@@ -3,7 +3,8 @@ import {
} from 'uni-core/service/uni' } from 'uni-core/service/uni'
import { import {
invokeCallbackHandler invokeCallbackHandler,
removeCallbackHandler
} from 'uni-helpers/api' } from 'uni-helpers/api'
import { import {
...@@ -35,6 +36,7 @@ uni.__$wx__ = wx ...@@ -35,6 +36,7 @@ uni.__$wx__ = wx
UniServiceJSBridge.publishHandler = publishHandler UniServiceJSBridge.publishHandler = publishHandler
UniServiceJSBridge.invokeCallbackHandler = invokeCallbackHandler UniServiceJSBridge.invokeCallbackHandler = invokeCallbackHandler
UniServiceJSBridge.removeCallbackHandler = removeCallbackHandler
export default { export default {
__vuePlugin: vuePlugin, __vuePlugin: vuePlugin,
...@@ -44,4 +46,4 @@ export default { ...@@ -44,4 +46,4 @@ export default {
uni, uni,
getApp, getApp,
getCurrentPages getCurrentPages
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册