{"size": 862, "ext": "js", "max_stars_repo_path": "src/client/store/store.js", "max_stars_repo_name": "liangyihui97/iottp-vue-express", "max_stars_repo_stars_event_min_datetime": "2021-05-13T15:40:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-13T15:40:55.000Z", "max_issues_repo_path": "src/client/store/store.js", "max_issues_repo_name": "liangyihui97/iottp-vue-express", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/client/store/store.js", "max_forks_repo_name": "liangyihui97/iottp-vue-express", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.2972972973, "max_line_length": 88, "alphanum_fraction": 0.5464037123}
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        user: undefined
    },
    mutations: {
        login(state, payload) {
            sessionStorage.setItem("user", JSON.stringify(payload)); //添加到sessionStorage
            sessionStorage.setItem("isLogin", true);
            state.user = payload 
            state.isLogin = true

        },
        logout(state) {
            sessionStorage.removeItem("user"); //移除sessionStorage
            sessionStorage.removeItem("isLogin");
            state.user = ''
            state.isLogin = false
console.log(state.isLogin)
        }
    },
    actions: {
        login(context, payload) {
            context.commit('login', payload)
        },
        logout(context) {
            context.commit('logout')
        }
    }
})

export default store
