= 0 ? 'change-positive' : 'change-negative'}"> ${coin.change >= 0 ? '+' : ''}${coin.change.toFixed(2)}% $${coin.high.toLocaleString('en-US', {minimumFractionDigits: coin.high < 1 ? 4 : 2, maximumFractionDigits: coin.high < 1 ? 4 : 2})} $${coin.low.toLocaleString('en-US', {minimumFractionDigits: coin.low < 1 ? 4 : 2, maximumFractionDigits: coin.low < 1 ? 4 : 2})} ${coin.vol} `).join(''); } // ============ 刷新所有内容 ============ function refreshAll() { // 旋转动画 btnRefresh.classList.add('spinning'); setTimeout(() => { btnRefresh.classList.remove('spinning'); }, 500); renderTitle(); renderKeywords(); renderMarketData(); showToast('🔄 已随机刷新标题和关键词!'); } // ============ 移动端菜单 ============ mobileMenuBtn.addEventListener('click', () => { if (navLinks.style.display === 'flex') { navLinks.style.display = 'none'; mobileMenuBtn.textContent = '☰'; } else { navLinks.style.display = 'flex'; navLinks.style.flexDirection = 'column'; navLinks.style.position = 'absolute'; navLinks.style.top = '100%'; navLinks.style.left = '0'; navLinks.style.right = '0'; navLinks.style.background = 'rgba(10,10,15,0.95)'; navLinks.style.backdropFilter = 'blur(20px)'; navLinks.style.padding = '16px 24px'; navLinks.style.borderBottom = '1px solid var(--border)'; navLinks.style.gap = '4px'; navLinks.style.zIndex = '999'; mobileMenuBtn.textContent = '✕'; } }); // 窗口大小变化时重置菜单 window.addEventListener('resize', () => { if (window.innerWidth > 768) { navLinks.style.display = ''; navLinks.style.flexDirection = ''; navLinks.style.position = ''; navLinks.style.top = ''; navLinks.style.left = ''; navLinks.style.right = ''; navLinks.style.background = ''; navLinks.style.backdropFilter = ''; navLinks.style.padding = ''; navLinks.style.borderBottom = ''; navLinks.style.gap = ''; navLinks.style.zIndex = ''; mobileMenuBtn.textContent = '☰'; } }); // ============ 事件监听 ============ btnRefresh.addEventListener('click', refreshAll); // 关键词标签点击 keywordsContainerEl.addEventListener('click', (e) => { const tag = e.target.closest('.keyword-tag'); if (tag) { const keywordText = tag.textContent.replace(/[→📌🔥💎🚀⭐🎯🏆💡]/g, '').trim(); showToast('🔍 搜索: ' + keywordText); // 模拟:点击后刷新关键词 renderKeywords(); } }); // ============ 初始化 ============ async function init() { // 先用默认数据渲染 renderTitle(); renderKeywords(); renderMarketData(); updateIndicator(); } init(); })();