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(); }); }