index.js 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import _ from 'lodash'
  2. import Vue from 'vue'
  3. import Vuex from 'vuex'
  4. Vue.use(Vuex)
  5. export default new Vuex.Store({
  6. state: {
  7. loadingStack: [],
  8. notification: {
  9. message: '',
  10. style: 'primary',
  11. icon: 'cached',
  12. isActive: false
  13. }
  14. },
  15. getters: {
  16. isLoading: state => { return state.loadingStack.length > 0 }
  17. },
  18. mutations: {
  19. loadingStart (state, stackName) {
  20. state.loadingStack = _.union(state.loadingStack, [stackName])
  21. },
  22. loadingStop (state, stackName) {
  23. state.loadingStack = _.without(state.loadingStack, stackName)
  24. },
  25. showNotification (state, opts) {
  26. state.notification = _.defaults(opts, {
  27. message: '',
  28. style: 'primary',
  29. icon: 'cached',
  30. isActive: true
  31. })
  32. },
  33. updateNotificationState (state, newState) {
  34. state.notification.isActive = newState
  35. }
  36. },
  37. actions: { },
  38. modules: { }
  39. })