sound.ts 520 B

123456789101112131415161718192021222324
  1. // 声音通知工具函数
  2. export function playNotificationSound() {
  3. try {
  4. const audio = new Audio("/notification.mp3");
  5. audio.volume = 0.5;
  6. audio.play().catch(() => {
  7. // 忽略播放错误(用户可能未交互)
  8. });
  9. } catch (error) {
  10. // 忽略错误
  11. }
  12. }
  13. export function playMessageSound() {
  14. try {
  15. const audio = new Audio("/message.mp3");
  16. audio.volume = 0.3;
  17. audio.play().catch(() => {
  18. // 忽略播放错误
  19. });
  20. } catch (error) {
  21. // 忽略错误
  22. }
  23. }