From 280cd3e9946385212dca04ebaa7af0c4269fd231 Mon Sep 17 00:00:00 2001 From: qinglong Date: Sun, 14 Jun 2026 16:30:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20HiChart=E7=94=A8canvas=E8=87=AA=E8=BA=AB?= =?UTF-8?q?getBoundingClientRect=E8=8E=B7=E5=8F=96=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=B0=BA=E5=AF=B8=EF=BC=8C=E6=B6=88=E9=99=A4CSS=E6=8B=89?= =?UTF-8?q?=E4=BC=B8=E5=AF=BC=E8=87=B4=E7=9A=84=E7=BA=BF=E6=9D=A1=E5=8F=98?= =?UTF-8?q?=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/sentinel/dashboard.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sentinel/dashboard.html b/plugins/sentinel/dashboard.html index a1a33e0..47c84e7 100644 --- a/plugins/sentinel/dashboard.html +++ b/plugins/sentinel/dashboard.html @@ -157,12 +157,12 @@ window.addEventListener('resize', function(){ self._resize(); }); } HiChart.prototype._resize = function() { - var rect = this.canvas.parentElement.getBoundingClientRect(); - var w = Math.max(rect.width - 8, 100); - var h = 60; + // 用 canvas 自身的 CSS 渲染尺寸 → 内部分辨率 = CSS尺寸 × DPR (保持高清) + var box = this.canvas.getBoundingClientRect(); + var w = box.width, h = box.height; + if (w <= 0 || h <= 0) { w = 280; h = 60; } // fallback this.canvas.width = w * this._dpr; this.canvas.height = h * this._dpr; - // CSS controls display size via width:100%;height:60px this.ctx.setTransform(this._dpr, 0, 0, this._dpr, 0, 0); this._draw(); };