import Vue from 'vue';
import Vuex from 'vuex';
import getters from './getters';
import app from './modules/app';
import auth from './modules/auth';
import user from './modules/user';
import data from './modules/data';
import order from './modules/order'

import CreatePersistedState from "vuex-persistedstate"
Vue.use(Vuex);

const store = new Vuex.Store({
  getters,
  modules: {
    app,
    auth,
    user,
    data,
    order
  },
  plugins: [
    CreatePersistedState({
      key:'local',
      paths:['app','auth','user','data','order'],
      storage: {
        getItem: key => uni.getStorageSync(key),
        setItem: (key, value) => uni.setStorageSync(key, value),
        removeItem: key => uni.removeStorageSync(key)
      },
    })
  ],
});

export default store;
