import { fetchLicenseData } from './services/licenseService.js'; import { fetchQueueData } from './services/queueService.js'; import { createLicenseBar } from './components/LicenseBar.js'; import { createQueueDisplay } from './components/QueueDisplay.js'; import { formatDateTime } from './utils/timeFormatter.js'; function updateLastRefreshTime() { const updateTimeElement = document.getElementById('update-time'); updateTimeElement.textContent = `Last Update: ${formatDateTime(new Date())}`; } async function renderChart() { const [licenseData, queueData] = await Promise.all([ fetchLicenseData(), fetchQueueData() ]); const max_duration = licenseData.reduce((max, license) => { return Math.max(max, license.maxDuration); }, 0); // 渲染许可证使用情况 const chartContainer = document.getElementById('chart-container'); chartContainer.innerHTML = ''; licenseData.forEach(license => { const licenseBar = createLicenseBar(license, max_duration); chartContainer.appendChild(licenseBar); }); // 渲染排队情况 const queueContainer = document.getElementById('queue-container'); queueContainer.innerHTML = ''; queueContainer.appendChild(createQueueDisplay(queueData)); updateLastRefreshTime(); } // 初始渲染 renderChart(); // 每1分钟更新一次数据 // setInterval(renderChart, 10000);