feat: 磁盘分区列 — 多分区/进度条/overflow/过滤虚拟FS

SystemInfoCollector:
- _get_partitions(): psutil disk_partitions + 过滤虚拟FS
- 跳过 tmpfs/devtmpfs/proc/sysfs/cgroup等22种
- 无psutil时 fallback到根分区

前端4列: 160px 1fr 0.8fr 1fr
- col-disk: 分区名/挂载点/进度条/百分比
- max-height:200px overflow:auto
- 跨平台兼容

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-14 09:31:52 +08:00
parent 095f6c765c
commit 528410d3e9
2 changed files with 80 additions and 4 deletions
+48
View File
@@ -66,6 +66,7 @@ class SystemInfoCollector:
"memory": self._get_memory(),
"swap": self._get_swap(),
"disk": self._get_disk(),
"partitions": self._get_partitions(),
"process": self._get_process(),
"network": self._get_network(),
"net_speed": self._get_network_speed(),
@@ -137,6 +138,53 @@ class SystemInfoCollector:
pass
return {"total_gb": 0, "used_gb": 0, "percent": 0}
_SKIP_FS = {'tmpfs', 'devtmpfs', 'devfs', 'overlay', 'squashfs', 'proc', 'sysfs',
'cgroup', 'cgroup2', 'debugfs', 'tracefs', 'fusectl', 'configfs',
'securityfs', 'pstore', 'efivarfs', 'autofs', 'ramfs', 'hugetlbfs',
'mqueue', 'bpf', 'binfmt_misc', 'rpc_pipefs', 'nfsd', 'smb3fs_ctl',
'snapfuse', 'fuse.gvfsd-fuse', 'fuse.portal'}
def _get_partitions(self) -> list:
"""获取存储分区列表 (过滤虚拟文件系统)"""
parts = []
if self.psutil:
try:
for p in self.psutil.disk_partitions(all=False):
if p.fstype and p.fstype.lower() in self._SKIP_FS:
continue
try:
usage = self.psutil.disk_usage(p.mountpoint)
parts.append({
"device": p.device,
"mount": p.mountpoint,
"fstype": p.fstype or "",
"total_gb": round(usage.total / 1073741824, 1),
"used_gb": round(usage.used / 1073741824, 1),
"percent": usage.percent,
})
except (PermissionError, OSError):
parts.append({
"device": p.device,
"mount": p.mountpoint,
"fstype": p.fstype or "",
"total_gb": 0, "used_gb": 0, "percent": 0,
})
except Exception:
pass
if not parts:
# Fallback: just root partition
disk = self._get_disk()
if disk.get("total_gb", 0) > 0:
parts.append({
"device": "/",
"mount": "/",
"fstype": "",
"total_gb": disk["total_gb"],
"used_gb": disk["used_gb"],
"percent": disk["percent"],
})
return parts
def _get_disk(self) -> Dict[str, Any]:
if self.psutil:
try: