feat: migrate Toast and Table with reviewed state focus and SSR contracts
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ToastProvider,
|
||||
ToastQueue,
|
||||
createToastFunction,
|
||||
} from "@heroui-vue/components";
|
||||
const queue = new ToastQueue();
|
||||
const toast = createToastFunction(queue);
|
||||
onBeforeUnmount(() => queue.destroy());
|
||||
const timers = new Set<ReturnType<typeof setTimeout>>();
|
||||
onBeforeUnmount(() => timers.forEach(clearTimeout));
|
||||
function show() {
|
||||
toast("简单消息");
|
||||
for (const [delay, run] of [
|
||||
[400, () => toast.success("操作已完成")],
|
||||
[800, () => toast.info("有新更新可用")],
|
||||
] as const) {
|
||||
const timer = setTimeout(() => {
|
||||
timers.delete(timer);
|
||||
run();
|
||||
}, delay);
|
||||
timers.add(timer);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex h-full max-w-xl flex-col items-center justify-center">
|
||||
<Button size="sm" variant="secondary" @click="show">显示 3 条 Toast</Button>
|
||||
<ToastProvider
|
||||
:queue="queue"
|
||||
is-expanded
|
||||
aria-label="展开的通知"
|
||||
to="body"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user