|
@@ -32,30 +32,7 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
let pingInterval: number | null = null;
|
|
let pingInterval: number | null = null;
|
|
|
const unreadMessagesCount = ref(0);
|
|
const unreadMessagesCount = ref(0);
|
|
|
|
|
|
|
|
- function playNotificationSound() {
|
|
|
|
|
- try {
|
|
|
|
|
- const AudioCtx = window.AudioContext || (window as any).webkitAudioContext;
|
|
|
|
|
- if (!AudioCtx) return;
|
|
|
|
|
- const ctx = new AudioCtx();
|
|
|
|
|
- const osc = ctx.createOscillator();
|
|
|
|
|
- const gainNode = ctx.createGain();
|
|
|
|
|
-
|
|
|
|
|
- osc.type = 'sine';
|
|
|
|
|
- osc.frequency.setValueAtTime(880, ctx.currentTime); // A5
|
|
|
|
|
- osc.frequency.exponentialRampToValueAtTime(1760, ctx.currentTime + 0.1); // Up to A6
|
|
|
|
|
-
|
|
|
|
|
- gainNode.gain.setValueAtTime(0, ctx.currentTime);
|
|
|
|
|
- gainNode.gain.linearRampToValueAtTime(0.1, ctx.currentTime + 0.05);
|
|
|
|
|
- gainNode.gain.linearRampToValueAtTime(0, ctx.currentTime + 0.2);
|
|
|
|
|
-
|
|
|
|
|
- osc.connect(gainNode);
|
|
|
|
|
- gainNode.connect(ctx.destination);
|
|
|
|
|
- osc.start();
|
|
|
|
|
- osc.stop(ctx.currentTime + 0.2);
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.warn("Audio disabled or not supported", e);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
let globalWs: WebSocket | null = null;
|
|
let globalWs: WebSocket | null = null;
|
|
|
let reconnectTimer: number | null = null;
|
|
let reconnectTimer: number | null = null;
|
|
@@ -106,6 +83,32 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
console.warn("Audio update sound error", e);
|
|
console.warn("Audio update sound error", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ async function playNotificationSound() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const ctx = getAudioCtx();
|
|
|
|
|
+ if (!ctx) return;
|
|
|
|
|
+ if (ctx.state === 'suspended') await ctx.resume();
|
|
|
|
|
+
|
|
|
|
|
+ const osc = ctx.createOscillator();
|
|
|
|
|
+ const gainNode = ctx.createGain();
|
|
|
|
|
+
|
|
|
|
|
+ osc.type = 'sine';
|
|
|
|
|
+ osc.frequency.setValueAtTime(880, ctx.currentTime); // A5
|
|
|
|
|
+ osc.frequency.exponentialRampToValueAtTime(1760, ctx.currentTime + 0.1); // Up to A6
|
|
|
|
|
+
|
|
|
|
|
+ gainNode.gain.setValueAtTime(0, ctx.currentTime);
|
|
|
|
|
+ gainNode.gain.linearRampToValueAtTime(0.1, ctx.currentTime + 0.05);
|
|
|
|
|
+ gainNode.gain.linearRampToValueAtTime(0, ctx.currentTime + 0.2);
|
|
|
|
|
+
|
|
|
|
|
+ osc.connect(gainNode);
|
|
|
|
|
+ gainNode.connect(ctx.destination);
|
|
|
|
|
+ osc.start();
|
|
|
|
|
+ osc.stop(ctx.currentTime + 0.2);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.warn("Audio notification sound error", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// ───────────────────────────────────────────────────────────────────────────
|
|
// ───────────────────────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
function startPing() {
|
|
function startPing() {
|