mirror of
https://github.com/Zippland/worth-calculator.git
synced 2026-01-19 09:41:05 +08:00
访问量debug
This commit is contained in:
@@ -372,12 +372,12 @@ const SalaryCalculator = () => {
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
<span id="busuanzi_container_site_pv" style={{display: 'inline'}}>
|
||||
访问量: <span id="busuanzi_value_site_pv" className="hidden"></span><span id="adjusted_pv">加载中...</span>
|
||||
<span id="busuanzi_container_site_pv" style={{display: 'none'}}>
|
||||
访问量: <span id="busuanzi_value_site_pv" className="hidden"></span><span id="adjusted_pv">--</span>
|
||||
</span>
|
||||
<span className="mx-1">|</span>
|
||||
<span id="busuanzi_container_site_uv" style={{display: 'inline'}}>
|
||||
访客数: <span id="busuanzi_value_site_uv" className="hidden"></span><span id="adjusted_uv">加载中...</span>
|
||||
<span id="busuanzi_container_site_uv" style={{display: 'none'}}>
|
||||
访客数: <span id="busuanzi_value_site_uv" className="hidden"></span><span id="adjusted_uv">--</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -391,36 +391,40 @@ const SalaryCalculator = () => {
|
||||
const historicalPV = 1997500; // 历史PV数据
|
||||
const historicalUV = 580000; // 估算历史UV数据
|
||||
|
||||
// 初始隐藏所有计数器
|
||||
document.getElementById('busuanzi_container_site_pv').style.display = 'none';
|
||||
document.getElementById('busuanzi_container_site_uv').style.display = 'none';
|
||||
|
||||
// 检查并添加历史数据
|
||||
const checkAndUpdateStats = () => {
|
||||
const pvElement = document.getElementById('busuanzi_value_site_pv');
|
||||
const uvElement = document.getElementById('busuanzi_value_site_uv');
|
||||
const adjustedPV = document.getElementById('adjusted_pv');
|
||||
const adjustedUV = document.getElementById('adjusted_uv');
|
||||
const pvContainer = document.getElementById('busuanzi_container_site_pv');
|
||||
const uvContainer = document.getElementById('busuanzi_container_site_uv');
|
||||
|
||||
if (pvElement && pvElement.textContent && pvElement.textContent !== '0') {
|
||||
const currentPV = parseInt(pvElement.textContent, 10) || 0;
|
||||
adjustedPV.textContent = (historicalPV + currentPV).toLocaleString();
|
||||
pvContainer.style.display = 'inline';
|
||||
}
|
||||
|
||||
if (uvElement && uvElement.textContent && uvElement.textContent !== '0') {
|
||||
const currentUV = parseInt(uvElement.textContent, 10) || 0;
|
||||
adjustedUV.textContent = (historicalUV + currentUV).toLocaleString();
|
||||
uvContainer.style.display = 'inline';
|
||||
}
|
||||
|
||||
// 如果尚未加载成功,继续尝试
|
||||
if (adjustedPV.textContent === '加载中...' || adjustedUV.textContent === '加载中...') {
|
||||
if (adjustedPV.textContent === '--' || adjustedUV.textContent === '--') {
|
||||
setTimeout(checkAndUpdateStats, 500);
|
||||
}
|
||||
};
|
||||
|
||||
// 页面加载后开始检查
|
||||
window.addEventListener('load', () => {
|
||||
// 立即显示历史数据
|
||||
document.getElementById('adjusted_pv').textContent = historicalPV.toLocaleString();
|
||||
document.getElementById('adjusted_uv').textContent = historicalUV.toLocaleString();
|
||||
|
||||
// 等待不蒜子加载
|
||||
// 等待不蒜子加载完成
|
||||
setTimeout(checkAndUpdateStats, 1000);
|
||||
});
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user