空间清理对齐电脑管家「清理点」粒度;受保护项折叠隐藏
- 规则类分类展开后先按清理点(= 一条规则的全部命中)聚合展示,中文名 映射 RULE_NAMES(系统临时文件/Windows 更新下载缓存/预读取文件…), 点开清理点才列具体路径;升级安装包按应用聚合(微信 升级包 / WPS 升级包)。 - 悬停清理点出现「忽略 / 查看路径」:忽略 = 该清理点全部路径加入保护名单 (白名单,可在设置撤销),toast 确认;分类头部改「N 个清理点」。 - 受安全策略保护项默认隐藏,分类底部一行「已自动隐藏 N 个…」+「仍然显示」; 应用正在运行/需要管理员等可操作锁定照常显示原因。回收站/项目产物/开发 文件保持平铺。大小与数量口径同步排除隐藏项。 - useScanWorkspace 新增 setIndexes(indexes,on) 供整簇勾选;无头浏览器 17 项点击断言全过;tsc/build 绿;0.1.10 重新打包。dev
parent
d305cb0b01
commit
dccbe9b60a
|
|
@ -38,6 +38,12 @@ Squid 0.1.10 更新说明
|
|||
左键也会弹菜单)。
|
||||
|
||||
调整
|
||||
- 空间清理对齐电脑管家的「清理点」粒度:规则类分类(系统垃圾 / 日志 /
|
||||
浏览器缓存等)展开后先按清理点汇总(如「Windows 更新下载缓存 441 MB ·
|
||||
1 个位置」),点开清理点才显示具体路径;悬停清理点可「忽略」(加入保护
|
||||
名单,可随时撤销)或「查看路径」;受安全策略保护、无法删除的项目默认
|
||||
不再刷屏,折叠为一行说明并提供「仍然显示」;应用正在运行、需要管理员
|
||||
等可操作锁定仍照常显示原因。「回收站 / 项目产物 / 开发文件」保持平铺。
|
||||
- 空间清理改版(参照电脑管家布局):取消「分类卡片 + 下方大列表」双层
|
||||
结构,分类即列表、一屏一层;分「已为你默认勾选 / 需要你手动勾选」两区,
|
||||
点击分类行展开该分类子项(再点收起),点击子项整行直接在资源管理器中
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
e921f7596389d76ac5636db348d7b3148f74544aea2e2b1845a14eab5d9f22c8 Squid-Setup-0.1.10-win-x64.exe
|
||||
3dce7e37d64d9edff0099effa47d3f9ae6f57f6cd3de12703b67ded02323ef1e Squid-0.1.10-portable-win-x64.zip
|
||||
046b0e2ad7e3a9dd8558d7ff673d5bd8b4d78c8337055847f7a789003cc31ef5 Squid-Setup-0.1.10-win-x64.exe
|
||||
587c70cc7bbbd48f29ee659baf86e30de16c3c13d9aa02c9c0b188f615d0027d Squid-0.1.10-portable-win-x64.zip
|
||||
Binary file not shown.
|
|
@ -2,12 +2,12 @@
|
|||
"schema": 1,
|
||||
"version": "0.1.10",
|
||||
"date": "2026-11-19",
|
||||
"notes": "Squid 0.1.10\n\n新增\n- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包\n (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。\n 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件\n 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量\n 与大小,可一键「跳过升级包,只删其余」。\n- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应\n 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变),\n 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动\n 收窄。管理页与桌面设置弹层可独立开关该面板。\n\n优化\n- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%):\n 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个\n 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控\n 页打开时才有完整进程表,功能不受影响。\n- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环),\n 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具\n 开着时 Squid 全家 CPU 占用接近 0%。\n\n修复\n- 权限管理:开机启动项每个子行不再重复显示软件图标(图标只在软件分组标题出现一次,子行文字与标题对齐)。\n- 空间清理:修复扫描后分类卡片与复选框全部不可点击的问题(勾选状态没有进入结果列表的派生缓存,点击后视图停留在扫描瞬间);「可选」角标不再遮挡复选框。\n- 权限管理:修复大量启动项/服务显示通用图标的问题——服务壳程序(如微软 Edge 提权服务、电脑管家 qmbsrv、H3C SpaceAgent)自身不含图标资源,现改为回退读取注册表 App Paths、卸载信息 DisplayIcon 与同目录主程序图标。\n- 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报\n 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增\n 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以\n 红色横幅显示。\n- 托盘交互:左键单击/双击图标 = 直接打开主界面,右键 = 弹出菜单(原先\n 左键也会弹菜单)。\n\n调整\n- 空间清理改版(参照电脑管家布局):取消「分类卡片 + 下方大列表」双层结构,分类即列表、一屏一层;分「已为你默认勾选 / 需要你手动勾选」两区,点击分类行展开该分类子项(再点收起),点击子项整行直接在资源管理器中定位文件位置,只有点小方框才改勾选;顶部常驻「已选中 xxx 可清理文件」汇总条(取消全选/立即清理随时可点)。\n- 「日常清理」与「深度清理」合并为一个「空间清理」页:一次扫描同时检查缓存\n 垃圾与项目构建目录,结果汇总为一份清单。默认只勾选日常清理项,「升级安装\n 包 / 项目产物 / 开发文件」三类为可选(虚线卡片 + 可选角标),勾选后与日常\n 项合并成一次清理。深度扫描目录、文件年龄(3/7/30 天)、Git 保护收进页面\n 顶部设置栏;扫描与删除全程有步骤条与实时进度;侧边栏与托盘菜单同步精简,\n 快捷键重排(Ctrl+2 = 空间清理)。\n- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面\n (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠\n 不会把它叫回来)。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。",
|
||||
"notes": "Squid 0.1.10\n\n新增\n- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包\n (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。\n 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件\n 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量\n 与大小,可一键「跳过升级包,只删其余」。\n- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应\n 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变),\n 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动\n 收窄。管理页与桌面设置弹层可独立开关该面板。\n\n优化\n- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%):\n 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个\n 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控\n 页打开时才有完整进程表,功能不受影响。\n- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环),\n 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具\n 开着时 Squid 全家 CPU 占用接近 0%。\n\n修复\n- 权限管理:开机启动项每个子行不再重复显示软件图标(图标只在软件分组标题出现一次,子行文字与标题对齐)。\n- 空间清理:修复扫描后分类卡片与复选框全部不可点击的问题(勾选状态没有进入结果列表的派生缓存,点击后视图停留在扫描瞬间);「可选」角标不再遮挡复选框。\n- 权限管理:修复大量启动项/服务显示通用图标的问题——服务壳程序(如微软 Edge 提权服务、电脑管家 qmbsrv、H3C SpaceAgent)自身不含图标资源,现改为回退读取注册表 App Paths、卸载信息 DisplayIcon 与同目录主程序图标。\n- 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报\n 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增\n 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以\n 红色横幅显示。\n- 托盘交互:左键单击/双击图标 = 直接打开主界面,右键 = 弹出菜单(原先\n 左键也会弹菜单)。\n\n调整\n- 空间清理对齐电脑管家的「清理点」粒度:规则类分类(系统垃圾/日志/浏览器缓存等)展开后先按清理点汇总(如「Windows 更新下载缓存 441 MB · 1 个位置」),点开清理点才显示具体路径;悬停清理点可「忽略」(加入保护名单,可随时撤销)或「查看路径」;受安全策略保护、无法删除的项目默认不再刷屏,折叠为一行说明并提供「仍然显示」;应用正在运行、需要管理员等可操作锁定仍照常显示原因。「回收站 / 项目产物 / 开发文件」保持平铺。\n- 空间清理改版(参照电脑管家布局):取消「分类卡片 + 下方大列表」双层结构,分类即列表、一屏一层;分「已为你默认勾选 / 需要你手动勾选」两区,点击分类行展开该分类子项(再点收起),点击子项整行直接在资源管理器中定位文件位置,只有点小方框才改勾选;顶部常驻「已选中 xxx 可清理文件」汇总条(取消全选/立即清理随时可点)。\n- 「日常清理」与「深度清理」合并为一个「空间清理」页:一次扫描同时检查缓存\n 垃圾与项目构建目录,结果汇总为一份清单。默认只勾选日常清理项,「升级安装\n 包 / 项目产物 / 开发文件」三类为可选(虚线卡片 + 可选角标),勾选后与日常\n 项合并成一次清理。深度扫描目录、文件年龄(3/7/30 天)、Git 保护收进页面\n 顶部设置栏;扫描与删除全程有步骤条与实时进度;侧边栏与托盘菜单同步精简,\n 快捷键重排(Ctrl+2 = 空间清理)。\n- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面\n (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠\n 不会把它叫回来)。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。",
|
||||
"artifacts": {
|
||||
"windows": {
|
||||
"file": "Squid-Setup-0.1.10-win-x64.exe",
|
||||
"sha256": "e921f7596389d76ac5636db348d7b3148f74544aea2e2b1845a14eab5d9f22c8",
|
||||
"size": 3578666
|
||||
"sha256": "046b0e2ad7e3a9dd8558d7ff673d5bd8b4d78c8337055847f7a789003cc31ef5",
|
||||
"size": 3580842
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +51,7 @@ export interface ScanWorkspace {
|
|||
toggleItem: (index: number) => void;
|
||||
toggleCategory: (category: Category) => void;
|
||||
setCategorySelection: (category: Category, on: boolean) => void;
|
||||
setIndexes: (indexes: number[], on: boolean) => void;
|
||||
deselect: (indexes: number[]) => void;
|
||||
selectAll: () => void;
|
||||
clearSelection: () => void;
|
||||
|
|
@ -191,6 +192,21 @@ export function useScanWorkspace(
|
|||
[result],
|
||||
);
|
||||
|
||||
// Bulk tick/un-tick an explicit index set — the 空间清理 accordion uses
|
||||
// this for whole 清理点 (rule clusters), which the category helpers
|
||||
// cannot express because a cluster is smaller than a category.
|
||||
const setIndexes = useCallback((indexes: number[], on: boolean) => {
|
||||
if (indexes.length === 0) return;
|
||||
setSelected((current) => {
|
||||
const next = new Set(current);
|
||||
for (const index of indexes) {
|
||||
if (on) next.add(index);
|
||||
else next.delete(index);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const deselect = useCallback((indexes: number[]) => {
|
||||
if (indexes.length === 0) return;
|
||||
const drop = new Set(indexes);
|
||||
|
|
@ -272,6 +288,7 @@ export function useScanWorkspace(
|
|||
toggleItem,
|
||||
toggleCategory,
|
||||
setCategorySelection,
|
||||
setIndexes,
|
||||
deselect,
|
||||
selectAll,
|
||||
clearSelection,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,156 @@ type Entry = {
|
|||
|
||||
const AGE_CHOICES = [3, 7, 30];
|
||||
|
||||
/* 清理点 names: one cluster per producing rule (电脑管家's "Windows系统日志
|
||||
* 文件" granularity). Unknown ids fall back to the prettified rule id. */
|
||||
const RULE_NAMES: Record<string, [string, string]> = {
|
||||
"windows-temp": ["Temp files", "系统临时文件"],
|
||||
"recent-items": ["Recent items", "最近使用记录"],
|
||||
"windows-update-downloads": ["Windows Update downloads", "Windows 更新下载缓存"],
|
||||
"bits-transfer-cache": ["Delivery Optimization cache", "传递优化缓存"],
|
||||
prefetch: ["Prefetch files", "预读取文件 Prefetch"],
|
||||
"edge-caches": ["Microsoft Edge caches", "Edge 浏览器缓存"],
|
||||
"chrome-caches": ["Chrome caches", "Chrome 浏览器缓存"],
|
||||
"firefox-cache": ["Firefox cache", "Firefox 浏览器缓存"],
|
||||
"inet-cache": ["IE/legacy browser cache", "IE 遗留浏览器缓存"],
|
||||
"icon-thumbnail-cache": ["Icon & thumbnail caches", "缩略图与图标缓存"],
|
||||
"discord-cache": ["Discord cache", "Discord 缓存"],
|
||||
"slack-cache": ["Slack cache", "Slack 缓存"],
|
||||
"vscode-cache": ["VS Code caches", "VS Code 缓存"],
|
||||
"vscode-logs": ["VS Code logs", "VS Code 日志"],
|
||||
"user-error-reporting": ["User error reports", "用户错误报告"],
|
||||
"system-error-reporting": ["Windows error reports", "Windows 错误报告"],
|
||||
"crash-dumps": ["Crash dumps", "崩溃转储文件"],
|
||||
"kernel-dumps": ["Kernel memory dumps", "内存转储文件"],
|
||||
"connected-devices-platform": ["Connected Devices logs", "已连接设备平台日志"],
|
||||
"onedrive-logs": ["OneDrive logs", "OneDrive 日志"],
|
||||
"windows-setup-logs": ["Windows setup logs", "Windows 安装日志"],
|
||||
"npm-cache": ["npm cache", "npm 缓存"],
|
||||
"pip-cache": ["pip cache", "pip 缓存"],
|
||||
"cargo-cache": ["cargo registry cache", "cargo 缓存"],
|
||||
"go-build-cache": ["Go build cache", "Go 构建缓存"],
|
||||
"nuget-cache": ["NuGet cache", "NuGet 缓存"],
|
||||
"gradle-cache": ["Gradle cache", "Gradle 缓存"],
|
||||
"windows-old": ["Previous Windows install", "Windows.old 旧系统"],
|
||||
"package-cache": ["Package cache", "系统包缓存"],
|
||||
"nvidia-installer-archives": ["NVIDIA installer archives", "NVIDIA 安装程序缓存"],
|
||||
"orphan-leftovers": ["Leftovers of uninstalled apps", "已卸载应用残留"],
|
||||
"update-installers-known": ["Known app update packages", "已知应用的升级包"],
|
||||
"update-installers-scan": ["Other update packages", "其他升级安装包"],
|
||||
"purge-artifacts": ["Build artefacts", "项目构建产物"],
|
||||
};
|
||||
|
||||
function ruleName(ruleId: string, lang: "zh" | "en"): string {
|
||||
const pair = RULE_NAMES[ruleId];
|
||||
if (pair) return lang === "zh" ? pair[1] : pair[0];
|
||||
if (!ruleId) return lang === "zh" ? "其他项目" : "Other items";
|
||||
return ruleId.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
/* Flat rule id → a normalised cluster key. Update installers cluster per
|
||||
* app ("<app> · <file>" labels) so the list matches how people think. */
|
||||
function clusterKey(item: CleanupItem): string {
|
||||
if (item.ruleId.startsWith("update-installers")) {
|
||||
return `update:${item.label.split(" · ")[0] ?? item.label}`;
|
||||
}
|
||||
return item.ruleId;
|
||||
}
|
||||
|
||||
// Categories whose items are raw directories with one meaning each; they
|
||||
// keep the flat list. Rule-driven categories group into 清理点 clusters.
|
||||
const FLAT_CATEGORIES: Category[] = ["project-artifacts", "developer", "trash"];
|
||||
|
||||
/* Cluster label for update installers: items carry "<app> · <file>" labels. */
|
||||
function clusterLabel(item: CleanupItem, lang: "zh" | "en"): string {
|
||||
if (item.ruleId.startsWith("update-installers")) {
|
||||
const app = item.label.split(" · ")[0] ?? item.label;
|
||||
return lang === "zh" ? `${app} 升级包` : `${app} installers`;
|
||||
}
|
||||
return ruleName(item.ruleId, lang);
|
||||
}
|
||||
|
||||
type Cluster = {
|
||||
key: string;
|
||||
label: string;
|
||||
entries: Entry[];
|
||||
total: number;
|
||||
removable: number;
|
||||
selected: number;
|
||||
};
|
||||
|
||||
/* A 清理点: one rule's worth of hits, aggregated like 电脑管家's sub-items.
|
||||
* Tick = whole cluster; hover = 忽略 / 查看路径; body = expand to paths. */
|
||||
function ClusterRow({
|
||||
cluster,
|
||||
open,
|
||||
onOpen,
|
||||
onTick,
|
||||
onIgnore,
|
||||
lang,
|
||||
}: {
|
||||
cluster: Cluster;
|
||||
open: boolean;
|
||||
onOpen: () => void;
|
||||
onTick: (on: boolean) => void;
|
||||
onIgnore: () => void;
|
||||
lang: "zh" | "en";
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const allOn = cluster.removable > 0 && cluster.selected >= cluster.removable;
|
||||
return (
|
||||
<>
|
||||
<div className="space-rule" onClick={onOpen}>
|
||||
<Checkbox
|
||||
checked={allOn}
|
||||
disabled={cluster.removable === 0}
|
||||
onChange={() => onTick(!allOn)}
|
||||
label={cluster.label}
|
||||
/>
|
||||
<span className="space-rule-name">{cluster.label}</span>
|
||||
<span className="space-rule-cnt">
|
||||
{t(
|
||||
`${formatCount(cluster.entries.length)} location(s)`,
|
||||
`${formatCount(cluster.entries.length)} 个位置`,
|
||||
)}
|
||||
</span>
|
||||
<span className="space-rule-acts">
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onIgnore();
|
||||
}}
|
||||
>
|
||||
{t("Ignore", "忽略")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onOpen();
|
||||
}}
|
||||
>
|
||||
{t("Paths", "查看路径")}
|
||||
</button>
|
||||
</span>
|
||||
<span className="space-rule-size">{formatBytes(cluster.total)}</span>
|
||||
<ChevronRight
|
||||
className={`space-rule-chv ${open ? "is-open" : ""}`}
|
||||
size={13}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
{open ? (
|
||||
<div className="space-rule-paths">
|
||||
{cluster.entries.map((entry) => (
|
||||
<AccItem key={`${entry.item.path}-${entry.index}`} entry={entry} />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/* One candidate inside an expanded category. The whole row reveals the path
|
||||
* in Explorer (电脑管家 habit: 点击定位); only the tick box changes the
|
||||
* selection, so browsing never mis-toggles. */
|
||||
|
|
@ -269,6 +419,94 @@ export function SpacePage({
|
|||
}
|
||||
};
|
||||
|
||||
// 受安全策略保护 items are the engine's own refusals — the user can fix
|
||||
// "app running" or "needs admin" rows, but never a protected path, so
|
||||
// those fold into a one-line footnote with a reveal switch per category.
|
||||
const [showProtected, setShowProtected] = useState<Partial<Record<Category, boolean>>>({});
|
||||
const visibleEntries = useMemo(
|
||||
() =>
|
||||
entries.filter(
|
||||
(entry) =>
|
||||
entry.item.lock !== "protected" || showProtected[entry.item.category],
|
||||
),
|
||||
[entries, showProtected],
|
||||
);
|
||||
const hiddenProtected = useMemo(() => {
|
||||
const map = new Map<Category, number>();
|
||||
for (const entry of entries) {
|
||||
if (entry.item.lock === "protected" && !showProtected[entry.item.category]) {
|
||||
map.set(entry.item.category, (map.get(entry.item.category) ?? 0) + 1);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}, [entries, showProtected]);
|
||||
|
||||
// 清理点 clusters for one category: same producing rule (update packages
|
||||
// cluster per app). Empty rule ids collapse into one "other" cluster.
|
||||
const clustersFor = (items: Entry[]): Cluster[] => {
|
||||
const map = new Map<string, Cluster>();
|
||||
for (const entry of items) {
|
||||
const key = clusterKey(entry.item);
|
||||
const cluster = map.get(key) ?? {
|
||||
key,
|
||||
label: clusterLabel(entry.item, lang),
|
||||
entries: [],
|
||||
total: 0,
|
||||
removable: 0,
|
||||
selected: 0,
|
||||
};
|
||||
cluster.entries.push(entry);
|
||||
cluster.total += entry.item.onDisk;
|
||||
if (!entry.item.lock) cluster.removable += 1;
|
||||
if (entry.source.selected.has(entry.index)) cluster.selected += 1;
|
||||
map.set(key, cluster);
|
||||
}
|
||||
return [...map.values()]
|
||||
.map((cluster) => ({
|
||||
...cluster,
|
||||
entries: [...cluster.entries].sort((a, b) => b.item.onDisk - a.item.onDisk),
|
||||
}))
|
||||
.sort((a, b) => b.total - a.total);
|
||||
};
|
||||
|
||||
// Open clusters inside expanded categories, keyed "category|ruleId".
|
||||
const [openClusters, setOpenClusters] = useState<Set<string>>(new Set());
|
||||
const toggleCluster = (key: string) =>
|
||||
setOpenClusters((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(key)) next.delete(key);
|
||||
else next.add(key);
|
||||
return next;
|
||||
});
|
||||
|
||||
// 忽略 = protect every path in the cluster through the whitelist — the
|
||||
// visible, reversible twin of 电脑管家's opaque "全部忽略".
|
||||
const ignoreCluster = async (cluster: Cluster) => {
|
||||
const unique = new Map<string, string>();
|
||||
for (const entry of cluster.entries) {
|
||||
unique.set(entry.item.path, entry.item.displayPath);
|
||||
}
|
||||
try {
|
||||
for (const path of unique.keys()) await api.whitelistAdd(path);
|
||||
const label =
|
||||
unique.size === 1
|
||||
? [...unique.values()][0]
|
||||
: t(
|
||||
`${formatCount(unique.size)} paths of ${cluster.label}`,
|
||||
`${cluster.label} 的 ${formatCount(unique.size)} 个路径`,
|
||||
);
|
||||
push(
|
||||
t(`${label} moved to the protection list`, `已将 ${label} 加入保护名单`),
|
||||
"success",
|
||||
);
|
||||
} catch (reason) {
|
||||
push(
|
||||
t(`Ignore failed: ${String(reason)}`, `忽略失败:${String(reason)}`),
|
||||
"danger",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// A group is "on" when every removable item in it is checked; it may only
|
||||
// switch itself off when nothing can be removed at all (every row locked)
|
||||
// — an empty selection is a state to click back from, never a disability.
|
||||
|
|
@ -584,14 +822,11 @@ export function SpacePage({
|
|||
(category) => groups.has(category) && inSection(category),
|
||||
);
|
||||
if (cats.length === 0) return null;
|
||||
const sectionCount = cats.reduce(
|
||||
(sum, category) => sum + groups.get(category)!.count,
|
||||
0,
|
||||
);
|
||||
const sectionTotal = cats.reduce(
|
||||
(sum, category) => sum + groups.get(category)!.total,
|
||||
0,
|
||||
);
|
||||
const inSectionEntry = (entry: Entry) => inSection(entry.item.category);
|
||||
const sectionCount = visibleEntries.filter(inSectionEntry).length;
|
||||
const sectionTotal = visibleEntries
|
||||
.filter(inSectionEntry)
|
||||
.reduce((sum, entry) => sum + entry.item.onDisk, 0);
|
||||
return (
|
||||
<div key={section}>
|
||||
<div className="space-sec">
|
||||
|
|
@ -622,9 +857,12 @@ export function SpacePage({
|
|||
const meta = CATEGORY_META[category];
|
||||
const Icon = meta.icon;
|
||||
const optional = OPTIONAL_CATEGORIES.includes(category);
|
||||
const items = entries
|
||||
.filter((entry) => entry.item.category === category)
|
||||
.sort((a, b) => b.item.onDisk - a.item.onDisk);
|
||||
const shown = visibleEntries.filter(
|
||||
(entry) => entry.item.category === category,
|
||||
);
|
||||
const flat = FLAT_CATEGORIES.includes(category);
|
||||
const clusters = flat ? [] : clustersFor(shown);
|
||||
const hidden = hiddenProtected.get(category) ?? 0;
|
||||
return (
|
||||
<div key={category} className={`space-cat ${open ? "is-open" : ""}`}>
|
||||
<div
|
||||
|
|
@ -655,11 +893,21 @@ export function SpacePage({
|
|||
{lang === "zh" ? meta.blurbZh : meta.blurbEn}
|
||||
</span>
|
||||
<span className="space-cat-n">
|
||||
{t(`${formatCount(group.count)} items`, `${formatCount(group.count)} 项`)}
|
||||
{flat
|
||||
? t(
|
||||
`${formatCount(shown.length)} items`,
|
||||
`${formatCount(shown.length)} 项`,
|
||||
)
|
||||
: t(
|
||||
`${formatCount(clusters.length)} clean-up spots`,
|
||||
`${formatCount(clusters.length)} 个清理点`,
|
||||
)}
|
||||
</span>
|
||||
<span className={`space-cat-size ${optional ? "is-opt" : ""}`}>
|
||||
{optional ? `${t("optional", "可选")} ` : ""}
|
||||
{formatBytes(group.total)}
|
||||
{formatBytes(
|
||||
shown.reduce((sum, entry) => sum + entry.item.onDisk, 0),
|
||||
)}
|
||||
</span>
|
||||
<ChevronRight
|
||||
className="space-cat-chv"
|
||||
|
|
@ -669,12 +917,57 @@ export function SpacePage({
|
|||
</div>
|
||||
{open ? (
|
||||
<div className="space-cat-items">
|
||||
{items.map((entry) => (
|
||||
<AccItem
|
||||
key={`${entry.item.path}-${entry.index}`}
|
||||
entry={entry}
|
||||
/>
|
||||
))}
|
||||
{flat
|
||||
? shown.map((entry) => (
|
||||
<AccItem
|
||||
key={`${entry.item.path}-${entry.index}`}
|
||||
entry={entry}
|
||||
/>
|
||||
))
|
||||
: clusters.map((cluster) => {
|
||||
const key = `${category}|${cluster.key}`;
|
||||
return (
|
||||
<ClusterRow
|
||||
key={key}
|
||||
cluster={cluster}
|
||||
open={openClusters.has(key)}
|
||||
lang={lang}
|
||||
onOpen={() => toggleCluster(key)}
|
||||
onTick={(on) => {
|
||||
const bySource = new Map<ScanWorkspace, number[]>();
|
||||
for (const entry of cluster.entries) {
|
||||
if (entry.item.lock) continue;
|
||||
const list = bySource.get(entry.source) ?? [];
|
||||
list.push(entry.index);
|
||||
bySource.set(entry.source, list);
|
||||
}
|
||||
for (const [source, list] of bySource) {
|
||||
source.setIndexes(list, on);
|
||||
}
|
||||
}}
|
||||
onIgnore={() => void ignoreCluster(cluster)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{hidden > 0 && !showProtected[category] ? (
|
||||
<div className="space-hidden">
|
||||
{t(
|
||||
`${formatCount(hidden)} items in protected system locations are hidden (they cannot be removed).`,
|
||||
`已自动隐藏 ${formatCount(hidden)} 个受安全策略保护、无法删除的项目。`,
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
setShowProtected((current) => ({
|
||||
...current,
|
||||
[category]: true,
|
||||
}))
|
||||
}
|
||||
>
|
||||
{t("Show anyway", "仍然显示")}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
|
|
|||
113
src/styles.css
113
src/styles.css
|
|
@ -5675,6 +5675,119 @@ select:focus-visible,
|
|||
color: #c0a06a;
|
||||
}
|
||||
|
||||
/* 清理点 rows: one rule's aggregated hits; body expands to concrete paths. */
|
||||
.space-rule {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
padding: 10px 16px 10px 44px;
|
||||
border-top: 1px solid #f6efe2;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.space-rule:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.space-rule:hover {
|
||||
background: rgba(253, 244, 228, 0.75);
|
||||
}
|
||||
|
||||
.space-rule-name {
|
||||
flex: 0 1 auto;
|
||||
overflow: hidden;
|
||||
color: #42505e;
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.space-rule-cnt {
|
||||
flex: 0 0 auto;
|
||||
color: #aab4c0;
|
||||
font-size: var(--nex-text-3xs);
|
||||
}
|
||||
|
||||
.space-rule-acts {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 118px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.space-rule:hover .space-rule-acts {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.space-rule-acts button {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: #3f6bbd;
|
||||
font-size: var(--nex-text-3xs);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.space-rule-acts button:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.space-rule-size {
|
||||
margin-left: auto;
|
||||
flex: 0 0 auto;
|
||||
color: #5a6776;
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.space-rule-chv {
|
||||
flex: 0 0 auto;
|
||||
color: #b7bfca;
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.space-rule-chv.is-open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.space-rule-paths {
|
||||
background: rgba(255, 253, 246, 0.85);
|
||||
}
|
||||
|
||||
.space-rule-paths .space-item {
|
||||
padding-left: 74px;
|
||||
border-top-color: #f8f2e6;
|
||||
}
|
||||
|
||||
/* Folded 受安全策略保护 rows: one quiet line with a reveal switch. */
|
||||
.space-hidden {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px 9px 44px;
|
||||
border-top: 1px dashed #efe3cc;
|
||||
background: rgba(255, 254, 251, 0.9);
|
||||
color: #b3a688;
|
||||
font-size: var(--nex-text-3xs);
|
||||
}
|
||||
|
||||
.space-hidden button {
|
||||
margin-left: auto;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: #3f6bbd;
|
||||
font-size: var(--nex-text-3xs);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.space-hidden button:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.confirm-updater-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
Loading…
Reference in New Issue