perf(页面加载): 优化价格显示性能并添加加载状态处理

- 改用DOMContentLoaded事件提前初始化页面
- 实现渐进式价格显示:基础价格→加载中→实时价格
- 为fetchVisitData添加超时和重试机制
- 新增价格状态视觉区分样式
- 从2分钟等待优化为立即显示基础价格,后台异步更新
This commit is contained in:
2025-08-17 14:49:06 +08:00
parent 9653a70dad
commit 9e8a88274d
3 changed files with 207 additions and 21 deletions

View File

@@ -48,6 +48,46 @@ main {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
}
/* 价格状态样式 */
.base-price {
color: #666 !important;
font-style: italic;
position: relative;
}
.base-price::after {
content: " (基础价格)";
font-size: 0.8em;
color: #999;
font-weight: normal;
}
.loading-price {
color: #007bff !important;
animation: pulse 1.5s ease-in-out infinite;
font-weight: 500;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.6; }
100% { opacity: 1; }
}
.real-time-price {
color: #28a745 !important;
font-weight: bold;
position: relative;
}
.real-time-price::after {
content: " (实时价格)";
font-size: 0.8em;
color: #28a745;
font-weight: normal;
opacity: 0.8;
margin-bottom: 3rem;
}
@@ -465,4 +505,4 @@ footer {
font-size: 0.9em;
font-weight: normal;
margin-top: 4px;
}
}