From fae6db2198ad322d1265d55e240643ed17c97583 Mon Sep 17 00:00:00 2001 From: rainv123 <2148537152@qq.com> Date: Thu, 5 Feb 2026 16:32:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=A7=BB=E9=99=A4=E6=8B=A8?= =?UTF-8?q?=E5=8F=B7=E6=8C=89=E9=92=AE=E9=98=B2=E6=8A=96=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8B=A8=E5=8F=B7=E5=90=8E=E7=A6=81=E7=94=A8=E6=8C=89?= =?UTF-8?q?=E9=92=AE3=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/js/ui/controller.js | 59 +++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/main/xiaozhi-server/test/js/ui/controller.js b/main/xiaozhi-server/test/js/ui/controller.js index 50b000c2..9f79f6b0 100644 --- a/main/xiaozhi-server/test/js/ui/controller.js +++ b/main/xiaozhi-server/test/js/ui/controller.js @@ -13,6 +13,7 @@ class UIController { this.audioStatsTimer = null; this.currentBackgroundIndex = localStorage.getItem('backgroundIndex') ? parseInt(localStorage.getItem('backgroundIndex')) : 0; this.backgroundImages = ['1.png', '2.png', '3.png']; + this.dialBtnDisabled = false; // Bind methods this.init = this.init.bind(this); @@ -99,36 +100,36 @@ class UIController { // Dial button const dialBtn = document.getElementById('dialBtn'); - let dialTimer = null; if (dialBtn) { dialBtn.addEventListener('click', () => { - if (dialTimer) { - clearTimeout(dialTimer); - dialTimer = null; - } - dialTimer = setTimeout(() => { - const wsHandler = getWebSocketHandler(); - const isConnected = wsHandler.isConnected(); + dialBtn.disabled = true; + this.dialBtnDisabled = true; + setTimeout(() => { + dialBtn.disabled = false; + this.dialBtnDisabled = false; + }, 3000); - if (isConnected) { - wsHandler.disconnect(); - this.updateDialButton(false); - this.addChatMessage('Disconnected, see you next time~😊', false); - } else { - // Check if OTA URL is filled - const otaUrlInput = document.getElementById('otaUrl'); - if (!otaUrlInput || !otaUrlInput.value.trim()) { - // If OTA URL is not filled, show settings modal and switch to device tab - this.showModal('settingsModal'); - this.switchTab('device'); - this.addChatMessage('Please fill in OTA server URL', false); - return; - } + const wsHandler = getWebSocketHandler(); + const isConnected = wsHandler.isConnected(); - // Start connection process - this.handleConnect(); + if (isConnected) { + wsHandler.disconnect(); + this.updateDialButton(false); + this.addChatMessage('Disconnected, see you next time~😊', false); + } else { + // Check if OTA URL is filled + const otaUrlInput = document.getElementById('otaUrl'); + if (!otaUrlInput || !otaUrlInput.value.trim()) { + // If OTA URL is not filled, show settings modal and switch to device tab + this.showModal('settingsModal'); + this.switchTab('device'); + this.addChatMessage('Please fill in OTA server URL', false); + return; } - }, 300); + + // Start connection process + this.handleConnect(); + } }); } @@ -618,7 +619,9 @@ class UIController { // Update dial button state const dialBtn = document.getElementById('dialBtn'); if (dialBtn) { - dialBtn.disabled = false; + if (!this.dialBtnDisabled) { + dialBtn.disabled = false; + } dialBtn.querySelector('.btn-text').textContent = '挂断'; dialBtn.classList.add('dial-active'); } @@ -644,7 +647,9 @@ class UIController { // Restore dial button state const dialBtn = document.getElementById('dialBtn'); if (dialBtn) { - dialBtn.disabled = false; + if (!this.dialBtnDisabled) { + dialBtn.disabled = false; + } dialBtn.querySelector('.btn-text').textContent = 'æ‹šć·'; dialBtn.classList.remove('dial-active'); console.log('Dial button state restored successfully');