提交 86e1d0a3 编写于 作者: D DCloud_LXH

chore: web-view brige

上级 8a90c54c
import { ComponentPublicInstance } from '@vue/runtime-core'
import { getCurrentPage, invokeHook } from './page'
import { onWebInvokeAppService } from '@dcloudio/uni-platform'
export function initOn() {
UniServiceJSBridge.on('onAppEnterForeground', onAppEnterForeground)
UniServiceJSBridge.on('onAppEnterBackground', onAppEnterBackground)
UniServiceJSBridge.on('onWebInvokeAppService', onWebInvokeAppService)
}
function onAppEnterForeground() {
......
此差异已折叠。
此差异已折叠。
......@@ -14,4 +14,3 @@ export {
export * from './saveImage'
export * from './constants'
export { getSameOriginUrl } from '../helpers/file'
export { onWebInvokeAppService } from '../service/onWebInvokeAppService'
......@@ -5,11 +5,19 @@ type Name =
| 'reLaunch'
| 'redirectTo'
| 'postMessage'
type WebInvokeData = {
name: Name
arg: any
}
export type WebInvokeAppService = (
webInvokeData: WebInvokeData,
pageId: number | number[]
) => void
export function onWebInvokeAppService(
{ name, arg }: { name: Name; arg: any },
pageId: number
) {
export const onWebInvokeAppService: WebInvokeAppService = (
{ name, arg },
pageId
) => {
if (name === 'postMessage') {
// TODO 小程序后退、组件销毁、分享时通知
} else {
......
......@@ -5,7 +5,12 @@ import {
useAttrs,
} from '@dcloudio/uni-components'
import { getRealPath } from '@dcloudio/uni-platform'
import { updateElementStyle } from '@dcloudio/uni-shared'
import { updateElementStyle, once } from '@dcloudio/uni-shared'
import { onWebInvokeAppService } from '../../../service/onWebInvokeAppService'
const Invoke = /*#__PURE__*/ once(() =>
UniServiceJSBridge.on('onWebInvokeAppService', onWebInvokeAppService)
)
const props = {
src: {
......@@ -21,6 +26,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
name: 'WebView',
props,
setup(props, { attrs }) {
Invoke()
const rootRef: RootRef = ref(null)
const iframeRef: RootRef = ref(null)
const _resize = useWebViewSize(rootRef, iframeRef)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册