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';
defineOptions({ inheritAttrs: true });
const props = defineProps<HPopconfirmProps>();
type NotUndefined<T> = T extends undefined ? never : T;
type PopconfirmOnConfirmParameters = Parameters<NotUndefined<PopconfirmProps['onConfirm']>>;
type HPopconfirmProps = {
description: PopconfirmProps['description'];
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 onConfirm: PopconfirmProps['onConfirm'] = async (e) => {
@ -24,16 +30,18 @@ const onConfirm: PopconfirmProps['onConfirm'] = async (e) => {
<template>
<APopconfirm
:arrowPointAtCenter="!true"
:disabled="_loading"
placement="topRight"
:align="{
targetOffset: [0, 0],
}"
:onConfirm
:cancelButtonProps="{ disabled: _loading }"
:arrow-point-at-center="!true"
:cancel-button-props="{ disabled: _loading }"
:description
:disabled="_loading"
:on-confirm
:title
placement="topRight"
>
<slot />
<slot></slot>
</APopconfirm>
</template>

View File

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