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.
30 lines
631 B
30 lines
631 B
1 year ago
|
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;
|
||
|
|