86 lines
2.9 KiB
Vue
86 lines
2.9 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogBackdrop,
|
|
AlertDialogBody,
|
|
AlertDialogClose,
|
|
AlertDialogCloseTrigger,
|
|
AlertDialogContainer,
|
|
AlertDialogDialog,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogHeading,
|
|
AlertDialogIcon,
|
|
Button,
|
|
} from "@heroui-vue/components";
|
|
|
|
const examples = [
|
|
{
|
|
actions: { cancel: "保持登录", confirm: "退出登录" },
|
|
body: "退出后需要重新登录才能访问账户,未保存的更改将丢失。",
|
|
classNames: "bg-accent-soft text-accent-soft-foreground",
|
|
header: "要退出当前账户吗?",
|
|
status: "accent",
|
|
trigger: "退出登录",
|
|
},
|
|
{
|
|
actions: { cancel: "稍后再说", confirm: "标记完成" },
|
|
body: "将把该任务标记为完成并通知所有成员,任务会移入已完成列表。",
|
|
classNames: "bg-success-soft text-success-soft-foreground",
|
|
header: "要完成此任务吗?",
|
|
status: "success",
|
|
trigger: "完成任务",
|
|
},
|
|
{
|
|
actions: { cancel: "继续编辑", confirm: "放弃更改" },
|
|
body: "你有未保存的更改,放弃后将永久丢失。确定要放弃吗?",
|
|
classNames: "bg-warning-soft text-warning-soft-foreground",
|
|
header: "要放弃未保存的更改吗?",
|
|
status: "warning",
|
|
trigger: "放弃更改",
|
|
},
|
|
{
|
|
actions: { cancel: "取消", confirm: "删除账户" },
|
|
body: "将永久删除你的账户并从服务器移除全部数据,此操作不可恢复。",
|
|
classNames: "bg-danger-soft text-danger-soft-foreground",
|
|
header: "要删除账户吗?",
|
|
status: "danger",
|
|
trigger: "删除账户",
|
|
},
|
|
] as const;
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex flex-wrap gap-4">
|
|
<AlertDialog v-for="example in examples" :key="example.status">
|
|
<Button :class="example.classNames">{{ example.trigger }}</Button>
|
|
<AlertDialogBackdrop>
|
|
<AlertDialogContainer>
|
|
<AlertDialogDialog class="sm:max-w-[400px]">
|
|
<AlertDialogCloseTrigger />
|
|
<AlertDialogHeader>
|
|
<AlertDialogIcon :status="example.status" />
|
|
<AlertDialogHeading>{{ example.header }}</AlertDialogHeading>
|
|
</AlertDialogHeader>
|
|
<AlertDialogBody>
|
|
<p>{{ example.body }}</p>
|
|
</AlertDialogBody>
|
|
<AlertDialogFooter>
|
|
<AlertDialogClose as-child>
|
|
<Button variant="tertiary">{{ example.actions.cancel }}</Button>
|
|
</AlertDialogClose>
|
|
<AlertDialogClose as-child>
|
|
<Button
|
|
:variant="example.status === 'danger' ? 'danger' : 'primary'"
|
|
>
|
|
{{ example.actions.confirm }}
|
|
</Button>
|
|
</AlertDialogClose>
|
|
</AlertDialogFooter>
|
|
</AlertDialogDialog>
|
|
</AlertDialogContainer>
|
|
</AlertDialogBackdrop>
|
|
</AlertDialog>
|
|
</div>
|
|
</template>
|