import * as types from '../types' import { getStore, setStore } from '@js/mUtils.js' const state = { accountId: getStore('accountId') || '', accountName: getStore('accountName') || '', userName: getStore('userName') || '', deptUuid: getStore('deptUuid') || '' } const getters = { accountId: state => state.accountId, accountName: state => state.accountName, userName: state => state.userName, deptUuid: state => state.deptUuid } const actions = { setUserInfo ({ commit }, res) { setStore('accountId', res.account_id) setStore('accountName', res.account_name) setStore('userName', res.user_name) setStore('deptUuid', res.dept_uuid) commit(types.SET_USER_INFO, res) }, setSignOut ({ commit }) { localStorage.removeItem('accountId') localStorage.removeItem('userName') localStorage.removeItem('accountName') localStorage.removeItem('deptUuid') commit(types.SET_SIGN_OUT) } } const mutations = { [types.SET_USER_INFO] (state, res) { state.accountId = res.account_id state.accountName = res.account_name state.userName = res.user_name state.memberName = res.member_name }, [types.SET_SIGN_OUT] (state) { state.accountId = '' } } export default { state, getters, actions, mutations }