From 7cdae4d954370496e7815a3f4db3b7cfec2fcebb Mon Sep 17 00:00:00 2001 From: qinglong Date: Sun, 14 Jun 2026 09:58:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Windows=E5=88=86=E5=8C=BA=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=90=8D=20=E2=80=94=20=E7=94=A8=E7=9B=98=E7=AC=A6(C:?= =?UTF-8?q?)=E6=9B=BF=E4=BB=A3=E8=AE=BE=E5=A4=87=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web_panel/utils/system_info.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/web_panel/utils/system_info.py b/services/web_panel/utils/system_info.py index ae16f87..d654c1e 100644 --- a/services/web_panel/utils/system_info.py +++ b/services/web_panel/utils/system_info.py @@ -154,8 +154,12 @@ class SystemInfoCollector: continue try: usage = self.psutil.disk_usage(p.mountpoint) + # Windows: 用盘符作为设备名 (C:, D:) + dev = p.device + if os.name == 'nt': + dev = p.mountpoint.rstrip('\\') # C:\ → C: parts.append({ - "device": p.device, + "device": dev, "mount": p.mountpoint, "fstype": p.fstype or "", "total_gb": round(usage.total / 1073741824, 1), @@ -163,8 +167,11 @@ class SystemInfoCollector: "percent": usage.percent, }) except (PermissionError, OSError): + dev = p.device + if os.name == 'nt': + dev = p.mountpoint.rstrip('\\') parts.append({ - "device": p.device, + "device": dev, "mount": p.mountpoint, "fstype": p.fstype or "", "total_gb": 0, "used_gb": 0, "percent": 0,