index.js 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import { mutations } from './mutations'
  4. import { actions } from './actions'
  5. import chat from './module/chat'
  6. import group from './module/group/index'
  7. Vue.use(Vuex)
  8. const state = {
  9. scatter: null,
  10. eos: null,
  11. account: '', // eos账户信息
  12. balance: 0, // EOS币
  13. mainnet: EOS_HOST,
  14. gtErrorCount: 0,
  15. eosErrorCount: 0,
  16. publicKey: null, // 用户公钥
  17. userId: '', // 用户登录id
  18. token: '', // 用户登录token
  19. curSession: '', // 当前会话sessionid
  20. userInfo: null // 登录用户信息
  21. }
  22. const getters = {
  23. // 判断是否是私聊
  24. isPrivate: state => {
  25. return /-/g.test(state.curSession)
  26. },
  27. // 私聊时候对方的userId
  28. otherUserId: state => {
  29. if (state.curSession.indexOf('-') > -1) {
  30. return state.curSession.replace('-', '').replace(state.userId, '')
  31. } else {
  32. return ''
  33. }
  34. }
  35. }
  36. export default new Vuex.Store({
  37. state,
  38. mutations,
  39. actions,
  40. getters,
  41. modules: {
  42. chat,
  43. group
  44. }
  45. })