/* * @Author: ch * @Date: 2022-05-20 11:00:07 * @LastEditors: ch * @LastEditTime: 2022-05-20 11:36:51 * @Description: file content */ import MsbIm from '@/common/plugins/msbIm' ; import $store from '@/common/store'; const Im = new MsbIm({ reconnect: true, }); const ImInit = () => { return Im.init({ url: `wss://k8s-horse-gateway.mashibing.cn/ws?client=${$store.state.token}&type=1` }) }; Im.interceptors.dataChangeAfter = () => { $store.commit('SET_SESSION_DATA', Im.sessionData); let msgCount = 0; Im.sessionData.forEach(i => { msgCount += i.unreadCount; }) $store.commit('SET_SESSION_MSG_COUNT', msgCount); } export { Im, ImInit }