空间清理改版为电脑管家式手风琴布局;启动项图标只在分组标题显示

- 空间清理:取消「分类卡片 + 大列表」双层结构,分类即列表一屏一层;
  分「已为你默认勾选 / 需要你手动勾选」两区;点击分类行展开子项
  (再点收起,首扫自动展开最大分类),点子项整行 = 资源管理器定位,
  只有小方框改勾选;顶部常驻汇总条(已选大小 / 取消全选 / 立即清理)。
- 权限管理:启动项子行去图标、缩进 30px 与组标题文字对齐,图标每软件
  只显示一次;组图标 20→22px。
- 无头浏览器 14 项点击断言全过;tsc/build/测试全绿;0.1.10 重新打包。
dev
lijunjie 2026-11-19 20:57:42 +08:00
parent 3b76a35e4d
commit d305cb0b01
8 changed files with 457 additions and 583 deletions

View File

@ -21,6 +21,8 @@ Squid 0.1.10 更新说明
开着时 Squid 全家 CPU 占用接近 0%。
修复
- 权限管理:开机启动项每个子行不再重复显示软件图标(图标只在软件分组标题
出现一次,子行文字与标题对齐)。
- 空间清理:修复扫描后分类卡片与复选框全部不可点击的问题(勾选状态没有
进入结果列表的派生缓存,点击后视图停留在扫描瞬间);「可选」角标不再
遮挡复选框。
@ -36,6 +38,11 @@ Squid 0.1.10 更新说明
左键也会弹菜单)。
调整
- 空间清理改版(参照电脑管家布局):取消「分类卡片 + 下方大列表」双层
结构,分类即列表、一屏一层;分「已为你默认勾选 / 需要你手动勾选」两区,
点击分类行展开该分类子项(再点收起),点击子项整行直接在资源管理器中
定位文件位置,只有点小方框才改勾选;顶部常驻「已选中 xxx 可清理文件」
汇总条(取消全选 / 立即清理随时可点)。
- 「日常清理」与「深度清理」合并为一个「空间清理」页:一次扫描同时检查缓存
垃圾与项目构建目录,结果汇总为一份清单。默认只勾选日常清理项,「升级安装
包 / 项目产物 / 开发文件」三类为可选(虚线卡片 + 可选角标),勾选后与日常

View File

@ -1,2 +1,2 @@
eb0d0740f3dcb0faa1f95323195d90d907271572de54481acafbb65550b53d7c Squid-Setup-0.1.10-win-x64.exe
35f68b65cee48b25aef2b9bc20db7bdc34cae8e77bc85e546a406df3c151a525 Squid-0.1.10-portable-win-x64.zip
e921f7596389d76ac5636db348d7b3148f74544aea2e2b1845a14eab5d9f22c8 Squid-Setup-0.1.10-win-x64.exe
3dce7e37d64d9edff0099effa47d3f9ae6f57f6cd3de12703b67ded02323ef1e Squid-0.1.10-portable-win-x64.zip

View File

@ -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- 权限管理:修复大量启动项/服务显示通用图标的问题——服务壳程序(如微软 Edge 提权服务、电脑管家 qmbsrv、H3C SpaceAgent)自身不含图标资源,现改为回退读取注册表 App Paths、卸载信息 DisplayIcon 与同目录主程序图标。\n- 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报\n 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增\n 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以\n 红色横幅显示。\n- 托盘交互:左键单击/双击图标 = 直接打开主界面,右键 = 弹出菜单(原先\n 左键也会弹菜单)。\n\n调整\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- 空间清理改版(参照电脑管家布局):取消「分类卡片 + 下方大列表」双层结构,分类即列表、一屏一层;分「已为你默认勾选 / 需要你手动勾选」两区,点击分类行展开该分类子项(再点收起),点击子项整行直接在资源管理器中定位文件位置,只有点小方框才改勾选;顶部常驻「已选中 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": "eb0d0740f3dcb0faa1f95323195d90d907271572de54481acafbb65550b53d7c",
"size": 3576785
"sha256": "e921f7596389d76ac5636db348d7b3148f74544aea2e2b1845a14eab5d9f22c8",
"size": 3578666
}
}
}

View File

@ -1,33 +1,6 @@
import {
ArrowUpRight,
DownloadCloud,
FolderOpen,
LockKeyhole,
RotateCcw,
ShieldCheck,
Trash2,
} from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { useI18n } from "../i18n";
import { api } from "../lib/api";
import { formatBytes, formatCount, shortPath } from "../lib/format";
import type { Category, CleanupItem, DeleteMode, ScanResult } from "../types";
import type { ScanWorkspace } from "../hooks/useScanWorkspace";
import {
Button,
CATEGORY_META,
CATEGORY_ORDER,
CategoryCard,
Checkbox,
ConfirmDialog,
InlineError,
ProgressCard,
ResultSummary,
SectionTitle,
categoryLabel,
lockLabel,
useToast,
} from "./ui";
import { useMemo } from "react";
import type { Category, ScanResult } from "../types";
import { CATEGORY_ORDER, CategoryCard } from "./ui";
type CategoryGroup = { total: number; count: number; items: number[]; selected: number };
@ -49,6 +22,7 @@ function grouped(result: ScanResult) {
return groups;
}
/* Overview 页的分类速览:紧凑卡片一排,点击跳转空间清理页。 */
export function CategorySummary({
result,
selected,
@ -83,377 +57,3 @@ export function CategorySummary({
</div>
);
}
export function ItemRow({
item,
checked,
onToggle,
}: {
item: CleanupItem;
checked: boolean;
onToggle: () => void;
}) {
const { lang, t, bin } = useI18n();
const Icon = CATEGORY_META[item.category].icon;
return (
<div
className={`cleanup-row ${item.lock ? "is-locked" : ""} ${
checked ? "is-selected" : ""
}`}
onClick={item.lock ? undefined : onToggle}
>
<Checkbox
checked={checked}
disabled={Boolean(item.lock)}
onChange={onToggle}
label={item.label}
/>
<span className={`row-icon tone-${CATEGORY_META[item.category].tone}`}>
<Icon size={17} />
</span>
<span className="cleanup-row-copy">
<span className="cleanup-row-title">
<strong>{item.label}</strong>
<span className="row-category">{categoryLabel(item.category, lang, bin)}</span>
</span>
<span className="cleanup-row-path" title={item.displayPath}>
{shortPath(item.displayPath, 90)}
</span>
{item.lock || item.note ? (
<span className={`cleanup-row-note ${item.lock ? "is-locked" : ""}`}>
{item.lock ? <LockKeyhole size={12} /> : null}
{item.lock ? lockLabel(item.lock, t) : item.note}
</span>
) : null}
</span>
<span className="cleanup-row-size">{formatBytes(item.onDisk)}</span>
<button
className="row-reveal"
title={t("Show in Finder", "在访达中显示")}
aria-label={t("Show in Finder", "Show in Finder")}
onClick={(event) => {
event.stopPropagation();
void api.revealPath(item.path).catch(() => undefined);
}}
>
<ArrowUpRight size={15} />
</button>
</div>
);
}
export function CleanupInventory({
workspace,
defaultMode,
onHistory,
}: {
workspace: ScanWorkspace;
defaultMode: DeleteMode;
onHistory: () => void;
}) {
const { t, lang, bin } = useI18n();
const { push } = useToast();
const [focus, setFocus] = useState<Category | null>(null);
const [confirming, setConfirming] = useState(false);
const [mode, setMode] = useState<DeleteMode>(defaultMode);
useEffect(() => setMode(defaultMode), [defaultMode]);
const result = workspace.result;
const groups = useMemo(
() => (result ? grouped(result) : new Map<Category, CategoryGroup>()),
[result],
);
const visibleItems = useMemo(() => {
if (!result) return [];
return result.items
.map((item, index) => ({ item, index }))
.filter(({ item }) => !focus || item.category === focus);
}, [focus, result]);
const removables = result?.items.filter((item) => !item.lock).length ?? 0;
// 升级安装包:selection may include stale update packages; the confirm
// dialog offers a one-click "delete everything else, keep these" escape.
const selectedUpdaters = useMemo(() => {
if (!result) return { indexes: [] as number[], total: 0 };
let total = 0;
const indexes: number[] = [];
result.items.forEach((item, index) => {
if (item.category === "update-installers" && workspace.selected.has(index)) {
indexes.push(index);
total += item.onDisk;
}
});
return { indexes, total };
}, [result, workspace.selected]);
if (workspace.scanning) {
return (
<ProgressCard
progress={workspace.progress}
title={t("Scanning your computer safely…", "正在安全扫描您的电脑…")}
onCancel={() => void workspace.cancel()}
/>
);
}
if (workspace.summary) {
return (
<ResultSummary
removed={workspace.summary.removed}
freed={workspace.summary.freedAllocated || workspace.summary.freed}
failed={workspace.summary.failed}
mode={workspace.summary.mode}
onAgain={() => void workspace.runScan()}
onHistory={onHistory}
/>
);
}
if (!result) return null;
const confirm = async (indexes?: number[]) => {
const summary = await workspace.clean(mode, indexes);
setConfirming(false);
if (summary) {
push(
t(
`${formatBytes(summary.freedAllocated || summary.freed)} cleaned`,
`已清理 ${formatBytes(summary.freedAllocated || summary.freed)}`,
),
"success",
);
}
};
return (
<>
<div className="scan-result-hero">
<div>
<span className="result-kicker">
<ShieldCheck size={14} />
{t("Scan complete", "扫描完成")}
</span>
<h2>
{formatBytes(workspace.selectedTotal)}
<small>{t(" ready to clean", " 可安全清理")}</small>
</h2>
<p>
{t(
`${formatCount(workspace.selectedCount)} of ${formatCount(
removables,
)} available items selected`,
`已选择 ${formatCount(workspace.selectedCount)} / ${formatCount(
removables,
)} 个可清理项目`,
)}
{result.unreadable > 0
? t(
` · ${formatCount(result.unreadable)} could not be read`,
` · ${formatCount(result.unreadable)} 项无法读取`,
)
: ""}
</p>
</div>
<div className="scan-result-actions">
<Button
variant="ghost"
onClick={workspace.clearSelection}
disabled={workspace.selectedCount === 0}
>
{t("Deselect all", "取消全选")}
</Button>
<Button
variant="primary"
icon={<Trash2 size={16} />}
disabled={workspace.selectedCount === 0}
onClick={() => setConfirming(true)}
>
{t("Review & clean", "检查并清理")}
</Button>
</div>
</div>
{workspace.error ? (
<InlineError message={workspace.error} onDismiss={workspace.clearError} />
) : null}
<div className="category-grid">
{CATEGORY_ORDER.filter((category) => groups.has(category)).map((category) => {
const group = groups.get(category);
if (!group) return null;
const indexes = group.items.filter((index) => !result.items[index].lock);
const allSelected =
indexes.length > 0 && indexes.every((index) => workspace.selected.has(index));
return (
<CategoryCard
key={category}
category={category}
total={group.total}
count={group.count}
selected={allSelected}
focused={focus === category}
disabled={indexes.length === 0}
onToggle={() => workspace.toggleCategory(category)}
onInspect={() => setFocus(focus === category ? null : category)}
/>
);
})}
</div>
<section className="cleanup-list-panel">
<SectionTitle
title={
focus
? categoryLabel(focus, lang, bin)
: t("Everything found in this scan", "本次扫描的全部项目")
}
subtitle={t(
"Only checked items are touched. Protected items stay locked.",
"只会处理已勾选的项目,受保护项目始终保持锁定。",
)}
action={
focus ? (
<Button variant="ghost" size="sm" onClick={() => setFocus(null)}>
{t("Show all", "显示全部")}
</Button>
) : (
<Button variant="ghost" size="sm" onClick={workspace.selectAll}>
{workspace.selectedCount === removables
? t("Deselect all", "取消全选")
: t("Select all", "全部选择")}
</Button>
)
}
/>
<div className="cleanup-rows">
{visibleItems.map(({ item, index }) => (
<ItemRow
key={`${item.path}-${index}`}
item={item}
checked={workspace.selected.has(index)}
onToggle={() => workspace.toggleItem(index)}
/>
))}
</div>
</section>
<div className="floating-action">
<div>
<span>{t("Selected for cleanup", "已选择清理")}</span>
<strong>{formatBytes(workspace.selectedTotal)}</strong>
</div>
<div className="floating-actions">
<Button
variant="ghost"
size="sm"
icon={<FolderOpen size={15} />}
onClick={() => void api.openTrash().catch(() => undefined)}
>
{bin}
</Button>
<Button
variant="primary"
icon={<Trash2 size={15} />}
disabled={workspace.selectedCount === 0}
onClick={() => setConfirming(true)}
>
{t("Clean now", "立即清理")}
</Button>
</div>
</div>
<ConfirmDialog
open={confirming}
title={t("Ready to make room?", "准备释放空间?")}
message={
<span>
{t(
`${formatCount(workspace.selectedCount)} items · ${formatBytes(
workspace.selectedTotal,
)}`,
`${formatCount(workspace.selectedCount)} 项 · ${formatBytes(
workspace.selectedTotal,
)}`,
)}
</span>
}
note={
mode === "trash"
? t(
`Items will move to the ${bin}. You can restore them from History.`,
`文件将移入${bin},之后可从历史记录中还原。`,
)
: t(
"Permanent removal cannot be undone. Squid re-checks every path before deleting it.",
"永久删除无法撤销。Squid 会在删除前重新检查每一个路径。",
)
}
confirmLabel={
mode === "trash"
? t(`Move to ${bin}`, `移入${bin}`)
: t("Remove permanently", "永久删除")
}
cancelLabel={t("Keep files", "保留文件")}
onConfirm={() => void confirm()}
onClose={() => setConfirming(false)}
busy={workspace.deleting}
icon={<RotateCcw size={23} />}
>
<div className="mode-picker">
<button
className={mode === "trash" ? "is-active" : ""}
onClick={() => setMode("trash")}
>
<FolderOpen size={17} />
<span>{bin}</span>
</button>
<button
className={mode === "permanent" ? "is-active" : ""}
onClick={() => setMode("permanent")}
>
<Trash2 size={17} />
<span>{t("Permanent", "永久")}</span>
</button>
</div>
{selectedUpdaters.indexes.length > 0 ? (
<div className="confirm-updater-banner">
<DownloadCloud size={18} />
<div>
<strong>
{t(
`Includes ${formatCount(selectedUpdaters.indexes.length)} update installers (${formatBytes(selectedUpdaters.total)})`,
`其中包含 ${formatCount(selectedUpdaters.indexes.length)} 个升级安装包(${formatBytes(selectedUpdaters.total)})`,
)}
</strong>
<span>
{t(
"Apps re-download them when needed. Delete them too?",
"应用需要时会自动重新下载。要一并清理吗?",
)}
</span>
</div>
<Button
variant="ghost"
size="sm"
disabled={workspace.deleting}
onClick={() => {
const keep = [...workspace.selected].filter(
(index) => !selectedUpdaters.indexes.includes(index),
);
if (keep.length === 0) {
workspace.deselect(selectedUpdaters.indexes);
setConfirming(false);
return;
}
void confirm(keep);
}}
>
{t("Skip installers, clean rest", "跳过升级包,只删其余")}
</Button>
</div>
) : null}
</ConfirmDialog>
</>
);
}

View File

@ -226,8 +226,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace
className={`settings-row ${workspace.busyId === item.id ? "is-busy" : ""}`}
key={item.id}
>
<div className="perm-row">
<RowIcon icon={item.icon} label={item.displayName} />
<div className="perm-row perm-row-noicon">
<div>
<span>{item.name}</span>
<small title={item.command}>

View File

@ -7,17 +7,24 @@
* three optional groups (升级安装包 / 项目产物 / 开发文件) start untouched
* and join the same delete run when the user checks their card. */
import {
ArrowUpRight,
ChevronRight,
DownloadCloud,
FolderOpen,
ScanSearch,
ShieldCheck,
Trash2,
} from "lucide-react";
import { open } from "@tauri-apps/plugin-dialog";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { useI18n } from "../i18n";
import { api } from "../lib/api";
import { formatBytes, formatCount } from "../lib/format";
import { formatBytes, formatCount, shortPath } from "../lib/format";
import type {
Bootstrap,
Category,
@ -26,17 +33,18 @@ import type {
DeleteResult,
} from "../types";
import type { ScanWorkspace } from "../hooks/useScanWorkspace";
import { ItemRow } from "../components/CleanupView";
import {
Button,
CATEGORY_META,
CATEGORY_ORDER,
CategoryCard,
Checkbox,
ConfirmDialog,
InlineError,
ProgressCard,
SectionTitle,
Toggle,
categoryLabel,
lockLabel,
useToast,
} from "../components/ui";
@ -55,6 +63,40 @@ type Entry = {
const AGE_CHOICES = [3, 7, 30];
/* 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. */
function AccItem({ entry }: { entry: Entry }) {
const { t } = useI18n();
const { item, source, index } = entry;
const checked = source.selected.has(index);
return (
<div
className={`space-item ${item.lock ? "is-locked" : ""}`}
onClick={() => void api.revealPath(item.path).catch(() => undefined)}
title={t("Open the location in Explorer", "在资源管理器中打开所在位置")}
>
<Checkbox
checked={checked}
disabled={Boolean(item.lock)}
onChange={() => source.toggleItem(index)}
label={item.label}
/>
<span className="space-item-name">{item.label}</span>
<span className="space-item-path" title={item.displayPath}>
{shortPath(item.displayPath, 96)}
</span>
{item.lock || item.note ? (
<span className={`space-item-meta ${item.lock ? "is-locked" : ""}`}>
{item.lock ? lockLabel(item.lock, t) : item.note}
</span>
) : null}
<span className="space-item-size">{formatBytes(item.onDisk)}</span>
<ArrowUpRight className="space-item-go" size={14} />
</div>
);
}
export function SpacePage({
cleanup,
purge,
@ -74,7 +116,16 @@ export function SpacePage({
const [minAge, setMinAge] = useState(bootstrap.settings.purgeMinAgeDays || 7);
const [force, setForce] = useState(false);
const [confirming, setConfirming] = useState(false);
const [focus, setFocus] = useState<Category | null>(null);
// Open accordions. On first results we auto-expand the biggest category so
// the list never reads as a dead panel; that initial choice is remembered
// here (null until the first scan lands).
const [expanded, setExpanded] = useState<Category[] | null>(null);
const toggleExpanded = (category: Category) =>
setExpanded((current) =>
(current ?? []).includes(category)
? (current ?? []).filter((item) => item !== category)
: [...(current ?? []), category],
);
const [mode, setMode] = useState<DeleteMode>(deleteMode);
const [busy, setBusy] = useState(false);
const [result, setResult] = useState<DeleteResult | null>(null);
@ -176,20 +227,6 @@ export function SpacePage({
return { count, total };
}, [entries, cleanup.selected, purge.selected]);
const optionalSelected = useMemo(() => {
let count = 0;
for (const entry of entries) {
if (
OPTIONAL_CATEGORIES.includes(entry.item.category) &&
entry.source.selected.has(entry.index) &&
!entry.item.lock
) {
count += 1;
}
}
return count;
}, [entries, cleanup.selected, purge.selected]);
// 升级安装包 keep the confirm-dialog escape: count them inside the current
// selection so the banner can offer "skip installers, clean the rest".
const selectedUpdaters = useMemo(() => {
@ -208,6 +245,21 @@ export function SpacePage({
return { count, total };
}, [entries, cleanup.selected, purge.selected]);
// First results in: pre-open the single fattest category so the page never
// looks inert; afterwards the user owns the open set entirely.
useEffect(() => {
if (expanded !== null || entries.length === 0) return;
let biggest: Category | null = null;
let best = 0;
for (const [category, group] of groups) {
if (group.removable > 0 && group.total > best) {
best = group.total;
biggest = category;
}
}
setExpanded(biggest ? [biggest] : []);
}, [entries, expanded, groups]);
const toggleGroup = (category: Category) => {
const allOn = groupSelected(category);
for (const source of [cleanup, purge]) {
@ -361,7 +413,9 @@ export function SpacePage({
onClick={() => void runScan()}
disabled={scanning || deleting}
>
{t("Start scan", "开始扫描")}
{cleanup.result || purge.result
? t("Rescan", "重新扫描")
: t("Start scan", "开始扫描")}
</Button>
</div>
@ -475,135 +529,160 @@ export function SpacePage({
{!scanning && !deleting && (cleanup.result || purge.result) ? (
<>
<div className="hero">
<div>
<span className="k">
<ShieldCheck size={13} />{" "}
{t("Scan complete · caches + projects", "扫描完成 · 缓存 + 项目目录")}
</span>
<h2>
{formatBytes(selectedStats.total)}
<small>
{t(" selected", " 已选")} ·{" "}
{formatBytes(
<div className="space-sum" style={{ position: "sticky", top: 0, zIndex: 5 }}>
<div className="grow">
<div className="big">
{t("Selected ", "已选中 ")}
<em>{formatBytes(selectedStats.total)}</em>
{t(" ready to clean", " 可清理文件")}
</div>
<div className="sub">
{t(
`${formatBytes(
entries
.filter((entry) => !entry.item.lock)
.reduce((sum, entry) => sum + entry.item.onDisk, 0),
)}{" "}
{t("available in total", "全部可清理")}
</small>
</h2>
<p>
{t(
`${formatCount(selectedStats.count)} of ${formatCount(
)} found in total · ${formatCount(selectedStats.count)} of ${formatCount(
entries.filter((entry) => !entry.item.lock).length,
)} items selected${
optionalSelected > 0
? ` · ${formatCount(optionalSelected)} optional (update installers / build artefacts / dev files)`
: " · optional groups untouched"
}`,
`已选 ${formatCount(selectedStats.count)} / ${formatCount(
)} items selected`,
`共发现 ${formatBytes(
entries
.filter((entry) => !entry.item.lock)
.reduce((sum, entry) => sum + entry.item.onDisk, 0),
)} 可清理文件 · 已选 ${formatCount(selectedStats.count)} / ${formatCount(
entries.filter((entry) => !entry.item.lock).length,
)} 项${
optionalSelected > 0
? ` · 含 ${formatCount(optionalSelected)} 个可选类(升级包/项目产物/开发文件)`
: " · 可选类未勾选(默认只清理日常项)"
}`,
)} 项`,
)}
</p>
</div>
<div className="hero-actions">
<Button
variant="ghost"
onClick={() => {
cleanup.clearSelection();
purge.clearSelection();
}}
disabled={selectedStats.count === 0}
>
{t("Deselect all", "取消全选")}
</Button>
<Button
variant="primary"
icon={<Trash2 size={16} />}
disabled={selectedStats.count === 0}
onClick={() => setConfirming(true)}
>
{t(
`Clean ${formatBytes(selectedStats.total)}`,
`清理已选 ${formatBytes(selectedStats.total)}`,
)}
</Button>
</div>
</div>
<Button
variant="ghost"
onClick={() => {
cleanup.clearSelection();
purge.clearSelection();
}}
disabled={selectedStats.count === 0}
>
{t("Deselect all", "取消全选")}
</Button>
<Button
variant="primary"
icon={<Trash2 size={16} />}
disabled={selectedStats.count === 0}
onClick={() => setConfirming(true)}
>
{t("Clean now", "立即清理")}
</Button>
</div>
<div className="hint-strip">
{t(
"Daily groups are pre-selected. The dashed cards (update installers, project artefacts, developer files) are opt-in — tick them to join the same clean run.",
"默认只勾选日常清理项;虚线卡片(升级安装包 / 项目产物 / 开发文件)为可选,勾选后将与日常项合并成一次清理。",
)}
</div>
<div className="category-grid">
{CATEGORY_ORDER.filter((category) => groups.has(category)).map(
(category) => {
const group = groups.get(category)!;
const optional = OPTIONAL_CATEGORIES.includes(category);
return (
<div className="category-slot" key={category}>
{optional ? (
<span className="opt-tag">
{t("optional", "可选")}
</span>
) : null}
<CategoryCard
category={category}
total={group.total}
count={group.count}
selected={groupSelected(category)}
focused={focus === category}
disabled={groupDisabled(category)}
onToggle={() => toggleGroup(category)}
onInspect={() => setFocus(focus === category ? null : category)}
/>
</div>
);
},
)}
</div>
<section className="cleanup-list-panel">
<SectionTitle
title={
focus
? categoryLabel(focus, lang, bin)
: t("Everything found in this scan", "本次扫描的全部项目")
}
subtitle={t(
"Only checked items are touched. Protected items stay locked.",
"只会处理已勾选的项目,受保护项目始终保持锁定。",
)}
action={
focus ? (
<Button variant="ghost" size="sm" onClick={() => setFocus(null)}>
{t("Show all", "显示全部")}
</Button>
) : null
}
/>
<div className="cleanup-rows">
{entries
.filter((entry) => !focus || entry.item.category === focus)
.map((entry) => (
<ItemRow
key={`${entry.item.path}-${entry.index}`}
item={entry.item}
checked={entry.source.selected.has(entry.index)}
onToggle={() => entry.source.toggleItem(entry.index)}
/>
))}
</div>
</section>
{(["daily", "optional"] as const).map((section) => {
const inSection = (category: Category) =>
section === "optional"
? OPTIONAL_CATEGORIES.includes(category)
: !OPTIONAL_CATEGORIES.includes(category);
const cats = CATEGORY_ORDER.filter(
(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,
);
return (
<div key={section}>
<div className="space-sec">
<h2>
{section === "daily"
? t("Pre-selected for you", "已为你默认勾选")
: t("Needs your tick", "需要你手动勾选")}
</h2>
<span className="tip">
{section === "daily"
? t(
`${formatCount(sectionCount)} items, safe to clean`,
`共 ${formatCount(sectionCount)} 项,可以放心清理`,
)
: t(
`${formatCount(sectionCount)} items, review before cleaning`,
`共 ${formatCount(sectionCount)} 项,请确认后清理`,
)}
</span>
<span className={`r ${section === "optional" ? "is-opt" : ""}`}>
{section === "daily" ? t("selected", "已选") : t("optional", "可选")}{" "}
<b>{formatBytes(sectionTotal)}</b>
</span>
</div>
{cats.map((category) => {
const group = groups.get(category)!;
const open = (expanded ?? []).includes(category);
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);
return (
<div key={category} className={`space-cat ${open ? "is-open" : ""}`}>
<div
className="space-cat-head"
role="button"
tabIndex={0}
onClick={() => toggleExpanded(category)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
toggleExpanded(category);
}
}}
>
<Checkbox
checked={groupSelected(category)}
disabled={groupDisabled(category)}
onChange={() => toggleGroup(category)}
label={categoryLabel(category, lang, bin)}
/>
<span className={`space-cat-icon tone-${meta.tone}`}>
<Icon size={15} />
</span>
<span className="space-cat-name">
{categoryLabel(category, lang, bin)}
</span>
<span className="space-cat-desc">
{lang === "zh" ? meta.blurbZh : meta.blurbEn}
</span>
<span className="space-cat-n">
{t(`${formatCount(group.count)} items`, `${formatCount(group.count)} 项`)}
</span>
<span className={`space-cat-size ${optional ? "is-opt" : ""}`}>
{optional ? `${t("optional", "可选")} ` : ""}
{formatBytes(group.total)}
</span>
<ChevronRight
className="space-cat-chv"
size={15}
aria-hidden="true"
/>
</div>
{open ? (
<div className="space-cat-items">
{items.map((entry) => (
<AccItem
key={`${entry.item.path}-${entry.index}`}
entry={entry}
/>
))}
</div>
) : null}
</div>
);
})}
</div>
);
})}
</>
) : null}

View File

@ -4947,9 +4947,9 @@ select:focus-visible,
}
.perm-group-icon {
width: 20px;
height: 20px;
border-radius: 5px;
width: 22px;
height: 22px;
border-radius: 6px;
object-fit: contain;
flex: 0 0 auto;
}
@ -4979,6 +4979,12 @@ select:focus-visible,
min-width: 0;
}
/* Startup rows live under a software-group header that already carries the
icon — the icon shows once per group, children just align under its text. */
.perm-row-noicon {
padding-left: 30px;
}
.perm-row > div {
display: flex;
min-width: 0;
@ -5447,43 +5453,226 @@ select:focus-visible,
flex-shrink: 0;
}
.hint-strip {
margin-top: 12px;
padding: 9px 14px;
border: 1px dashed #e3d2b2;
border-radius: 10px;
background: #fbf4e7;
color: #8a7a60;
font-size: var(--nex-text-2xs);
/* ---- 空间清理 v2: sticky summary + category accordions ----------------- */
.space-sum {
display: flex;
align-items: center;
gap: 14px;
padding: 13px 20px;
border: 1px solid #f2ddba;
border-radius: 14px;
background: linear-gradient(135deg, #fff7ea, #ffefdb);
box-shadow: 0 10px 24px rgba(150, 106, 40, 0.08);
}
.category-slot {
position: relative;
.space-sum .grow {
flex: 1;
min-width: 0;
}
.opt-tag {
position: absolute;
top: -8px;
right: 8px;
z-index: 2;
/* Sits over the card corner where the checkbox lives: it is a label,
never a click target, so the tick underneath stays hittable. */
pointer-events: none;
border-radius: 99px;
padding: 2px 9px;
background: #3f6bbd;
color: #fff;
font-size: 10px;
.space-sum .big {
color: var(--nex-ink);
font-size: 19px;
font-weight: var(--nex-weight-bold);
}
.category-slot .category-card {
height: 100%;
.space-sum .big em {
font-style: normal;
color: var(--nex-primary);
}
.category-slot:has(.opt-tag) .category-card {
border-style: dashed;
border-color: #b9c6e4;
.space-sum .sub {
margin-top: 3px;
color: #9a8a6d;
font-size: var(--nex-text-3xs);
}
.space-sec {
display: flex;
align-items: baseline;
gap: 10px;
margin: 22px 2px 8px;
}
.space-sec h2 {
color: var(--nex-ink);
font-size: 14px;
font-weight: var(--nex-weight-bold);
}
.space-sec .tip {
color: #97a2b0;
font-size: var(--nex-text-3xs);
}
.space-sec .r {
margin-left: auto;
color: #97a2b0;
font-size: var(--nex-text-3xs);
}
.space-sec .r b {
color: var(--nex-primary);
font-size: 13px;
}
.space-sec .r.is-opt b {
color: #2fa06b;
}
.space-cat {
margin-bottom: 8px;
overflow: hidden;
border: 1px solid rgba(47, 87, 126, 0.08);
border-radius: 12px;
background: rgba(255, 253, 248, 0.92);
box-shadow: var(--shadow-card);
}
.space-cat-head {
display: flex;
align-items: center;
gap: 11px;
padding: 12px 16px;
cursor: pointer;
}
.space-cat-head:hover {
background: rgba(255, 248, 235, 0.7);
}
.space-cat-icon {
display: grid;
flex: 0 0 auto;
place-items: center;
width: 26px;
height: 26px;
border-radius: 8px;
color: #fff;
background: var(--tone);
}
.space-cat-name {
flex: 0 0 auto;
color: var(--nex-ink);
font-size: var(--nex-text-2xs);
font-weight: var(--nex-weight-semibold);
}
.space-cat-desc {
overflow: hidden;
flex: 1;
min-width: 0;
color: #99a4b2;
font-size: var(--nex-text-3xs);
text-overflow: ellipsis;
white-space: nowrap;
}
.space-cat-n {
flex: 0 0 auto;
color: #a5aebb;
font-size: var(--nex-text-3xs);
}
.space-cat-size {
flex: 0 0 auto;
color: var(--nex-primary);
font-size: 13px;
font-weight: var(--nex-weight-semibold);
}
.space-cat-size.is-opt {
color: #2fa06b;
}
.space-cat-chv {
flex: 0 0 auto;
color: #b7bfca;
transition: transform 0.15s ease;
}
.space-cat.is-open .space-cat-chv {
transform: rotate(90deg);
}
.space-cat-items {
border-top: 1px dashed #eee0c8;
background: rgba(255, 254, 251, 0.9);
}
.space-item {
display: flex;
align-items: center;
gap: 11px;
padding: 9px 16px 9px 46px;
border-top: 1px solid #f6efe2;
cursor: pointer;
}
.space-item:first-child {
border-top: 0;
}
.space-item:hover {
background: rgba(253, 244, 228, 0.75);
}
.space-item.is-locked {
cursor: default;
}
.space-item.is-locked:hover {
background: transparent;
}
.space-item-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-item-path {
flex: 1 1 auto;
overflow: hidden;
min-width: 0;
color: #8b98a8;
font-family: Consolas, "Courier New", monospace;
font-size: var(--nex-text-3xs);
text-overflow: ellipsis;
white-space: nowrap;
}
.space-item-meta {
flex: 0 0 auto;
padding: 1px 8px;
border: 1px solid #ecd9b4;
border-radius: 99px;
color: #b3854d;
font-size: var(--nex-text-3xs);
}
.space-item-meta.is-locked {
border-color: #e5c8c8;
color: #a94c52;
}
.space-item-size {
flex: 0 0 auto;
color: #5a6776;
font-size: var(--nex-text-3xs);
font-weight: var(--nex-weight-semibold);
font-variant-numeric: tabular-nums;
}
.space-item-go {
flex: 0 0 auto;
color: #c0a06a;
}
.confirm-updater-actions {