user.js 408 B

12345678910111213141516171819202122232425262728
  1. const state = () => ({
  2. userInfo: {},
  3. })
  4. const mutations = {
  5. // 设置用户信息
  6. SET_USER_INFO(state, data) {
  7. state.userInfo = data
  8. },
  9. }
  10. const actions = {
  11. // 退出登录
  12. logout({ commit }) {
  13. commit('SET_USER_INFO', {})
  14. },
  15. // 用户登录
  16. login({ commit }, data) {
  17. commit('SET_USER_INFO', data)
  18. },
  19. }
  20. export default {
  21. namespaced: true,
  22. state,
  23. mutations,
  24. actions,
  25. }