diff --git a/src/js/utils/audio.js b/src/js/utils/audio.js index 0860398..1e7964f 100644 --- a/src/js/utils/audio.js +++ b/src/js/utils/audio.js @@ -3,22 +3,31 @@ import msgSend from '@/assets/audio/msgsend.mp3' import { useUserStore } from '@/stores' const userData = useUserStore() +let playMsgReceiveTimer export const playMsgReceive = () => { if (!userData.user.newMsgTips) { return } - const audio = new Audio(msgReceive) - audio.play().catch(() => { - // do nothing - }) + clearTimeout(playMsgReceiveTimer) + playMsgReceiveTimer = setTimeout(() => { + const audio = new Audio(msgReceive) + audio.play().catch(() => { + // do nothing + }) + }, 300) } +let playMsgSendTimer export const playMsgSend = () => { if (!userData.user.sendMsgTips) { return } - const audio = new Audio(msgSend) - audio.play().catch(() => { - // do nothing - }) + + clearTimeout(playMsgSendTimer) + playMsgSendTimer = setTimeout(() => { + const audio = new Audio(msgSend) + audio.play().catch(() => { + // do nothing + }) + }, 300) } diff --git a/src/views/message/MessageLayout.vue b/src/views/message/MessageLayout.vue index cf1fc7c..49def4a 100644 --- a/src/views/message/MessageLayout.vue +++ b/src/views/message/MessageLayout.vue @@ -673,6 +673,10 @@ const handleSendForwardMsg = async ({ session, content, contentType }) => { const after = (msgId) => { messageData.updateMsg(msg.sessionId, msg.msgId, { msgId, status: msgSendStatus.OK }) + + if (!messageData.sessionList[msg.sessionId].dnd) { + playMsgSend() + } } wsConnect.sendMsg( msg.sessionId,