import Vue from 'vue'; import Vuex from 'vuex'; import {createApi} from 'create-api'; import reportError from 'report-error'; import predata from 'common/predata'; import storeYoho from './yoho'; import storeArticle from './article'; import storeUser from './user'; import storeComment from './comment'; import storeProduct from './product'; Vue.use(Vuex); export function createStore(context, state = {}) { const store = new Vuex.Store({ namespaced: true, modules: { yoho: storeYoho(state.yoho), article: storeArticle(), user: storeUser(), comment: storeComment(), product: storeProduct() }, strict: process.env.NODE_ENV !== 'production', }); const api = createApi(context, store); store.$api = api; store.$predata = predata(api); store.$context = context; store.$reportError = reportError(context); return store; }