You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
631 B
29 lines
631 B
import Vue from "vue";
|
|
import Vuex from "vuex";
|
|
|
|
Vue.use(Vuex);
|
|
const files = require.context("./modules", false, /\.js$/);
|
|
let modules = {
|
|
state: {},
|
|
mutations: {},
|
|
actions: {},
|
|
};
|
|
|
|
files.keys().forEach((key) => {
|
|
const moduleName = key.replace(/(\.\/|\.js)/g, '');
|
|
const module = files(key).default || files(key);
|
|
|
|
if (module.state) {
|
|
Object.assign(modules.state, module.state);
|
|
}
|
|
if (module.mutations) {
|
|
Object.assign(modules.mutations, module.mutations);
|
|
}
|
|
if (module.actions) {
|
|
Object.assign(modules.actions, module.actions);
|
|
}
|
|
});
|
|
|
|
const store = new Vuex.Store(modules);
|
|
export default store;
|
|
|
|
|