import { createStore } from 'vuex'
import getters from './getters'

// 动态导入所有 modules
const modulesFiles = import.meta.glob('./modules/*.js', { eager: true })

const modules = {}
for (const path in modulesFiles) {
  const moduleName = path.replace(/(\.\/modules\/|\.js$)/g, '')
  modules[moduleName] = modulesFiles[path].default
}

const store = createStore({
  modules,
  getters
})

export default store
