import { createStore } from "vuex"
// 引入持久化
import createPersistedState from 'vuex-persistedstate';

const store = createStore({
    state: {
        currentPath: '',
        userInfo: {}
    },
    mutations: {
        updateCurrentPath(state, path) {
            state.currentPath = path
        },
        setUserInfo(state, data) {
            console.log(123, data);
            state.userInfo = data;
        }
    },
    actions: {
        updateCurrentPath({ commit }, path) {
            commit('updateCurrentPath', path)
        }
    },
    modules: {},
    getters: {
        getCurrentPath(state) {
            return state.currentPath;
        }
    },
    plugins: [
        createPersistedState({
            key: 'vuex', 
            storage: window.localStorage
        })
    ]
})
export default store