feat: 优化前端页面架构
This commit is contained in:
parent
29a3e9305b
commit
8fbdcb1e5b
@ -44,28 +44,30 @@ const WeatherApp = {
|
|||||||
const prevPageBtn = document.getElementById('prevPage');
|
const prevPageBtn = document.getElementById('prevPage');
|
||||||
const nextPageBtn = document.getElementById('nextPage');
|
const nextPageBtn = document.getElementById('nextPage');
|
||||||
|
|
||||||
if (showDeviceListBtn && modal) {
|
// 由 Alpine 管理设备列表弹窗开关与分页,不再绑定以下事件
|
||||||
showDeviceListBtn.addEventListener('click', (e) => {
|
// if (showDeviceListBtn && modal) {
|
||||||
e.preventDefault();
|
// showDeviceListBtn.addEventListener('click', (e) => {
|
||||||
modal.style.display = 'block';
|
// e.preventDefault();
|
||||||
this.updateDeviceList(1);
|
// modal.style.display = 'block';
|
||||||
});
|
// this.updateDeviceList(1);
|
||||||
}
|
// });
|
||||||
if (prevPageBtn) {
|
// }
|
||||||
prevPageBtn.addEventListener('click', () => {
|
// if (prevPageBtn) {
|
||||||
if (this.currentPage > 1) this.updateDeviceList(this.currentPage - 1);
|
// prevPageBtn.addEventListener('click', () => {
|
||||||
});
|
// if (this.currentPage > 1) this.updateDeviceList(this.currentPage - 1);
|
||||||
}
|
// });
|
||||||
if (nextPageBtn) {
|
// }
|
||||||
nextPageBtn.addEventListener('click', () => {
|
// if (nextPageBtn) {
|
||||||
const totalPages = Math.ceil(this.filteredDevices.length / this.itemsPerPage);
|
// nextPageBtn.addEventListener('click', () => {
|
||||||
if (this.currentPage < totalPages) this.updateDeviceList(this.currentPage + 1);
|
// 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');
|
// if (closeBtn && modal) {
|
||||||
window.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; });
|
// closeBtn.addEventListener('click', () => modal.style.display = 'none');
|
||||||
}
|
// window.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; });
|
||||||
|
// }
|
||||||
|
|
||||||
const deviceListEl = document.getElementById('deviceList');
|
const deviceListEl = document.getElementById('deviceList');
|
||||||
if (deviceListEl && modal) {
|
if (deviceListEl && modal) {
|
||||||
deviceListEl.addEventListener('click', (e) => {
|
deviceListEl.addEventListener('click', (e) => {
|
||||||
@ -74,7 +76,8 @@ const WeatherApp = {
|
|||||||
const decimalId = deviceItem.getAttribute('data-decimal-id');
|
const decimalId = deviceItem.getAttribute('data-decimal-id');
|
||||||
const input = document.getElementById('stationInput');
|
const input = document.getElementById('stationInput');
|
||||||
if (input) input.value = decimalId;
|
if (input) input.value = decimalId;
|
||||||
modal.style.display = 'none';
|
// 关闭交给 Alpine: deviceModalOpen = false
|
||||||
|
window.dispatchEvent(new CustomEvent('close-device-modal'));
|
||||||
this.queryHistoryData();
|
this.queryHistoryData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user