| 123456789101112131415161718192021222324252627282930313233343536 |
- import type {Alert} from '~/types/interfaces'
- import {defineStore} from "pinia";
- import {TYPE_ALERT} from "~/types/enum/enums";
- import {ref} from "@vue/reactivity";
- import type {Ref} from "@vue/reactivity";
- export const usePageStore = defineStore('page', () => {
- const alerts: Ref<Array<Alert>> = ref([])
- const loading: Ref<Boolean> = ref(false)
- const removeSlowlyAlert = () => {
- setTimeout(() => {
- alerts.value.shift()
- }, 300)
- }
- /**
- * Ajout des alerts dans le store
- * @param type
- * @param messages
- */
- const addAlert = (type: TYPE_ALERT, messages: Array<string>) => {
- const alert: Alert = {
- type: type,
- messages: messages
- }
- alerts.value.push(alert)
- }
- return {
- alerts,
- loading,
- removeSlowlyAlert,
- addAlert
- }
- })
|