From 8fbdcb1e5be7ebe2c5d4f47ac66880eb55d9cda0 Mon Sep 17 00:00:00 2001 From: yarnom Date: Sat, 23 Aug 2025 22:06:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/app.js | 49 +++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index 283ab26..f7fadb2 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -44,28 +44,30 @@ const WeatherApp = { const prevPageBtn = document.getElementById('prevPage'); const nextPageBtn = document.getElementById('nextPage'); - if (showDeviceListBtn && modal) { - showDeviceListBtn.addEventListener('click', (e) => { - e.preventDefault(); - modal.style.display = 'block'; - this.updateDeviceList(1); - }); - } - if (prevPageBtn) { - prevPageBtn.addEventListener('click', () => { - if (this.currentPage > 1) this.updateDeviceList(this.currentPage - 1); - }); - } - if (nextPageBtn) { - nextPageBtn.addEventListener('click', () => { - const totalPages = Math.ceil(this.filteredDevices.length / this.itemsPerPage); - if (this.currentPage < totalPages) this.updateDeviceList(this.currentPage + 1); - }); - } - if (closeBtn && modal) { - closeBtn.addEventListener('click', () => modal.style.display = 'none'); - window.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; }); - } + // 由 Alpine 管理设备列表弹窗开关与分页,不再绑定以下事件 + // if (showDeviceListBtn && modal) { + // showDeviceListBtn.addEventListener('click', (e) => { + // e.preventDefault(); + // modal.style.display = 'block'; + // this.updateDeviceList(1); + // }); + // } + // if (prevPageBtn) { + // prevPageBtn.addEventListener('click', () => { + // if (this.currentPage > 1) this.updateDeviceList(this.currentPage - 1); + // }); + // } + // if (nextPageBtn) { + // nextPageBtn.addEventListener('click', () => { + // const totalPages = Math.ceil(this.filteredDevices.length / this.itemsPerPage); + // if (this.currentPage < totalPages) this.updateDeviceList(this.currentPage + 1); + // }); + // } + // if (closeBtn && modal) { + // closeBtn.addEventListener('click', () => modal.style.display = 'none'); + // window.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; }); + // } + const deviceListEl = document.getElementById('deviceList'); if (deviceListEl && modal) { deviceListEl.addEventListener('click', (e) => { @@ -74,7 +76,8 @@ const WeatherApp = { const decimalId = deviceItem.getAttribute('data-decimal-id'); const input = document.getElementById('stationInput'); if (input) input.value = decimalId; - modal.style.display = 'none'; + // 关闭交给 Alpine: deviceModalOpen = false + window.dispatchEvent(new CustomEvent('close-device-modal')); this.queryHistoryData(); }); }