2024-10-13 17:37:01 +00:00
|
|
|
import type { Ref } from 'vue'
|
2022-11-18 17:45:38 +00:00
|
|
|
import { MessageToasterKey } from '@/symbols'
|
|
|
|
import { requireInjection } from '@/utils'
|
2024-10-13 17:37:01 +00:00
|
|
|
import type MessageToaster from '@/components/ui/message-toaster/MessageToaster.vue'
|
2022-11-19 18:04:21 +00:00
|
|
|
|
|
|
|
let toaster: Ref<InstanceType<typeof MessageToaster>>
|
2022-11-18 17:45:38 +00:00
|
|
|
|
|
|
|
export const useMessageToaster = () => {
|
2022-11-19 18:04:21 +00:00
|
|
|
toaster = toaster || requireInjection(MessageToasterKey)
|
2022-11-18 17:45:38 +00:00
|
|
|
|
|
|
|
return {
|
2022-11-19 18:04:21 +00:00
|
|
|
toastSuccess: toaster.value.success.bind(toaster.value),
|
|
|
|
toastInfo: toaster.value.info.bind(toaster.value),
|
|
|
|
toastWarning: toaster.value.warning.bind(toaster.value),
|
2024-10-13 17:37:01 +00:00
|
|
|
toastError: toaster.value.error.bind(toaster.value),
|
2022-11-18 17:45:38 +00:00
|
|
|
}
|
|
|
|
}
|