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,
  cms: () => require('./cms').default,
  role: () => require('./system/role').default,
  device: () => require('./case/device').default,
  goods: () => require('./goods/goods').default,
  course: () => require('./course/course').default,
  coursetag: () => require('./course/tag').default,
  schedule: () => require('./course/schedule').default,
}

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

  store.registerModule(...modNS, getMod())
})

export default store
