async function fetchTimestamp() { try { const response = await fetch('/api/demo/timestamp'); const data = await response.json(); if (data.code === 1) { document.getElementById('timestamp').textContent = data.data.timestamp; } else { document.getElementById('timestamp').textContent = '获取失败: ' + data.msg; } } catch (error) { document.getElementById('timestamp').textContent = '请求失败: ' + error.message; } } // 页面加载时获取时间戳 fetchTimestamp();