import Vue from 'vue' import Vuex from 'vuex' import { mutations } from './mutations' import { actions } from './actions' import chat from './module/chat' import group from './module/group/index' Vue.use(Vuex) const state = { scatter: null, eos: null, account: '', // eos账户信息 balance: 0, // EOS币 mainnet: EOS_HOST, gtErrorCount: 0, eosErrorCount: 0, publicKey: null, // 用户公钥 userId: '', // 用户登录id token: '', // 用户登录token curSession: '', // 当前会话sessionid userInfo: null // 登录用户信息 } const getters = { // 判断是否是私聊 isPrivate: state => { return /-/g.test(state.curSession) }, // 私聊时候对方的userId otherUserId: state => { if (state.curSession.indexOf('-') > -1) { return state.curSession.replace('-', '').replace(state.userId, '') } else { return '' } } } export default new Vuex.Store({ state, mutations, actions, getters, modules: { chat, group } })