1. 弹幕功能
2. 点赞 3. 导航引导 4. ai弹幕、审核
This commit is contained in:
36
vite-tailwindcss/src/composables/useToast.js
Normal file
36
vite-tailwindcss/src/composables/useToast.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const toasts = ref([])
|
||||
let seq = 0
|
||||
|
||||
function dismiss(id) {
|
||||
toasts.value = toasts.value.filter((t) => t.id !== id)
|
||||
}
|
||||
|
||||
function show(message, type = 'info', duration = 2400) {
|
||||
const text = String(message || '').trim()
|
||||
if (!text) return
|
||||
const id = ++seq
|
||||
toasts.value = [...toasts.value, { id, message: text, type }]
|
||||
if (duration > 0) {
|
||||
setTimeout(() => dismiss(id), duration)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
export function useToast() {
|
||||
return {
|
||||
toasts,
|
||||
dismiss,
|
||||
info: (msg, duration) => show(msg, 'info', duration),
|
||||
success: (msg, duration) => show(msg, 'success', duration),
|
||||
error: (msg, duration) => show(msg, 'error', duration),
|
||||
}
|
||||
}
|
||||
|
||||
export const toast = {
|
||||
info: (msg, duration) => show(msg, 'info', duration),
|
||||
success: (msg, duration) => show(msg, 'success', duration),
|
||||
error: (msg, duration) => show(msg, 'error', duration),
|
||||
dismiss,
|
||||
}
|
||||
Reference in New Issue
Block a user