feat: 打开页面立即显示公网 IP 与地区(无需等测速完成)

This commit is contained in:
dsh
2026-08-17 23:13:54 -04:00
parent 575b5be0bf
commit 9cccbba3bd
+7 -8
View File
@@ -557,14 +557,7 @@ async function runTest() {
updateGaugeSpeed(upload);
markDone(document.getElementById('cardUpload'));
// 4. 展示 IP 与地区(页面上方徽标;排行榜不展示 IP
try {
const pr = await fetch('/api/ping?t=' + Date.now(), { cache: 'no-store' });
const pi = await pr.json();
showMyIP(pi.client_ip || '', pi.location || '');
} catch (e) { /* ignore */ }
// 5. 提交(记录我的成绩 ID,用于排行榜高亮)
// 4. 提交(记录我的成绩 ID,用于排行榜高亮
setPhase('正在提交结果…');
const res = await submitResult({ latency, jitter, download, upload });
if (res && res.id) {
@@ -589,6 +582,12 @@ startBtn.addEventListener('click', runTest);
drawGauge(0);
updateSortHeaders();
loadRankings();
// 打开页面立即显示 IP 与地区(无需等待测速)
fetch('/api/ping?t=' + Date.now(), { cache: 'no-store' })
.then(r => r.json())
.then(d => showMyIP(d.client_ip || '', d.location || ''))
.catch(() => { /* 网络异常时静默,徽标保持隐藏 */ });
</script>
</body>
</html>