提交 2c89f5a1 编写于 作者: D DCloud_LXH

chore: popup add onHidePopup

上级 71e116f5
......@@ -62,6 +62,7 @@ export default /*#__PURE__*/ defineComponent({
)}
<div
class="uni-modal__bd"
// @ts-ignore
onTouchmovePassive={onEventStop}
v-text={content}
></div>
......
......@@ -5,6 +5,7 @@ import {
ShowActionSheetOptions,
defineAsyncApi,
} from '@dcloudio/uni-api'
import { once } from '@dcloudio/uni-shared'
import { extend } from '@vue/shared'
import { nextTick, reactive } from 'vue'
import actionSheet, { Props } from './actionSheet'
......@@ -15,6 +16,13 @@ let rejectAction: UniApp.ShowActionSheetOptions['fail']
let showActionSheetState: Props
const onHidePopupOnce = /*#__PURE__*/ once(() => {
UniServiceJSBridge.on(
'onHidePopup',
() => (showActionSheetState.visible = false)
)
})
function onActionSheetClose(tapIndex: number) {
if (tapIndex === -1) {
rejectAction && rejectAction('cancel')
......@@ -26,6 +34,7 @@ function onActionSheetClose(tapIndex: number) {
export const showActionSheet = defineAsyncApi<API_TYPE_SHOW_ACTION_SHEET>(
API_SHOW_ACTION_SHEET,
(args, { resolve, reject }) => {
onHidePopupOnce()
resolveAction = resolve
rejectAction = reject
if (!showActionSheetState) {
......
......@@ -11,9 +11,14 @@ import {
import modal, { ModalProps } from './modal'
import { ensureRoot, createRootApp } from './utils'
import { once } from '@dcloudio/uni-shared'
let showModalState: ModalProps
const onHidePopupOnce = /*#__PURE__*/ once(() => {
UniServiceJSBridge.on('onHidePopup', () => (showModalState.visible = false))
})
let currentShowModalResolve: UniApp.ShowModalOptions['success']
function onModalClose(type: 'cancel' | 'confirm') {
......@@ -27,6 +32,7 @@ function onModalClose(type: 'cancel' | 'confirm') {
export const showModal = defineAsyncApi<API_TYPE_SHOW_MODAL>(
API_SHOW_MODAL,
(args, { resolve }) => {
onHidePopupOnce()
currentShowModalResolve = resolve
if (!showModalState) {
showModalState = reactive(args as ModalProps)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册