universal-runtime: fix overlay hiding error messages on reconnect
This commit is contained in:
@@ -86,25 +86,22 @@ cat > /opt/portal/index.html <<'HTML'
|
||||
const MAX_RECONNECT_ATTEMPTS = 12;
|
||||
const RECONNECT_DELAYS_MS = [1000, 2000, 3000, 5000, 8000];
|
||||
let manualDisconnect = false;
|
||||
|
||||
function showOverlay() {
|
||||
coEl.style.opacity = '1';
|
||||
coEl.style.display = 'flex';
|
||||
coEl.classList.remove('hidden');
|
||||
statusEl.style.display = 'none';
|
||||
}
|
||||
let overlayHidden = false;
|
||||
|
||||
function hideOverlay() {
|
||||
if (overlayHidden) return;
|
||||
overlayHidden = true;
|
||||
coEl.classList.add('hidden');
|
||||
setTimeout(() => { coEl.style.display = 'none'; }, 520);
|
||||
}
|
||||
|
||||
function showError(text) {
|
||||
hideOverlay();
|
||||
statusEl.textContent = text;
|
||||
statusEl.style.display = 'block';
|
||||
}
|
||||
|
||||
function hideError() { statusEl.style.display = 'none'; }
|
||||
|
||||
function clearConnectTimer() {
|
||||
if (connectTimer) { clearTimeout(connectTimer); connectTimer = null; }
|
||||
}
|
||||
@@ -129,6 +126,7 @@ cat > /opt/portal/index.html <<'HTML'
|
||||
clearConnectTimer();
|
||||
clearReconnectTimer();
|
||||
if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
|
||||
hideOverlay();
|
||||
showError('Соединение потеряно. Переподключение не удалось. Откройте сервис заново.');
|
||||
return;
|
||||
}
|
||||
@@ -137,6 +135,7 @@ cat > /opt/portal/index.html <<'HTML'
|
||||
showError(\`\${reasonText} Повтор \${nextAttempt}/\${MAX_RECONNECT_ATTEMPTS} через \${Math.ceil(delayMs/1000)} сек.\`);
|
||||
reconnectTimer = setTimeout(() => {
|
||||
reconnectAttempts = nextAttempt;
|
||||
hideError();
|
||||
connectRfb();
|
||||
}, delayMs);
|
||||
}
|
||||
@@ -153,6 +152,7 @@ cat > /opt/portal/index.html <<'HTML'
|
||||
clearConnectTimer();
|
||||
clearReconnectTimer();
|
||||
hideOverlay();
|
||||
hideError();
|
||||
});
|
||||
rfb.addEventListener('disconnect', () => {
|
||||
connected = false;
|
||||
@@ -164,7 +164,6 @@ cat > /opt/portal/index.html <<'HTML'
|
||||
function connectRfb() {
|
||||
if (manualDisconnect) return;
|
||||
connected = false;
|
||||
showOverlay();
|
||||
attachRfb();
|
||||
scheduleConnectTimeout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user