mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
fix:移除拨号按钮防抖,点击拨号后禁用按钮3秒
This commit is contained in:
parent
32aea32e2c
commit
fae6db2198
1 changed files with 32 additions and 27 deletions
|
|
@ -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,14 +100,15 @@ 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(() => {
|
||||
dialBtn.disabled = true;
|
||||
this.dialBtnDisabled = true;
|
||||
setTimeout(() => {
|
||||
dialBtn.disabled = false;
|
||||
this.dialBtnDisabled = false;
|
||||
}, 3000);
|
||||
|
||||
const wsHandler = getWebSocketHandler();
|
||||
const isConnected = wsHandler.isConnected();
|
||||
|
||||
|
|
@ -128,7 +130,6 @@ class UIController {
|
|||
// Start connection process
|
||||
this.handleConnect();
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -618,7 +619,9 @@ class UIController {
|
|||
// Update dial button state
|
||||
const dialBtn = document.getElementById('dialBtn');
|
||||
if (dialBtn) {
|
||||
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) {
|
||||
if (!this.dialBtnDisabled) {
|
||||
dialBtn.disabled = false;
|
||||
}
|
||||
dialBtn.querySelector('.btn-text').textContent = '拨号';
|
||||
dialBtn.classList.remove('dial-active');
|
||||
console.log('Dial button state restored successfully');
|
||||
|
|
|
|||
Loading…
Reference in a new issue