mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
fix:拨号按钮和摄像头按钮增加防抖机制
This commit is contained in:
parent
378d68aba9
commit
041c254ea4
1 changed files with 63 additions and 49 deletions
|
|
@ -99,8 +99,14 @@ 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();
|
||||
|
||||
|
|
@ -122,13 +128,20 @@ class UIController {
|
|||
// Start connection process
|
||||
this.handleConnect();
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
// Camera button
|
||||
const cameraBtn = document.getElementById('cameraBtn');
|
||||
let cameraTimer = null;
|
||||
if (cameraBtn) {
|
||||
cameraBtn.addEventListener('click', () => {
|
||||
if (cameraTimer) {
|
||||
clearTimeout(cameraTimer);
|
||||
cameraTimer = null;
|
||||
}
|
||||
cameraTimer = setTimeout(() => {
|
||||
const cameraContainer = document.getElementById('cameraContainer');
|
||||
if (!cameraContainer) {
|
||||
log('摄像头容器不存在', 'warning');
|
||||
|
|
@ -162,6 +175,7 @@ class UIController {
|
|||
log('startCamera函数未定义', 'warning');
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue