Initial vue frontend

This commit is contained in:
2025-08-12 01:05:59 +02:00
parent 64e50027ca
commit 58e0c10b4e
70 changed files with 16958 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { defineStore } from 'pinia'
import { ref, readonly } from 'vue'
import type { ToastMessage } from '@/types'
export const useToastStore = defineStore('toast', () => {
const toasts = ref<ToastMessage[]>([])
const addToast = (message: string, type: ToastMessage['type'] = 'info', duration = 3000) => {
const id = Date.now().toString()
const toast: ToastMessage = {
id,
message,
type,
duration
}
toasts.value.push(toast)
if (duration > 0) {
setTimeout(() => {
removeToast(id)
}, duration)
}
return id
}
const removeToast = (id: string) => {
const index = toasts.value.findIndex(toast => toast.id === id)
if (index > -1) {
toasts.value.splice(index, 1)
}
}
const clearToasts = () => {
toasts.value = []
}
const success = (message: string, duration?: number) => addToast(message, 'success', duration)
const error = (message: string, duration?: number) => addToast(message, 'error', duration)
const info = (message: string, duration?: number) => addToast(message, 'info', duration)
return {
toasts,
addToast,
removeToast,
clearToasts,
success,
error,
info
}
})