import Vue from 'vue'
import Vuex from 'vuex'
import Ajax from '../util/ajax'
import api from '../util/api'
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    loadding: false,
    pageSize: 10
  }
})
Vuex.Store.prototype.$api = api
Vuex.Store.prototype.$ajax = Ajax
export const modules = {
  app: () => require('./app').default,
  prize: () => require('./prize').default
}

Object.keys(modules).forEach((modKey) => {
  const modNS = modKey.split('/')
  const getMod = modules[modKey]
  store.registerModule(...modNS, getMod())
})

export default store
