httpsms-gateway / web /app /stores /notifications.ts
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca
Raw History Blame Contribute Delete
938 Bytes
import { defineStore } from 'pinia'
export type NotificationType = 'error' | 'success' | 'info'
export interface Notification {
message: string
timeout: number
active: boolean
type: NotificationType
}
export interface NotificationRequest {
message: string
type: NotificationType
}
const DEFAULT_TIMEOUT = 3000
export const useNotificationsStore = defineStore('notifications', () => {
const notification = ref<Notification>({
active: false,
message: '',
type: 'success',
timeout: DEFAULT_TIMEOUT,
})
function addNotification(request: NotificationRequest) {
notification.value = {
active: true,
message: request.message,
type: request.type,
timeout: Math.floor(Math.random() * 100) + DEFAULT_TIMEOUT,
}
}
function disableNotification() {
notification.value.active = false
}
return {
notification,
addNotification,
disableNotification,
}
})