import Vue from 'vue'
import Vuex from 'vuex'
import styles from './modules/styles'
import createMultiTabState from 'vuex-multi-tab-state'; // 多个tab 共享vuex
Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        aside_collapsed: false,
        userInfo: JSON.parse(localStorage.getItem('userInfo') || '{}')
    },
    getters:{
        styles: (state) => state.styles.data,
        getAside_collapsed(state){
            return  state.aside_collapsed
        },
    },
    mutations: {
        // 通用修改
        setState(state, object) {
            for (let key in object) {
                state[key] = object[key]
            }
        },
        aside_collapsed(state,val){
            state.aside_collapsed = val
        },
    },
    actions: {},
    modules: {
        styles
    },
    plugins: [
        createMultiTabState()
    ]
})
