Files
indee-demo/src/composables/useToast.ts
Dorian c970f5b29f Enhance deployment script and update package dependencies
- Added detailed labels to the deployment script for IndeedHub, including title, version, description, license, icon, and repository URL.
- Updated package dependencies in package.json and package-lock.json, including upgrading 'nostr-tools' to version 2.23.0 and adding 'axios' and '@tanstack/vue-query'.
- Improved README with a modern description of the platform and updated project structure details.

This commit enhances the clarity of the deployment process and ensures the project is using the latest dependencies for better performance and features.
2026-02-12 10:30:47 +00:00

74 lines
1.4 KiB
TypeScript

import { ref } from 'vue'
interface Toast {
id: number
message: string
type: 'success' | 'error' | 'info' | 'warning'
duration: number
}
/**
* Toast Notification Composable
* Displays glassmorphic toast notifications
*/
export function useToast() {
const toasts = ref<Toast[]>([])
let nextId = 0
function showToast(
message: string,
type: Toast['type'] = 'info',
duration: number = 3000
) {
const toast: Toast = {
id: nextId++,
message,
type,
duration,
}
toasts.value.push(toast)
if (duration > 0) {
setTimeout(() => {
removeToast(toast.id)
}, duration)
}
return toast.id
}
function removeToast(id: number) {
const index = toasts.value.findIndex((t) => t.id === id)
if (index > -1) {
toasts.value.splice(index, 1)
}
}
function success(message: string, duration?: number) {
return showToast(message, 'success', duration)
}
function error(message: string, duration?: number) {
return showToast(message, 'error', duration)
}
function info(message: string, duration?: number) {
return showToast(message, 'info', duration)
}
function warning(message: string, duration?: number) {
return showToast(message, 'warning', duration)
}
return {
toasts,
showToast,
removeToast,
success,
error,
info,
warning,
}
}