page.ts 665 B

12345678910111213141516171819202122232425262728293031
  1. import {Alert, pageState} from '~/types/interfaces'
  2. import {defineStore} from "pinia";
  3. import {TYPE_ALERT} from "~/types/enum/enums";
  4. export const usePageStore = defineStore('page', {
  5. state: (): pageState => {
  6. return {
  7. alerts: [],
  8. menusOpened: {}
  9. }
  10. },
  11. actions: {
  12. removeSlowlyAlert () {
  13. setTimeout(() => {
  14. this.alerts.shift()
  15. }, 300)
  16. },
  17. /**
  18. * Ajout des alerts dans le store
  19. * @param type
  20. * @param alerts
  21. */
  22. addAlerts(type: TYPE_ALERT, alerts: Array<string>){
  23. const alert:Alert = {
  24. type: type,
  25. messages: alerts
  26. }
  27. this.alerts.push(alert)
  28. }
  29. }
  30. })