|
@@ -129,28 +129,7 @@ function startCooldown() {
|
|
|
}
|
|
}
|
|
|
const authStore = useAuthStore();
|
|
const authStore = useAuthStore();
|
|
|
|
|
|
|
|
-function playDing() {
|
|
|
|
|
- try {
|
|
|
|
|
- const AudioContext = window.AudioContext || (window as any).webkitAudioContext;
|
|
|
|
|
- if (!AudioContext) return;
|
|
|
|
|
- const ctx = new AudioContext();
|
|
|
|
|
- const osc = ctx.createOscillator();
|
|
|
|
|
- const gainNode = ctx.createGain();
|
|
|
|
|
-
|
|
|
|
|
- osc.type = "sine";
|
|
|
|
|
- osc.frequency.setValueAtTime(880, ctx.currentTime);
|
|
|
|
|
- osc.frequency.exponentialRampToValueAtTime(440, ctx.currentTime + 0.1);
|
|
|
|
|
-
|
|
|
|
|
- gainNode.gain.setValueAtTime(0.3, ctx.currentTime);
|
|
|
|
|
- gainNode.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + 0.3);
|
|
|
|
|
-
|
|
|
|
|
- osc.connect(gainNode);
|
|
|
|
|
- gainNode.connect(ctx.destination);
|
|
|
|
|
-
|
|
|
|
|
- osc.start();
|
|
|
|
|
- osc.stop(ctx.currentTime + 0.3);
|
|
|
|
|
- } catch(e) {}
|
|
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
let ws: WebSocket | null = null;
|
|
let ws: WebSocket | null = null;
|
|
|
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
@@ -198,7 +177,7 @@ function connectWebSocket() {
|
|
|
const myRole = authStore.user?.role === 'admin' ? 'admin' : 'user';
|
|
const myRole = authStore.user?.role === 'admin' ? 'admin' : 'user';
|
|
|
const isMsgFromMe = (msg.is_from_admin && myRole === 'admin') || (!msg.is_from_admin && myRole === 'user');
|
|
const isMsgFromMe = (msg.is_from_admin && myRole === 'admin') || (!msg.is_from_admin && myRole === 'user');
|
|
|
if (!isMsgFromMe) {
|
|
if (!isMsgFromMe) {
|
|
|
- playDing();
|
|
|
|
|
|
|
+ authStore.playChatSound();
|
|
|
ws?.send("read");
|
|
ws?.send("read");
|
|
|
setTimeout(() => authStore.refreshUnreadCount(), 300);
|
|
setTimeout(() => authStore.refreshUnreadCount(), 300);
|
|
|
}
|
|
}
|