You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
966 B

  1. import debounce from 'lodash/debounce'
  2. export default {
  3. namespaced: true,
  4. state: {
  5. subtitleShown: false,
  6. subtitleStyle: '',
  7. subtitleIcon: false,
  8. subtitleText: '',
  9. subtitleStatic: 'Welcome'
  10. },
  11. getters: {},
  12. mutations: {
  13. subtitleChange (state, opts) {
  14. state.subtitleShown = (opts.shown === true)
  15. state.subtitleStyle = opts.style || ''
  16. state.subtitleIcon = opts.icon || false
  17. state.subtitleText = opts.msg || ''
  18. },
  19. subtitleStatic (state, text) {
  20. state.subtitleText = text
  21. state.subtitleStatic = text
  22. }
  23. },
  24. actions: {
  25. alert ({ commit, dispatch }, opts) {
  26. opts.shown = true
  27. commit('subtitleChange', opts)
  28. dispatch('alertDismiss')
  29. },
  30. alertDismiss: debounce(({ commit, state }) => {
  31. let opts = {
  32. shown: false,
  33. style: state.subtitleStyle,
  34. msg: state.subtitleStatic
  35. }
  36. commit('subtitleChange', opts)
  37. }, 5000)
  38. }
  39. }