// ──────── 優化版渲染邏輯 ──────── async function refreshMarket() { const apiEndpoint = API + '/market-v29'; const container = document.getElementById('market-table-body'); try { const res = await fetch(apiEndpoint); const data = await res.json(); if (!data.ok) throw new Error('API Error'); // 渲染 asset 列表 Object.keys(data.assets).forEach(key => { const item = data.assets[key]; const el = document.getElementById(key + '-val'); if (el) { // 【防誤判機制】若數值異常,顯示同步提示 if (item.val === '---' || item.val === '0.00' || !item.val) { el.innerHTML = '⏳ 同步中...'; } else { el.innerText = item.val; } } }); } catch (e) { console.error("連線異常,保持防禦顯示"); // 發生錯誤時顯示提醒,但不影響網頁其他功能 document.querySelectorAll('.val-field').forEach(el => { el.innerHTML = '⚠️ 連線中'; }); } }