config.js 787 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import PersistedState from '../PersistedState'
  2. // initial state
  3. import { getConfigList } from '../../api/config'
  4. const state = {
  5. config: PersistedState.getStorage('config','config')
  6. }
  7. // mutations
  8. const mutations = {
  9. configSave (state, payload) {
  10. state.config = payload
  11. PersistedState.setStorage('config',state)
  12. }
  13. }
  14. // actions
  15. const actions = {
  16. fetchConfig ({ commit, state }) {
  17. return new Promise((resolve, reject) => {
  18. getConfigList().then(
  19. (response) => {
  20. if (response.result && response.result.config_list) {
  21. commit('configSave', response.result.config_list)
  22. }
  23. resolve(response)
  24. }, (error) => {
  25. reject(error)
  26. })
  27. })
  28. }
  29. }
  30. export default {
  31. state,
  32. mutations,
  33. actions
  34. }