File size: 490 Bytes
8ede856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { useToastStore } from '@/stores/toast'

export function useToast() {
    const store = useToastStore()

    const toast = (message, color = 'info', opts = {}) =>
        store.add({ message, color, ...opts })

    return {
        toast,
        success: (msg, opts) => toast(msg, 'success', opts),
        error: (msg, opts) => toast(msg, 'error', opts),
        info: (msg, opts) => toast(msg, 'primary', opts),
        warning: (msg, opts) => toast(msg, 'warning', opts)
    }
}