index.js 869 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import { mutations } from './mutations'
  4. import { actions } from './actions'
  5. import { initBaseState } from './state'
  6. import chat from './module/chat/index'
  7. import group from './module/group/index'
  8. Vue.use(Vuex)
  9. const state = initBaseState()
  10. const getters = {
  11. // 判断是否是私聊
  12. isPrivate: state => {
  13. return /-/g.test(state.curSession)
  14. },
  15. // 私聊时候对方的userId
  16. otherUserId: state => {
  17. if (!state.curSession) return
  18. if (state.curSession.indexOf('-') > -1) {
  19. return state.curSession.replace('-', '').replace(state.userId, '')
  20. } else {
  21. return ''
  22. }
  23. },
  24. muteList: state => {
  25. return state.chat.sessionList.filter(item => item.is_mute == 1)
  26. }
  27. }
  28. export default new Vuex.Store({
  29. state,
  30. mutations,
  31. actions,
  32. getters,
  33. modules: {
  34. chat,
  35. group
  36. }
  37. })