feat: 添加 HAPopconfirm 组件并更新 index.page.vue 以集成确认功能
This commit is contained in:
@ -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>
|
||||||
|
|
@ -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
|
||||||
|
Reference in New Issue
Block a user