mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
19 lines
381 B
TypeScript
19 lines
381 B
TypeScript
import { ref } from "vue";
|
|
|
|
const message = ref("");
|
|
const visible = ref(false);
|
|
let timer = 0;
|
|
|
|
export function useToast() {
|
|
function toast(msg: string, duration = 2000) {
|
|
message.value = msg;
|
|
visible.value = true;
|
|
clearTimeout(timer);
|
|
timer = window.setTimeout(() => {
|
|
visible.value = false;
|
|
}, duration);
|
|
}
|
|
|
|
return { message, visible, toast };
|
|
}
|