Browse Source

feat: 通知消息音效提示

wanggaokun 11 months ago
parent
commit
8236575d0e
2 changed files with 6 additions and 0 deletions
  1. BIN
      src/assets/audio/tip.mp3
  2. 6 0
      src/utils/websocket.ts

BIN
src/assets/audio/tip.mp3


+ 6 - 0
src/utils/websocket.ts

@@ -113,6 +113,11 @@ export const sendMsg = (data: any) => {
   websocket.send(data)
   websocket.send(data)
 }
 }
 
 
+const playSound = () => {
+  const audio = new Audio('src/assets/audio/tip.mp3')
+  audio.play()
+}
+
 // socket 接收数据
 // socket 接收数据
 export const websocketOnmessage = () => {
 export const websocketOnmessage = () => {
   websocket.onmessage = function (e: any) {
   websocket.onmessage = function (e: any) {
@@ -137,6 +142,7 @@ export const websocketOnmessage = () => {
       type: 'success',
       type: 'success',
       duration: 3000
       duration: 3000
     })
     })
+    playSound()
     return e.data
     return e.data
   }
   }
 }
 }