mirror of https://github.com/wg-easy/wg-easy
14 changed files with 94 additions and 48 deletions
@ -0,0 +1,26 @@ |
|||
export const useToast = defineStore('Toast', () => { |
|||
type ToastInterface = { |
|||
publish: (e: { title: string; message: string }) => void; |
|||
}; |
|||
|
|||
type ToastRef = Ref<null | ToastInterface>; |
|||
|
|||
const toast = ref<Ref<ToastRef> | null>(null); |
|||
|
|||
function setToast(toastInstance: ToastRef) { |
|||
toast.value = toastInstance; |
|||
} |
|||
|
|||
function showToast({ |
|||
title, |
|||
message, |
|||
}: { |
|||
type: 'success' | 'error'; |
|||
title: string; |
|||
message: string; |
|||
}) { |
|||
toast.value?.value?.publish({ title, message }); |
|||
} |
|||
|
|||
return { setToast, showToast }; |
|||
}); |
Loading…
Reference in new issue