From 4a2c7b313f12a794e3f891eb37884137c7fc50f5 Mon Sep 17 00:00:00 2001 From: Netfan Date: Sat, 12 Apr 2025 10:37:47 +0800 Subject: [PATCH] fix: alert animation (#5927) --- .../@core/ui-kit/popup-ui/src/alert/alert.ts | 4 ++++ .../@core/ui-kit/popup-ui/src/alert/alert.vue | 22 +++++++++---------- .../ui/alert-dialog/AlertDialogContent.vue | 14 ++++++++++-- playground/src/views/examples/modal/index.vue | 2 ++ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/packages/@core/ui-kit/popup-ui/src/alert/alert.ts b/packages/@core/ui-kit/popup-ui/src/alert/alert.ts index 49d65ed5..1f0d0282 100644 --- a/packages/@core/ui-kit/popup-ui/src/alert/alert.ts +++ b/packages/@core/ui-kit/popup-ui/src/alert/alert.ts @@ -36,6 +36,10 @@ export type AlertProps = { contentMasking?: boolean; /** 弹窗的图标(在标题的前面) */ icon?: Component | IconType; + /** + * 弹窗遮罩模糊效果 + */ + overlayBlur?: number; /** 是否显示取消按钮 */ showCancel?: boolean; /** 弹窗标题 */ diff --git a/packages/@core/ui-kit/popup-ui/src/alert/alert.vue b/packages/@core/ui-kit/popup-ui/src/alert/alert.vue index 5c02ed2a..e6237304 100644 --- a/packages/@core/ui-kit/popup-ui/src/alert/alert.vue +++ b/packages/@core/ui-kit/popup-ui/src/alert/alert.vue @@ -3,7 +3,7 @@ import type { Component } from 'vue'; import type { AlertProps } from './alert'; -import { computed, h, nextTick, ref, watch } from 'vue'; +import { computed, h, nextTick, ref } from 'vue'; import { useSimpleLocale } from '@vben-core/composables'; import { @@ -39,14 +39,12 @@ const open = defineModel('open', { default: false }); const { $t } = useSimpleLocale(); const components = globalShareState.getComponents(); const isConfirm = ref(false); -watch(open, async (val) => { - await nextTick(); - if (val) { - isConfirm.value = false; - } else { - emits('closed', isConfirm.value); - } -}); + +function onAlertClosed() { + emits('closed', isConfirm.value); + isConfirm.value = false; +} + const getIconRender = computed(() => { let iconRender: Component | null = null; if (props.icon) { @@ -100,6 +98,7 @@ function handleCancel() { const loading = ref(false); async function handleOpenChange(val: boolean) { + await nextTick(); if (!val && props.beforeClose) { loading.value = true; try { @@ -120,15 +119,16 @@ async function handleOpenChange(val: boolean) { - + { message.success(`用户输入了:${res}`);