feat: add interest button
This commit is contained in:
51
composables/useToast.ts
Normal file
51
composables/useToast.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
interface Toast {
|
||||
show: boolean
|
||||
message: string
|
||||
color: string
|
||||
timeout: number
|
||||
}
|
||||
|
||||
const toast = ref<Toast>({
|
||||
show: false,
|
||||
message: '',
|
||||
color: 'success',
|
||||
timeout: 3000
|
||||
})
|
||||
|
||||
export const useToast = () => {
|
||||
const showToast = (message: string, color: string = 'success', timeout: number = 3000) => {
|
||||
toast.value = {
|
||||
show: true,
|
||||
message,
|
||||
color,
|
||||
timeout
|
||||
}
|
||||
}
|
||||
|
||||
const success = (message: string) => {
|
||||
showToast(message, 'success')
|
||||
}
|
||||
|
||||
const error = (message: string) => {
|
||||
showToast(message, 'error')
|
||||
}
|
||||
|
||||
const info = (message: string) => {
|
||||
showToast(message, 'info')
|
||||
}
|
||||
|
||||
const warning = (message: string) => {
|
||||
showToast(message, 'warning')
|
||||
}
|
||||
|
||||
return {
|
||||
toast,
|
||||
showToast,
|
||||
success,
|
||||
error,
|
||||
info,
|
||||
warning
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user