图表随容器宽度重绘;刷新数据

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
FANGKK
2026-09-10 17:17:58 +08:00
co-authored by Claude Opus 5
parent e77898bc67
commit a183c0976b
2 changed files with 12 additions and 5 deletions
+9 -2
View File
@@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tecdo 消耗与余额</title>
<link rel="icon" href="data:,">
<style>
:root {
color-scheme: light;
@@ -405,8 +406,14 @@ Promise.all([
err.textContent = '数据加载失败:' + e.message;
});
let resizeTimer;
addEventListener('resize', () => { clearTimeout(resizeTimer); resizeTimer = setTimeout(drawCharts, 120); });
let resizeTimer, lastWidth = 0;
new ResizeObserver(entries => {
const w = Math.round(entries[0].contentRect.width);
if (w === lastWidth) return;
lastWidth = w;
clearTimeout(resizeTimer);
resizeTimer = setTimeout(drawCharts, 120);
}).observe(document.querySelector('main'));
</script>
</body>
</html>