import Vue from 'vue';
import Vuex from 'vuex';

import permissions from './module/permissions';
import common from './module/common';
import order from './module/order';

Vue.use(Vuex);

const debug = process.env.NODE_ENV !== 'production';

const store = new Vuex.Store({
  strict: debug,
  modules: {
    permissions,
    common,
    order
  }
});

// 刷新页面处理，打开的滚动菜单
let tagnavs = localStorage.getItem('tagnavs');
tagnavs = tagnavs ? JSON.parse(tagnavs) : [];
if (tagnavs.length) {
  tagnavs.forEach(item => {
    store.commit('SET_TAGNAVS', item);
  });

  // 获取缓存页面
  store.dispatch('getCachPage');
}

export default store;
