diff --git a/store/index.js b/store/index.js index 3bdb4c7..8f8a0bd 100644 --- a/store/index.js +++ b/store/index.js @@ -178,14 +178,14 @@ const store = new Vuex.Store({ }, // 推送一条新消息(去重) push_Msg(state, msg) { - // 注:现在的消息没有id,暂时注释 - // if (!msg || !msg.id) return; - // const exists = (state.vuex_msgList || []).some( - // (item) => item && item.id === msg.id - // ); - // if (!exists) { - state.vuex_msgList.push(msg); - // } + // 注:现在的消息没有id,无法去重,暂时用push_MsgList + if (!msg || !msg.id) return; + const exists = (state.vuex_msgList || []).some( + (item) => item && item.id === msg.id + ); + if (!exists) { + state.vuex_msgList.push(msg); + } }, // 插入历史消息到头部 unshift_Msg(state, msg) {