chore: use UUID for message toaster

This commit is contained in:
Phan An 2023-04-17 22:13:11 +02:00
parent cb2fc8e15d
commit e9fdc02485

View file

@ -8,18 +8,17 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { uuid } from '@/utils'
import MessageToast from '@/components/ui/MessageToast.vue'
const messages = ref<ToastMessage[]>([])
const addMessage = (type: 'info' | 'success' | 'warning' | 'danger', content: string, timeout = 5) => {
const id = `${Date.now().toString(36)}.${Math.random().toString(36)}`
messages.value.push({
id,
type,
content,
timeout
timeout,
id: uuid()
})
}