import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import tagsView from './modules/tagsView'
import permission from './modules/permission'
import settings from './modules/settings'
import getters from './getters'


import conversation from './modules/conversation'
import group from './modules/group'
import imuser from './modules/imuser'
import video from './modules/video'
import friend from './modules/friend'
import blacklist from './modules/blacklist'
import groupLive from './modules/groupLive'
import {Message} from 'element-ui'



Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    current: Date.now(), // 当前时间
    intervalID: 0,
    message: undefined
  },
  mutations: {
    startComputeCurrent(state) {
      state.intervalID = setInterval(() => {
        state.current = Date.now()
      }, 500)
    },
    stopComputeCurrent(state) {
      clearInterval(state.intervalID)
      state.intervalID = 0
    },
    showMessage(state, options) {
      if (state.message) {
        state.message.close()
      }
      state.message = Message({
        message: options.message,
        type: options.type || 'success',
        duration: options.duration || 2000,
        offset: 40
      })
    }
  },
  modules: {
    app,
    user,
    tagsView,
    permission,
    settings,
	  conversation,
    group,
    friend,
    blacklist,
    imuser,
    video,
    groupLive
  },
  getters
  
})

export default store
