function toggleSwitch(e) { const rect = e.currentTarget.getBoundingClientRect(); const clickX = e.clientX - rect.left; if (clickX < rect.width / 2) { // 选中时钟 switchBg.style.left = '0'; gridSizeSelect.value=16; } else { // 选中日历 switchBg.style.left = '50%'; gridSizeSelect.value=24; } }