From aa0cd0c449dce1b716e4f80208f4cd26ac1a9139 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Wed, 3 Jun 2026 17:10:33 +0900 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=20=D1=81=D0=BE=D0=BA=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=D0=B7=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/bootstrap.js | 26 +++++++++++++++++++++----- resources/views/app.blade.php | 11 ++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index c9905c5..12684ef 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -6,17 +6,33 @@ import {startGlobalLoading, stopGlobalLoading} from "./Composables/useGlobalLoad window.axios = axios; window.Pusher = Pusher; +let reverbFailCount = 0; +const MAX_REVERB_FAILS = 3; + window.Echo = new Echo({ broadcaster: 'reverb', - key: import.meta.env.VITE_REVERB_APP_KEY, - wsHost: import.meta.env.VITE_REVERB_HOST, - wsPort: import.meta.env.VITE_REVERB_PORT ?? 8080, - wssPort: import.meta.env.VITE_REVERB_PORT ?? 8080, - forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'http') === 'https', + key: window.reverb.key, + wsHost: window.reverb.host, + wsPort: window.reverb.port ?? 8080, + wssPort: window.reverb.port ?? 8080, + forceTLS: (window.reverb.scheme ?? 'http') === 'https', enabledTransports: ['ws', 'wss'], withCredentials: true, }); +window.Echo.connector.pusher.connection.bind('failed', () => { + reverbFailCount++; + if (reverbFailCount >= MAX_REVERB_FAILS) { + console.warn('Reverb недоступен, отключаем WebSocket'); + window.Echo.disconnect(); + } +}); + +window.Echo.connector.pusher.connection.bind('unavailable', () => { + console.warn('Reverb недоступен'); + window.Echo.disconnect(); +}); + window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; window.axios.defaults.withCredentials = true window.axios.defaults.withXSRFToken = true; diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index f4bbba5..8cb9796 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -1,4 +1,4 @@ - + @@ -6,6 +6,15 @@ {{ config('app.name', 'Laravel') }} + + @if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot'))) @vite(['resources/js/app.js'])