fix: 市场交易时间
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
*.log
|
||||
. *
|
||||
logs/*
|
||||
.*
|
||||
@@ -62,6 +62,9 @@
|
||||
// 关闭公告的函数
|
||||
function closeAnnouncement() {
|
||||
const container = document.getElementById('announcement-container');
|
||||
if(!container){
|
||||
return;
|
||||
}
|
||||
container.style.opacity = '0';
|
||||
container.style.transform = 'translateY(-10px)';
|
||||
container.style.transition = 'all 0.3s ease-out';
|
||||
@@ -111,7 +114,7 @@
|
||||
|
||||
<script>
|
||||
// 更新时间显示
|
||||
function updateTime() {
|
||||
function updateMarketTime() {
|
||||
const now = new Date();
|
||||
|
||||
// 更新当前时间
|
||||
@@ -157,7 +160,21 @@
|
||||
const timer = document.getElementById(`${market}MarketTimer`);
|
||||
|
||||
if (isOpen) {
|
||||
// ... 现有的开市逻辑保持不变 ...
|
||||
element.textContent = '交易中';
|
||||
element.className = 'text-lg font-medium text-green-600';
|
||||
|
||||
// 计算距离收盘时间
|
||||
const now = new Date();
|
||||
const closeTime = new Date(now);
|
||||
closeTime.setHours(closeHour, closeMinute, 0);
|
||||
|
||||
const timeToClose = closeTime - now;
|
||||
const hours = Math.floor(timeToClose / 3600000);
|
||||
const minutes = Math.floor((timeToClose % 3600000) / 60000);
|
||||
|
||||
if (hours >= 0 && minutes >= 0) {
|
||||
timer.textContent = `距离收盘还有 ${hours}小时${minutes}分钟`;
|
||||
}
|
||||
} else {
|
||||
element.textContent = '已休市';
|
||||
element.className = 'text-lg font-medium text-gray-600';
|
||||
@@ -200,8 +217,8 @@
|
||||
}
|
||||
|
||||
// 每秒更新一次时间
|
||||
setInterval(updateTime, 1000);
|
||||
updateTime(); // 立即执行一次
|
||||
setInterval(updateMarketTime, 1000);
|
||||
updateMarketTime(); // 立即执行一次
|
||||
</script>
|
||||
|
||||
<div class="max-w-4xl mx-auto">
|
||||
|
||||
Reference in New Issue
Block a user