/*
 * @Description: vue-store 配置文件
 * @Author: Napier
 * @LastEditors: Napier
 * @LastEditorTime:
 */

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

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 登陆状态
    isLogin: false,
    // 是否移动端
    isMobile: false,
    // 用户信息
    user: {
      name: 'Mike',
      uid: null
    }
  },
  mutations: {
    /**
     * @description:用户登入
     * @param {} state:默认形参
     * @param {} msg:用户参数
     * @returns {Void}
     */
    userLogin (state, msg) {
      state.isLogin = true
      state.user.name = msg.name
      state.user.uid = msg.uid
    },

    /**
     * @description:用户登出
     * @param {} state:默认形参
     * @returns {Void}
     */
    userLogout (state) {
      state.isLogin = false
    },

    /**
     * @description:设置为移动端状态
     * @param {} state :默认形参
     */
    setMobile (state) {
      state.isMobile = true
    }
  }
})
