feat: 添加 HAPopconfirm 组件并更新 index.page.vue 以集成确认功能
Some checks failed
/ depcheck (push) Successful in 2m2s
/ surge (push) Successful in 2m2s
/ playwright (push) Successful in 4m1s
/ build-and-deploy-to-vercel (push) Failing after 44s

This commit is contained in:
严浩
2025-02-28 14:47:10 +08:00
parent 8c855b5b3d
commit 94b71c5c47
2 changed files with 22 additions and 23 deletions

View File

@ -1,13 +1,19 @@
<script setup lang="ts"> <script lang="ts">
import type { PopconfirmProps } from 'ant-design-vue'; import type { PopconfirmProps } from 'ant-design-vue';
defineOptions({ inheritAttrs: true });
const props = defineProps<HPopconfirmProps>();
type NotUndefined<T> = T extends undefined ? never : T; type NotUndefined<T> = T extends undefined ? never : T;
type PopconfirmOnConfirmParameters = Parameters<NotUndefined<PopconfirmProps['onConfirm']>>; type PopconfirmOnConfirmParameters = Parameters<NotUndefined<PopconfirmProps['onConfirm']>>;
type HPopconfirmProps = { type HPopconfirmProps = {
description: PopconfirmProps['description'];
onConfirm?: (...args: PopconfirmOnConfirmParameters) => Promise<void>; onConfirm?: (...args: PopconfirmOnConfirmParameters) => Promise<void>;
title: PopconfirmProps['title'];
}; };
</script>
<script setup lang="ts">
defineOptions({ inheritAttrs: true });
const props = defineProps<HPopconfirmProps>();
const _loading = shallowRef(false); const _loading = shallowRef(false);
const onConfirm: PopconfirmProps['onConfirm'] = async (e) => { const onConfirm: PopconfirmProps['onConfirm'] = async (e) => {
@ -24,16 +30,18 @@ const onConfirm: PopconfirmProps['onConfirm'] = async (e) => {
<template> <template>
<APopconfirm <APopconfirm
:arrowPointAtCenter="!true"
:disabled="_loading"
placement="topRight"
:align="{ :align="{
targetOffset: [0, 0], targetOffset: [0, 0],
}" }"
:onConfirm :arrow-point-at-center="!true"
:cancelButtonProps="{ disabled: _loading }" :cancel-button-props="{ disabled: _loading }"
:description
:disabled="_loading"
:on-confirm
:title
placement="topRight"
> >
<slot /> <slot></slot>
</APopconfirm> </APopconfirm>
</template> </template>

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import HAPopconfirmButton from './HAPopconfirmButton.vue'; import HAPopconfirm from './HAPopconfirm.vue';
async function handleConfirmAsync(e: MouseEvent) { async function handleConfirmAsync(e: MouseEvent) {
console.debug('handleConfirmAsync', e); console.debug('handleConfirmAsync', e);
@ -15,19 +15,9 @@ async function handleConfirmAsync(e: MouseEvent) {
<template> <template>
<ACard> <ACard>
<ACard> <ACard>
<APopconfirm @confirm="handleConfirmAsync"> <HAPopconfirm title="你确定吗? 🤔 " description="别担心,我们只是假装很严肃 🎭" @confirm="handleConfirmAsync">
<AButton size="small" type="text">APopconfirm</AButton> <AButton size="small" danger type="text">HAPopconfirm</AButton>
</APopconfirm> </HAPopconfirm>
<AButton size="small" type="text">AButton</AButton>
<HAPopconfirmButton
title="你确定吗? 🤔 "
description="别担心,我们只是假装很严肃 🎭"
@confirm="handleConfirmAsync"
>
<AButton size="small" danger type="text">HAPopconfirmButton</AButton>
</HAPopconfirmButton>
</ACard> </ACard>
<ACard class="mt-4"> <ACard class="mt-4">
<AForm name="basic" :label-col="{ style: { width: '7em' } }"> <AForm name="basic" :label-col="{ style: { width: '7em' } }">
@ -44,3 +34,4 @@ async function handleConfirmAsync(e: MouseEvent) {
</ACard> </ACard>
</ACard> </ACard>
</template> </template>
./HAPopconfirm.vue