import Vue from 'vue'
import Vuex from 'vuex'
import Ajax from '../util/ajax'
import api from '../util/api'
import VueClipboard from 'vue-clipboard2'

Vue.use(Vuex)
Vue.use(VueClipboard)

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,
  verification: () => require('./verification/verification').default,
  goodsorder: () => require('./goods/order').default,
  cmscase: () => require('./cms/case').default,
  caserecord: () => require('./case/record').default,
  vip: () => require('./card/vip').default,
  gymcard: () => require('./card/gymCard').default,
  card: () => require('./card/card').default,
  coupon: () => require('./coupon/coupon').default,
  channel: () => require('./channel/channel').default,
  customer: () => require('./customer/customer').default,
  user: () => require('./system/user').default,
  sta: () => require('./sta/sta').default,
  health: () => require('./health/health').default,
  luckDraw: () => require('./luckDraw/luckDraw').default,
  activityLuckDraw: () => require('./activityManager/luckDraw').default,
  activityFlashbuy: () => require('./activityManager/flashbuy').default,
  calendar: () => require('./activityManager/calendar').default,
  library: () => require('./library').default,
}

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

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

export default store
