From 22eb0fcddb2f965b1032f1aa075197151b4b9472 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Wed, 25 Nov 2026 19:27:12 +0800 Subject: [PATCH] Unify the frontend on one component library --- CHANGELOG.md | 1 + src/components/ProcessTable.tsx | 74 +- src/components/SecuritySettingsCard.tsx | 434 ++++++----- src/components/SetupPanel.tsx | 42 +- src/components/UpdatePanel.tsx | 74 +- src/components/ui.tsx | 359 +++++++++ src/pages/ApplicationsPage.tsx | 215 +++--- src/pages/DuplicateFilesPage.tsx | 307 ++++---- src/pages/HistoryPage.tsx | 168 ++-- src/pages/LargeFilesPage.tsx | 244 +++--- src/pages/MaintenanceHubPage.tsx | 32 +- src/pages/MaintenancePage.tsx | 177 +++-- src/pages/OptimizationPage.tsx | 103 +-- src/pages/OverviewPage.tsx | 305 ++++---- src/pages/PermissionsPage.tsx | 735 +++++++++--------- src/pages/PrivacyPage.tsx | 162 ++-- src/pages/SecurityPage.tsx | 201 ++--- src/pages/SettingsPage.tsx | 502 ++++++------ src/pages/SpaceHubPage.tsx | 32 +- src/pages/SpacePage.tsx | 461 +++++------ src/pages/SystemPage.tsx | 371 +++++---- src/pages/WidgetPage.tsx | 225 +++--- src/styles.css | 974 ++++++++++++++++++++++++ 23 files changed, 3803 insertions(+), 2395 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a513f..cade37a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Squid 的重要变更记录在这里。版本号使用语义化版本,日期 - 概览页采用新的三列指标布局,所有页面一级标题下不再重复二级描述。 - 主界面的更新提示现在直接打开“设置 → 更新”分区。 - macOS 隐藏仅依赖 Windows 服务的“系统维护”,权限管理只保留开机启动项页签。 +- 前端统一为一套标准组件库:页签、卡片、行、状态标签、工具栏与搜索框不再由各模块自行定义;空间清理三个页签与设置页一致,权限管理的开机启动项信息与其他模块一致。 ## [0.1.11] - 2026-11-22 diff --git a/src/components/ProcessTable.tsx b/src/components/ProcessTable.tsx index ac4f652..22c5419 100644 --- a/src/components/ProcessTable.tsx +++ b/src/components/ProcessTable.tsx @@ -17,10 +17,14 @@ import type { Finding, ProcessDetail, ProcessRow } from "../types"; import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace"; import { Button, + Chip, ConfirmDialog, EmptyState, InlineError, Modal, + SearchField, + Section, + Toolbar, useToast, } from "./ui"; @@ -224,55 +228,47 @@ export function ProcessTable({ if (error && !rows) return ; return ( -
-
- +
+ +
- - - - - +
-
+ {visible.length === 0 ? ( victim && void stop(victim)} onClose={() => setVictim(null)} /> -
+ ); } diff --git a/src/components/SecuritySettingsCard.tsx b/src/components/SecuritySettingsCard.tsx index f280eda..cb7e1a2 100644 --- a/src/components/SecuritySettingsCard.tsx +++ b/src/components/SecuritySettingsCard.tsx @@ -13,7 +13,17 @@ import { api } from "../lib/api"; import { messageFrom, shortPath } from "../lib/format"; import type { ScanSchedule, SecurityStatus } from "../types"; import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace"; -import { Button, ConfirmDialog, Select, Toggle, useToast } from "./ui"; +import { + Button, + ConfirmDialog, + IconButton, + Row, + Section, + Select, + Subhead, + Toggle, + useToast, +} from "./ui"; const SCHEDULES: [ScanSchedule, string, string][] = [ ["manual", "Only when I ask", "仅在我要求时"], @@ -110,21 +120,12 @@ export function SecuritySettingsCard({ }; return ( -
-
-
-

- - {t("Security", "安全")} -

-
-
- -
-
- {t("Scan schedule", "扫描计划")} - - {settings.scanSchedule === "manual" +
} title={t("Security", "安全")}> +
+ -
- ({ value, label: t(en, zh) }))} + onChange={(next) => void save({ scanSchedule: next })} + /> + } /> -
-
-
- {t("Notify on confirmed findings", "发现高危时通知")} - - {t( - "The banner and the tray report the same thing without it.", - "关闭后,应用内提示与托盘仍会显示相同状态。", - )} - -
- void save({ notifyOnFindings: next })} + void save({ notifyOnFindings: next })} + /> + } /> -
-
-
- {t("Auto-quarantine confirmed findings", "自动隔离已确认项")} - - {t( - "Confirmed findings only. A suspicious file is never moved on its own.", - "仅针对已确认发现,可疑项不会被自动移动。", - )} - -
- (next ? setConfirmAuto(true) : void save({ autoQuarantine: false }))} + + next ? setConfirmAuto(true) : void save({ autoQuarantine: false }) + } + /> + } /> -
-
-
- {t("Update rules automatically", "自动更新规则")} - - {intel.source === "pack" + -
- void save({ updateRules: next })} + ) + } + trailing={ + void save({ updateRules: next })} + /> + } + /> + + + + {intel.fallbackAvailable ? ( + + ) : null} +
+ } />
-
-
- {t("Rule pack", "规则包")} - - {rulesNote ?? - t( - "Rules are downloaded to this machine; nothing is ever sent out.", - "规则只下载到本机,不上传任何内容。", - )} - -
-
- - {intel.fallbackAvailable ? ( - - ) : null} -
-
- -
-
- {t("Scan exclusions", "安全扫描排除项")} - - {t( - "Separate from the cleanup whitelist. Nothing inside is reported.", - "与清理白名单彼此独立。被排除目录内的威胁不会上报。", - )} - -
+
+
-
+
{settings.scanExclusions.length === 0 ? ( -

+

{t("No folders are excluded from scanning.", "没有排除扫描的文件夹。")}

) : ( settings.scanExclusions.map((pattern) => ( -
- - - - {shortPath(pattern, 88)} - -
+ + + + } + title={{shortPath(pattern, 88)}} + trailing={ + setPendingRemove(pattern)} + disabled={busy} + > + + + } + /> )) )}
{settings.allowlist.length ? ( -
-
- {t("Trusted software", "已信任的软件")} - - {t( - `${settings.allowlist.length} rules quiet ordinary advisories. Confirmed threats are never trusted.`, - `${settings.allowlist.length} 条规则用于静默普通提示,已确认威胁永远不会被信任。`, - )} - -
-
+
+ +
{settings.allowlist.map((entry) => ( -
- - - - - {entry.kind === "publisher" - ? t("Publisher", "发布者") - : entry.kind === "path" - ? t("Folder", "文件夹") - : t("Note type", "提示类型")} - - - {entry.kind === "evidence" - ? t( - EVIDENCE_LABELS[entry.value]?.[0] ?? entry.value, - EVIDENCE_LABELS[entry.value]?.[1] ?? entry.value, - ) - : entry.kind === "path" - ? shortPath(entry.value, 88) - : entry.value} - - -
+ + + + } + title={ + + {entry.kind === "evidence" + ? t( + EVIDENCE_LABELS[entry.value]?.[0] ?? entry.value, + EVIDENCE_LABELS[entry.value]?.[1] ?? entry.value, + ) + : entry.kind === "path" + ? shortPath(entry.value, 88) + : entry.value} + + } + tags={ + + {entry.kind === "publisher" + ? t("Publisher", "发布者") + : entry.kind === "path" + ? t("Folder", "文件夹") + : t("Note type", "提示类型")} + + } + trailing={ + void untrust(entry.kind, entry.value)} + disabled={busy} + > + + + } + /> ))}
) : null} {settings.ignoredFindings.length ? ( -
-
- {t("Ignored findings", "已忽略的发现")} - - {t( - `${settings.ignoredFindings.length} dismissed. Future scans hide them until you restore them here.`, - `已忽略 ${settings.ignoredFindings.length} 项。在恢复之前,后续扫描不会再次报告。`, - )} - -
-
+
+ +
{settings.ignoredFindings.map((fingerprint) => ( -
- {shortPath(fingerprint, 88)} - -
+ if (match) { + void security + .dismiss(match.id, false) + .then((message) => push(message, "success")); + } else { + push( + t( + "This finding is not in the last scan — run a scan to restore it.", + "该发现不在上次扫描结果中,请先扫描再恢复。", + ), + "danger", + ); + } + }} + > + {t("Report again", "重新报告")} + + } + /> ))}
@@ -437,6 +449,6 @@ export function SecuritySettingsCard({ }} onClose={() => setPendingRemove(null)} /> -
+ ); } diff --git a/src/components/SetupPanel.tsx b/src/components/SetupPanel.tsx index 6a95cbe..219568a 100644 --- a/src/components/SetupPanel.tsx +++ b/src/components/SetupPanel.tsx @@ -15,7 +15,7 @@ import { api } from "../lib/api"; import { messageFrom } from "../lib/format"; import type { PermissionStatus, SecurityStatus } from "../types"; import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace"; -import { Button } from "./ui"; +import { Badge, Button, Row } from "./ui"; type State = "checking" | "granted" | "denied" | "unknown" | "not-required" | "error"; @@ -362,22 +362,30 @@ function SetupRow({ }) { const { t } = useI18n(); return ( -
- {icon} -
- - {title} - {optional ? {t("optional", "可选")} : null} - - {state.tone === "ok" ? : null} - {state.tone === "problem" ? : null} + {icon}} + title={title} + tags={ + <> + {optional ? {t("optional", "可选")} : null} + + {state.tone === "ok" ? : null} + {state.tone === "problem" ? : null} {state.label} - - - {note} - {code ? {code} : null} -
- {action ?
{action}
: null} -
+ + + } + subtitle={note} + detail={code ? {code} : undefined} + trailing={action} + /> ); } diff --git a/src/components/UpdatePanel.tsx b/src/components/UpdatePanel.tsx index f410c6f..48a383c 100644 --- a/src/components/UpdatePanel.tsx +++ b/src/components/UpdatePanel.tsx @@ -11,7 +11,7 @@ import { useI18n } from "../i18n"; import { formatBytes } from "../lib/format"; import type { UpdateFlow } from "../hooks/useUpdateFlow"; import type { Bootstrap } from "../types"; -import { Button, Toggle } from "./ui"; +import { Badge, Button, Row, Section, Toggle } from "./ui"; function architectureLabel(arch: string): string { if (arch === "aarch64") return "ARM64"; @@ -44,14 +44,11 @@ export function UpdatePanel({ : null; return ( -
-
-
-

- - {t("Software updates", "软件更新")} -

-
+
} + title={t("Software updates", "软件更新")} + actions={ -
- -
- - - -
- {t("Current system", "当前系统")} - - {bootstrap.osVersion || bootstrap.osName} - -
-
- {architectureLabel(bootstrap.arch)} - Squid {bootstrap.version} -
+ } + > +
+ + + + } + title={t("Current system", "当前系统")} + subtitle={bootstrap.osVersion || bootstrap.osName} + tags={ + <> + {architectureLabel(bootstrap.arch)} + Squid {bootstrap.version} + + } + />
{available && status ? ( @@ -188,17 +187,22 @@ export function UpdatePanel({ ) : null}
-
-
- {t("Check for updates daily", "每天自动检查更新")} - {t("At most once a day, when Squid starts.", "每天最多一次,在启动时进行。")} -
- + + } />
-
+ ); } diff --git a/src/components/ui.tsx b/src/components/ui.tsx index 0fcb060..d5342a7 100644 --- a/src/components/ui.tsx +++ b/src/components/ui.tsx @@ -15,6 +15,7 @@ import { LoaderCircle, PackageOpen, Puzzle, + Search, Trash2, X, } from "lucide-react"; @@ -795,6 +796,364 @@ export function SectionTitle({ ); } +/* ── Standard library ───────────────────────────────────────────────── + Every page composes these instead of inventing its own tab bar, row, + section card or status pill. The matching CSS lives in one place in + styles.css under the same names. */ + +export interface TabItem { + id: T; + label: ReactNode; + icon?: ReactNode; + badge?: ReactNode; + disabled?: boolean; +} + +export function Tabs({ + items, + value, + onChange, + label, + className = "", +}: { + items: TabItem[]; + value: T; + onChange: (next: T) => void; + label: string; + className?: string; +}) { + return ( +
+ {items.map((item) => ( + + ))} +
+ ); +} + +export function Chip({ + active = false, + count, + tone, + onClick, + children, +}: { + active?: boolean; + count?: ReactNode; + tone?: "danger"; + onClick?: () => void; + children: ReactNode; +}) { + return ( + + ); +} + +export function Segmented({ + value, + options, + onChange, + label, + className = "", +}: { + value: T; + options: { value: T; label: ReactNode }[]; + onChange: (next: T) => void; + label: string; + className?: string; +}) { + return ( +
+ {options.map((option) => ( + + ))} +
+ ); +} + +export function ChoiceCard({ + selected, + onClick, + icon, + title, + description, + disabled = false, +}: { + selected: boolean; + onClick: () => void; + icon?: ReactNode; + title: ReactNode; + description?: ReactNode; + disabled?: boolean; +}) { + return ( + + ); +} + +export function Section({ + icon, + title, + hint, + actions, + children, + className = "", +}: { + icon?: ReactNode; + title: ReactNode; + hint?: ReactNode; + actions?: ReactNode; + children: ReactNode; + className?: string; +}) { + return ( +
+
+
+ {icon ? {icon} : null} +
+

{title}

+ {hint ?

{hint}

: null} +
+
+ {actions ?
{actions}
: null} +
+ {children} +
+ ); +} + +export function Subhead({ + title, + hint, + action, +}: { + title: ReactNode; + hint?: ReactNode; + action?: ReactNode; +}) { + return ( +
+
+

{title}

+ {hint ? {hint} : null} +
+ {action ?
{action}
: null} +
+ ); +} + +export function Row({ + leading, + title, + subtitle, + detail, + tags, + trailing, + children, + onClick, + selected = false, + muted = false, + busy = false, + className = "", +}: { + leading?: ReactNode; + title: ReactNode; + subtitle?: ReactNode; + detail?: ReactNode; + tags?: ReactNode; + trailing?: ReactNode; + children?: ReactNode; + onClick?: () => void; + selected?: boolean; + muted?: boolean; + busy?: boolean; + className?: string; +}) { + const body = ( + <> + {leading ?
{leading}
: null} +
+
+ {title} + {tags} +
+ {subtitle ?
{subtitle}
: null} + {detail ?
{detail}
: null} + {children} +
+ {trailing ?
{trailing}
: null} + + ); + const classes = `row ${onClick ? "is-clickable" : ""} ${selected ? "is-selected" : ""} ${ + muted ? "is-muted" : "" + } ${busy ? "is-busy" : ""} ${className}`; + return ( +
{ + if (event.key === "Enter" || event.key === " ") { + event.preventDefault(); + onClick(); + } + } + : undefined + } + > + {body} +
+ ); +} + +export function Badge({ + tone = "neutral", + children, + className = "", + title, +}: { + tone?: "neutral" | "success" | "warning" | "danger" | "info" | "primary"; + children: ReactNode; + className?: string; + title?: string; +}) { + return ( + + {children} + + ); +} + +export function Toolbar({ + children, + className = "", +}: { + children: ReactNode; + className?: string; +}) { + return
{children}
; +} + +export function SearchField({ + value, + onChange, + placeholder, + label, + className = "", +}: { + value: string; + onChange: (next: string) => void; + placeholder: string; + label: string; + className?: string; +}) { + return ( + + ); +} + +export function Notice({ + tone = "info", + icon, + children, + actions, +}: { + tone?: "info" | "warning" | "danger"; + icon?: ReactNode; + children: ReactNode; + actions?: ReactNode; +}) { + return ( +
+ {icon ? {icon} : null} +
{children}
+ {actions ?
{actions}
: null} +
+ ); +} + +export function Stat({ + icon, + label, + value, + hint, + tone, + children, +}: { + icon?: ReactNode; + label: ReactNode; + value: ReactNode; + hint?: ReactNode; + tone?: string; + children?: ReactNode; +}) { + return ( +
+
+ {icon ? {icon} : null} + {label} +
+ {value} + {hint ? {hint} : null} + {children} +
+ ); +} + export function CategoryCard({ category, total, diff --git a/src/pages/ApplicationsPage.tsx b/src/pages/ApplicationsPage.tsx index 5248ccf..a23300c 100644 --- a/src/pages/ApplicationsPage.tsx +++ b/src/pages/ApplicationsPage.tsx @@ -17,14 +17,20 @@ import { formatBytes, formatCount, messageFrom, shortPath } from "../lib/format" import type { AppInfo, DeleteMode } from "../types"; import type { AppsWorkspace } from "../hooks/useAppsWorkspace"; import { + Badge, Button, Checkbox, ConfirmDialog, EmptyState, InlineError, + Notice, PageHeader, ProgressCard, ResultSummary, + Row, + SearchField, + Section, + Segmented, categoryLabel, lockLabel, useToast, @@ -60,40 +66,49 @@ function AppRow({ const letter = app.name.trim().slice(0, 1).toUpperCase() || "?"; const badge = sourceBadge(app.source); return ( - + + } + subtitle={app.bundle_id || shortPath(app.path, 45)} + trailing={ + <> + + {formatBytes(app.size)} + {app.version ? `v${app.version}` : app.publisher || app.source} + + + + } + /> ); } export function ApplicationsPage({ @@ -203,30 +218,26 @@ export function ApplicationsPage({ {workspace.scanned && !workspace.scanning && !workspace.summary ? (
-
-
-
-

{t("Installed applications", "已安装应用")}

-

- {t( - `${formatCount(workspace.apps.length)} apps · ${formatBytes( - workspace.total, - )}`, - `${formatCount(workspace.apps.length)} 个应用 · ${formatBytes( - workspace.total, - )}`, - )} -

-
- -
+
+ } + >
{apps.map((app) => ( ) : null}
-
+
-
-
+
{workspace.plan.items.map((item, index) => ( -
workspace.togglePlanItem(index)} + label={item.label} + /> + } + title={item.label} + subtitle={shortPath(item.displayPath, 44)} + detail={`${categoryLabel(item.category, lang, bin)}${ + item.note ? ` · ${item.note}` : "" + }${item.lock ? ` · ${lockLabel(item.lock, t)}` : ""}`} + trailing={{formatBytes(item.onDisk)}} + muted={Boolean(item.lock)} onClick={() => { if (!item.lock) workspace.togglePlanItem(index); }} - > - workspace.togglePlanItem(index)} - label={item.label} - /> - - {item.label} - {shortPath(item.displayPath, 44)} - - {categoryLabel(item.category, lang, bin)} - {item.note ? ` · ${item.note}` : ""} - {item.lock ? ` · ${lockLabel(item.lock, t)}` : ""} - - - {formatBytes(item.onDisk)} -
+ /> ))}
@@ -442,22 +454,31 @@ export function ApplicationsPage({ busy={workspace.deleting} icon={} > -
- - -
+ + + {bin} + + ), + }, + { + value: "permanent", + label: ( + <> + + {t("Permanent", "永久")} + + ), + }, + ]} + /> {workspace.deleting ? ( diff --git a/src/pages/DuplicateFilesPage.tsx b/src/pages/DuplicateFilesPage.tsx index 6594216..2a822ee 100644 --- a/src/pages/DuplicateFilesPage.tsx +++ b/src/pages/DuplicateFilesPage.tsx @@ -17,12 +17,18 @@ import { useI18n } from "../i18n"; import { agoLabel, formatBytes, formatCount } from "../lib/format"; import { keepIndexOf, useDuplicatesWorkspace } from "../hooks/useDuplicatesWorkspace"; import { + Badge, Button, Checkbox, EmptyState, + IconButton, InlineError, + Notice, PageHeader, ProgressCard, + Row, + Segmented, + Toolbar, useToast, } from "../components/ui"; import { CleanBar } from "../components/CleanBar"; @@ -75,97 +81,94 @@ function DupGroupCard({ // the strategy stays visible, and adds a warning when it gets picked. const keepPicked = picked?.has(keep) ?? false; return ( -
-
-
- - {group.copies.length} {t("copies", "份相同")} - - {group.copies[keep]?.path.split(/[\\/]/).pop()} - - {t("wastes", "重复浪费")} {formatBytes(wasted)} - - {keepPicked ? ( - - {t("group will be empty", "本组将一份不剩")} - - ) : null} - {group.personal ? ( - - - {t("personal files", "个人文件")} - - ) : null} -
-
- {formatBytes(group.size)} {t("each", "/ 份")} -
- -
-
    +
    + + + {group.copies.length} {t("copies", "份相同")} + + + {t("wastes", "重复浪费")} {formatBytes(wasted)} + + {keepPicked ? ( + {t("group will be empty", "本组将一份不剩")} + ) : null} + {group.personal ? ( + + + {t("personal files", "个人文件")} + + ) : null} + + } + subtitle={t( + `${formatBytes(group.size)} each`, + `每份 ${formatBytes(group.size)}`, + )} + trailing={ + onDismiss(index)} + > + + + } + /> +
    {group.copies.map((copy, copyIndex) => { const isKeep = copyIndex === keep; const checked = picked?.has(copyIndex) ?? false; return ( -
  • - onToggle(index, copyIndex)} - label={copy.path} - /> - {isKeep ? ( - onToggle(index, copyIndex)} + label={copy.path} + /> + } + title={copy.path} + tags={ + <> + {isKeep ? ( + + {checked + ? t("keep · deleting", "保留 · 已勾选删除") + : t("keep", "保留")} + + ) : null} + {copy.locked ? ( + + + + ) : null} + + } + subtitle={copy.mtimeMs ? agoLabel(copy.mtimeMs, lang) : undefined} + trailing={ + + void apiClient.api.revealPath(copy.path).catch(() => undefined) } > - {checked ? t("keep · deleting", "保留 · 已勾选删除") : t("keep", "保留")} - - ) : null} - - {copy.locked ? ( - - - - ) : null} - - {copy.path} - - - {copy.mtimeMs ? agoLabel(copy.mtimeMs, lang) : ""} - - -
  • + + + } + /> ); })} -
+
); } @@ -280,18 +283,15 @@ export function DuplicateFilesPage({ {t("Min size", "最小体积")} -
- {MIN_SIZE_OPTIONS.map((option) => ( - - ))} -
+ ({ + value: option.value, + label: option.label, + }))} + /> - - + - - {formatCount(groups.length)} {t("groups · duplicate copies", "组 · 重复副本")}{" "} - {formatCount(groups.reduce((sum, g) => sum + g.copies.length - 1, 0))} ·{" "} - {formatBytes(visibleWasted)} - {empties > 0 ? ( - - {t( - `${formatCount(empties)} group(s) will be fully removed`, - ` · ${formatCount(empties)} 组将一份不剩`, - )} - - ) : null} - + - + + {confirming ? ( -
0 ? "is-strict" : ""}`}> - -
- - {lang === "zh" - ? `将 ${workspace.selectedCount} 个副本(${formatBytes(workspace.selectedBytes)})移入回收站?` - : `Move ${workspace.selectedCount} copies (${formatBytes(workspace.selectedBytes)}) to the Recycle Bin?`} - - {empties > 0 ? ( - - {lang === "zh" - ? `${formatCount(empties)} 组勾选了最后保留版本——这 ${formatCount(empties)} 组将被完全删除!` - : `${formatCount(empties)} group(s) include the kept copy — they will be deleted entirely!`} - - ) : ( - - {t( - "Every group keeps at least one copy; a mis-click is one Undo away from History.", - "每组至少保留一份;误删可从「历史记录 → 撤销」找回。", - )} - - )} - - {t( - "Deletions land in the Recycle Bin — undo from History.", - "删除一律进回收站,可从「历史记录 → 撤销」找回。", + 0 ? "danger" : "warning"} + icon={} + actions={ + <> + + + + } + > + + {lang === "zh" + ? `将 ${workspace.selectedCount} 个副本(${formatBytes(workspace.selectedBytes)})移入回收站?` + : `Move ${workspace.selectedCount} copies (${formatBytes(workspace.selectedBytes)}) to the Recycle Bin?`} + +
+ {empties > 0 + ? t( + `${formatCount(empties)} group(s) include the kept copy — they will be deleted entirely!`, + `${formatCount(empties)} 组勾选了最后保留版本——这 ${formatCount(empties)} 组将被完全删除!`, + ) + : t( + "Every group keeps at least one copy; a mis-click is one Undo away from History.", + "每组至少保留一份;误删可从「历史记录 → 撤销」找回。", )} -
-
- - -
+
+ {t( + "Deletions land in the Recycle Bin — undo from History.", + "删除一律进回收站,可从「历史记录 → 撤销」找回。", + )} + ) : null}
{entries.map(({ group, index }) => ( diff --git a/src/pages/HistoryPage.tsx b/src/pages/HistoryPage.tsx index c8ce852..55fdb0c 100644 --- a/src/pages/HistoryPage.tsx +++ b/src/pages/HistoryPage.tsx @@ -19,11 +19,16 @@ import { } from "../lib/format"; import type { HistorySession } from "../types"; import { + Badge, Button, ConfirmDialog, EmptyState, + IconButton, InlineError, PageHeader, + Row, + Section, + Stat, useToast, } from "../components/ui"; @@ -105,25 +110,17 @@ export function HistoryPage() { {error ? : null} {sessions.length > 0 ? ( -
-
- {t("Space kept clean", "当前已释放")} - {formatBytes(totalKept)} -
-
- {t("Cleanup sessions", "清理记录")} - {formatCount(sessions.length)} -
-
- {t("Restorable sessions", "可还原记录")} - - {formatCount( - sessions.filter( - (session) => session.mode === "trash" && !session.restored, - ).length, - )} - -
+
+ + + session.mode === "trash" && !session.restored, + ).length, + )} + />
) : null} @@ -151,50 +148,52 @@ export function HistoryPage() { session.entries.some((entry) => entry.trash_path); const isOpen = expanded === session.id; return ( -
- + } + title={ + session.command.replace(/^Squid · /, "") || t("Cleanup", "清理") + } + subtitle={`${formatDate(session.started, lang)} · ${ + session.mode === "trash" + ? t(`Moved to ${bin}`, `已移入${bin}`) + : t("Permanently removed", "已永久删除") + }`} + tags={ + session.restored ? ( + + + {t("Restored", "已还原")} + + ) : undefined + } + trailing={ + <> + + {formatBytes(bytes)} + + {formatCount(session.removed)} {t("items", "项")} + {session.failed > 0 + ? ` · ${session.failed} ${t("failed", "失败")}` + : ""} + + + + {(session.duration_ms / 1000).toFixed(1)}s + + + + } + onClick={() => setExpanded(isOpen ? null : session.id)} + /> {isOpen ? (
@@ -216,30 +215,29 @@ export function HistoryPage() { ) : null}
-
+
{session.entries.slice(0, 40).map((entry, index) => ( -
- - - {shortPath(entry.path, 78)} - - {entry.category || entry.kind} - {entry.trash_path - ? ` · ${t(`in ${bin}`, `位于${bin}`)}` - : ""} - - - {formatBytes(entry.allocated || entry.logical)} - -
+ + {formatBytes(entry.allocated || entry.logical)} + + void api.revealPath(entry.path).catch(() => undefined) + } + > + + + + } + /> ))}
diff --git a/src/pages/LargeFilesPage.tsx b/src/pages/LargeFilesPage.tsx index c0c0d1e..46a8827 100644 --- a/src/pages/LargeFilesPage.tsx +++ b/src/pages/LargeFilesPage.tsx @@ -18,12 +18,18 @@ import { subscribeJobProgress } from "../lib/api"; import { useI18n } from "../i18n"; import { agoLabel, formatBytes, formatCount, messageFrom } from "../lib/format"; import { + Badge, Button, Checkbox, EmptyState, + IconButton, InlineError, + Notice, PageHeader, ProgressCard, + Row, + Segmented, + Toolbar, useToast, } from "../components/ui"; import { CleanBar } from "../components/CleanBar"; @@ -191,54 +197,45 @@ export function LargeFilesPage({
{t("Scope", "范围")} -
- - {["C:", "D:", "E:"].map((drive) => ( - - ))} -
+ setScope(next ? [next] : [])} + options={[ + { value: "", label: t("All local drives", "全部本地磁盘") }, + ...["C:", "D:", "E:"].map((drive) => ({ + value: `${drive}\\`, + label: drive, + })), + ]} + /> {t("At least", "阈值")} -
- {THRESHOLDS.map((option) => ( - - ))} -
+ ({ + value: option.value, + label: option.label, + }))} + /> {t("Type", "类型")} -
- {CLASSES.map((option) => { + { const Icon = option.icon; - return ( - - ); + return { + value: option.id, + label: ( + <> + {lang === "zh" ? option.zh : option.en} + + ), + }; })} -
+ /> -
+
+ {confirming ? ( -
- -
- - {lang === "zh" - ? `将 ${pickedCount} 个大文件(${formatBytes(pickedBytes)})移入回收站?` - : `Move ${pickedCount} files (${formatBytes(pickedBytes)}) to the Recycle Bin?`} - - - {t( - "Undo from History while the Recycle Bin holds them.", - "回收站清空前,可随时在「历史记录」撤销。", - )} - -
- - -
+ } + actions={ + <> + + + + } + > + + {lang === "zh" + ? `将 ${pickedCount} 个大文件(${formatBytes(pickedBytes)})移入回收站?` + : `Move ${pickedCount} files (${formatBytes(pickedBytes)}) to the Recycle Bin?`} + +
+ {t( + "Undo from History while the Recycle Bin holds them.", + "回收站清空前,可随时在「历史记录」撤销。", + )} +
) : null} -
    +
    {visible.map((file, index) => { const Icon = CLASS_ICON[file.class] ?? HardDrive; const dormant = file.modifiedMs > 0 && (now - file.modifiedMs) / 1000 > DORMANT_SECS; return ( -
  • - toggle(file.path)} - label={file.displayPath} - /> - {String(index + 1).padStart(2, "0")} - - - -
    - {file.path.split(/[\\/]/).pop()} - {file.displayPath} -
    - {dormant ? ( - - {agoLabel(file.modifiedMs, lang)} {t("untouched", "未修改")} + + toggle(file.path)} + label={file.displayPath} + /> + + {String(index + 1).padStart(2, "0")} + + + + - ) : null} - {file.cloudHint ? ( - - {t("cloud copy?", "网盘可能有副本?")} - - ) : null} - {file.maybeMounted ? ( - - {t("check in use", "占用检查")} - - ) : null} - {formatBytes(file.size)} - -
  • + } + title={file.path.split(/[\\/]/).pop()} + tags={ + <> + {dormant ? ( + + {agoLabel(file.modifiedMs, lang)} {t("untouched", "未修改")} + + ) : null} + {file.cloudHint ? ( + + {t("cloud copy?", "网盘可能有副本?")} + + ) : null} + {file.maybeMounted ? ( + + {t("check in use", "占用检查")} + + ) : null} + + } + detail={file.displayPath} + trailing={ + <> + {formatBytes(file.size)} + + void apiClient.api.revealPath(file.path).catch(() => undefined) + } + > + + + + } + /> ); })} -
+
) : null} diff --git a/src/pages/MaintenanceHubPage.tsx b/src/pages/MaintenanceHubPage.tsx index df28198..641d7bf 100644 --- a/src/pages/MaintenanceHubPage.tsx +++ b/src/pages/MaintenanceHubPage.tsx @@ -1,7 +1,7 @@ import { EyeOff, SlidersHorizontal, Wrench } from "lucide-react"; import { useEffect, useState } from "react"; import { useI18n } from "../i18n"; -import { EmptyState, PageHeader } from "../components/ui"; +import { EmptyState, PageHeader, Tabs } from "../components/ui"; import { MaintenancePage } from "./MaintenancePage"; import { PrivacyPage } from "./PrivacyPage"; import { OptimizationPage } from "./OptimizationPage"; @@ -56,26 +56,20 @@ export function MaintenanceHubPage({ -
- {TABS.map((item) => { + { const Icon = item.icon; - const badge = badges[item.id]; - return ( - - ); + return { + id: item.id, + label: t(item.en, item.zh), + icon: , + badge: badges[item.id] ?? undefined, + }; })} -
+ />
diff --git a/src/pages/MaintenancePage.tsx b/src/pages/MaintenancePage.tsx index 7208df9..3ccbaa1 100644 --- a/src/pages/MaintenancePage.tsx +++ b/src/pages/MaintenancePage.tsx @@ -12,19 +12,25 @@ import { api, subscribeJobProgress } from "../lib/api"; import { useI18n } from "../i18n"; import { messageFrom } from "../lib/format"; import { + Badge, Button, InlineError, + Notice, PageHeader, ProgressCard, + Row, + Section, useToast, } from "../components/ui"; import type { JobProgress, MaintenanceResult, MaintenanceTask } from "../types"; -const RISK_CHIP: Record = { - // [class, zh, en] - safe: ["is-safe", "安全", "Safe"], - admin: ["is-admin", "需要管理员", "Admin rights"], - slow: ["is-slow", "较慢", "Slow"], +const RISK_CHIP: Record< + MaintenanceTask["risk"], + [tone: "success" | "warning" | "neutral", zh: string, en: string] +> = { + safe: ["success", "安全", "Safe"], + admin: ["warning", "需要管理员", "Admin rights"], + slow: ["neutral", "较慢", "Slow"], }; export function MaintenancePage({ @@ -115,28 +121,56 @@ export function MaintenancePage({ )} {error ? setError(null)} /> : null} -
- - - {t( - "All repairs below touch only system caches / services / indexes — never your documents.", - "以下修复只影响系统缓存 / 服务 / 索引,不碰你的文档。", - )} - -
+ }> + {t( + "All repairs below touch only system caches / services / indexes — never your documents.", + "以下修复只影响系统缓存 / 服务 / 索引,不碰你的文档。", + )} + -
    - {tasks.map((task) => { - const [chipClass, chipZh, chipEn] = RISK_CHIP[task.risk]; - const isRunning = running === task.id; - return ( -
  • - - - -
    - {lang === "zh" ? task.titleZh : task.titleEn} - {lang === "zh" ? task.detailZh : task.detailEn} +
    +
    + {tasks.map((task) => { + const [chipTone, chipZh, chipEn] = RISK_CHIP[task.risk]; + const isRunning = running === task.id; + return ( + + + + } + title={lang === "zh" ? task.titleZh : task.titleEn} + subtitle={lang === "zh" ? task.detailZh : task.detailEn} + tags={ + <> + {lang === "zh" ? chipZh : chipEn} + {task.estimate} + + } + trailing={ + isRunning ? ( + + ) : ( + + ) + } + > {isRunning && progress ? ( ) : null} -
    - {task.estimate} - {lang === "zh" ? chipZh : chipEn} - {isRunning ? ( - - ) : ( - - )} -
  • - ); - })} - {tasks.length === 0 && !error ? ( -
  • - - {t("Loading the repair list…", "正在加载修复清单…")} -
  • - ) : null} -
+ + ); + })} + {tasks.length === 0 && !error ? ( +

+ {t("Loading the repair list…", "正在加载修复清单…")} +

+ ) : null} + + {result ? ( -
- {result.ok ? : } -
- - {result.ok - ? t("Repair completed", "修复完成") - : t("Repair stopped early", "修复提前停止")} - -
    - {result.steps.map((step, index) => ( -
  • - {step} -
  • - ))} -
- {result.outputTail ? ( -
- {t("Command output", "命令输出")} -
{result.outputTail}
-
- ) : null} -
- -
+ : } + actions={ + + } + > + + {result.ok + ? t("Repair completed", "修复完成") + : t("Repair stopped early", "修复提前停止")} + +
    + {result.steps.map((step, index) => ( +
  • + {step} +
  • + ))} +
+ {result.outputTail ? ( +
+ {t("Command output", "命令输出")} +
{result.outputTail}
+
+ ) : null} +
) : null} ); diff --git a/src/pages/OptimizationPage.tsx b/src/pages/OptimizationPage.tsx index ab1ad8b..06aa900 100644 --- a/src/pages/OptimizationPage.tsx +++ b/src/pages/OptimizationPage.tsx @@ -3,7 +3,16 @@ import { useCallback, useEffect, useState } from "react"; import { api } from "../lib/api"; import { useI18n } from "../i18n"; import { messageFrom } from "../lib/format"; -import { Button, InlineError, PageHeader, Toggle, useToast } from "../components/ui"; +import { + Badge, + Button, + InlineError, + PageHeader, + Row, + Section, + Toggle, + useToast, +} from "../components/ui"; import type { TweakState } from "../types"; export function OptimizationPage({ @@ -85,19 +94,16 @@ export function OptimizationPage({ )} {error ? setError(null)} /> : null} -
-
-

- {t("Everyday privacy & clarity", "常用隐私与界面")} -

- - {changed > 0 - ? t(`${changed} changed · revertable`, `已更改 ${changed} 项 · 可随时恢复`) - : t("Nothing changed yet", "尚未更改任何项")} - - {/* Embedded (维护 hub): the page header — and with it the restore - button — is hidden, so the group head carries it instead. */} - {embedded ? ( +
} + title={t("Everyday privacy & clarity", "常用隐私与界面")} + hint={ + changed > 0 + ? t(`${changed} changed · revertable`, `已更改 ${changed} 项 · 可随时恢复`) + : t("Nothing changed yet", "尚未更改任何项") + } + actions={ + embedded ? ( + ) : undefined + } + > +
+ {states.map((state) => ( + + {t("needs Explorer/Windows restart", "需重启 Explorer/系统生效")} + + ) : undefined + } + trailing={ + <> + + {state.risk === "safe" ? t("Safe", "安全") : t("Read the note", "看说明")} + + void flip(state, next)} + label={lang === "zh" ? state.titleZh : state.titleEn} + /> + + } + /> + ))} + {states.length === 0 && !error ? ( +

{t("Loading the catalog…", "正在加载目录…")}

) : null}
-
    - {states.map((state) => ( -
  • -
    - - {lang === "zh" ? state.titleZh : state.titleEn} - {state.restartHint && state.enabled ? ( - - {t("needs Explorer/Windows restart", "需重启 Explorer/系统生效")} - - ) : null} - - {lang === "zh" ? state.detailZh : state.detailEn} - - {state.hive}\\{state.key} · {state.value} - -
    - - {state.risk === "safe" ? t("Safe", "安全") : t("Read the note", "看说明")} - - void flip(state, next)} - label={lang === "zh" ? state.titleZh : state.titleEn} - /> -
  • - ))} -
- {states.length === 0 && !error ? ( -

{t("Loading the catalog…", "正在加载目录…")}

- ) : null} -
+
); } diff --git a/src/pages/OverviewPage.tsx b/src/pages/OverviewPage.tsx index c044af5..aaaf5d4 100644 --- a/src/pages/OverviewPage.tsx +++ b/src/pages/OverviewPage.tsx @@ -25,7 +25,9 @@ import { Button, PageHeader, ProgressCard, - SectionTitle, + Row, + Section, + Stat, UsageBar, } from "../components/ui"; @@ -59,11 +61,12 @@ function SpecRow({ t: (en: string, zh: string) => string; }) { return ( -
- {icon} - {label} - {value || t("—", "—")} -
+ {icon}
} + title={label} + detail={{value || t("—", "—")}} + /> ); } @@ -274,20 +277,20 @@ export function OverviewPage({ ) : null} {scanned && !scanning ? ( -
- onNavigate("space")}> - {t("Open space cleaning", "打开空间清理")} - - - } - /> +
onNavigate("space")}> + {t("Open space cleaning", "打开空间清理")} + + + } + > {cleanup.result ? ( onNavigate("space")} /> ) : null} -
+
) : null} - {/* 指标行 30% / 42% / 28%:处理器+内存共用一框上下分布;存储每盘 - 一行;日常维护三入口竖排放右列,与左两卡等高。独立的「日常维护」 - 区块随此改版取消。 */}
-
-
-
- - - -
- {t("Processor", "处理器")} - - {snapshot - ? `${snapshot.cpu.physical_cores} ${t("cores", "核")} / ${snapshot.cpu.logical_cores} ${t("threads", "线程")}` - : t("Sampling…", "正在采样…")} - -
- {Math.round(snapshot?.cpu.total ?? 0)}% -
- - - {snapshot?.cpu.brand || t("Processor details unavailable", "暂无处理器信息")} - -
-
-
- - - -
- {t("Memory", "内存")} - - {snapshot - ? `${formatMemory(snapshot.memory.used)} / ${formatMemory(memoryInstalled)}` - : t("Sampling…", "正在采样…")} - -
- - {Math.round( - snapshot ? percent(snapshot.memory.used, snapshot.memory.total) : 0, - )} - % - -
- - - {memoryReserved > 0 - ? t( - `Hardware reserved (integrated graphics): ${formatMemory(memoryReserved)}`, - `硬件保留(含核显):${formatMemory(memoryReserved)}`, - ) - : snapshot +
} + title={t("Live performance", "运行状态")} + > +
+ } + label={t("Processor", "处理器")} + value={`${Math.round(snapshot?.cpu.total ?? 0)}%`} + hint={ + snapshot + ? `${snapshot.cpu.physical_cores} ${t("cores", "核")} / ${snapshot.cpu.logical_cores} ${t("threads", "线程")}` + : t("Sampling…", "正在采样…") + } + > + + + {snapshot?.cpu.brand || t("Processor details unavailable", "暂无处理器信息")} + + + } + label={t("Memory", "内存")} + value={`${Math.round( + snapshot ? percent(snapshot.memory.used, snapshot.memory.total) : 0, + )}%`} + hint={ + snapshot + ? `${formatMemory(snapshot.memory.used)} / ${formatMemory(memoryInstalled)}` + : t("Sampling…", "正在采样…") + } + > + + + {memoryReserved > 0 ? t( - `${formatCount(snapshot.processes)} processes running`, - `${formatCount(snapshot.processes)} 个进程正在运行`, + `Hardware reserved (integrated graphics): ${formatMemory(memoryReserved)}`, + `硬件保留(含核显):${formatMemory(memoryReserved)}`, ) - : t("Reading activity", "正在读取活动")} - + : snapshot + ? t( + `${formatCount(snapshot.processes)} processes running`, + `${formatCount(snapshot.processes)} 个进程正在运行`, + ) + : t("Reading activity", "正在读取活动")} + +
-
-
-
- - - -
- {t("Storage", "存储空间")} - - {volumes.length > 0 - ? t( - `${volumes.length} drives`, - `${volumes.length} 个分区`, - ) - : t("Reading volumes…", "正在读取磁盘…")} - -
-
-
+
+
} + title={t("Storage", "存储空间")} + hint={ + volumes.length > 0 + ? t(`${volumes.length} drives`, `${volumes.length} 个分区`) + : t("Reading volumes…", "正在读取磁盘…") + } + > +
{volumes.slice(0, 4).map((volume) => { const usedPercent = percent(volume.total - volume.free, volume.total); return ( -
- - {driveLabel(volume)} - - - 85 ? "red" : "green"} - /> - - - {Math.round(usedPercent)}% - {t( - `total ${formatBytes(volume.total)} · ${formatBytes(volume.free)} free`, - `总 ${formatBytes(volume.total)} · 可用 ${formatBytes(volume.free)}`, - )} - -
+ {driveLabel(volume)} + } + subtitle={t( + `total ${formatBytes(volume.total)} · ${formatBytes(volume.free)} free`, + `总 ${formatBytes(volume.total)} · 可用 ${formatBytes(volume.free)}`, + )} + trailing={{Math.round(usedPercent)}%} + > + 85 ? "red" : "green"} + /> + ); })}
- -
- - - -
+
+
} + title={t("Shortcuts", "快捷入口")} + > +
+ + + + } + title={t("Uninstall apps", "卸载应用")} + subtitle={t("Remove apps and their leftovers", "连同残留一起彻底移除")} + trailing={} + onClick={() => onNavigate("applications")} + /> + + + + } + title={t("Large files", "大文件")} + subtitle={t("See what is taking up space", "查看空间都被什么占用")} + trailing={} + onClick={() => onOpenSpaceTab?.("big")} + /> + + + + } + title={t("Space cleaning", "空间清理")} + subtitle={t( + "Caches, logs and build artefacts in one scan", + "一次扫描清掉缓存、垃圾与构建产物", + )} + trailing={} + onClick={smartScan} + /> +
+
); diff --git a/src/pages/PermissionsPage.tsx b/src/pages/PermissionsPage.tsx index 9d5c771..0dc15b1 100644 --- a/src/pages/PermissionsPage.tsx +++ b/src/pages/PermissionsPage.tsx @@ -4,8 +4,8 @@ import { ChevronRight, FolderOpen, LayoutGrid, + Power, RefreshCw, - Search, ShieldCheck, Trash2, X, @@ -17,14 +17,22 @@ import { shortPath } from "../lib/format"; import type { PermissionsWorkspace } from "../hooks/usePermissionsWorkspace"; import type { StartupItem } from "../types"; import { + Badge, Button, + Chip, ConfirmDialog, EmptyState, IconButton, InlineError, + Notice, PageHeader, - SectionTitle, + Row, + SearchField, + Section, + Subhead, + Tabs, Toggle, + Toolbar, } from "../components/ui"; function scopeLabel(scope: string, t: (en: string, zh: string) => string): string { @@ -315,36 +323,32 @@ export function PermissionsPage({ } /> -
- {tabs.map((tab) => ( - - ))} -
+ ({ + id: tab.id, + label: tab.label, + badge: tab.count, + }))} + /> {workspace.error ? ( ) : null} {workspace.tab === "startup" ? ( -
- -
-
+
} + title={t("Startup items", "开机启动项")} + hint={t( + `${view.startupEnabledCount} of ${view.startupCount} entries start with Windows.`, + `共 ${view.startupCount} 项,其中 ${view.startupEnabledCount} 项已开启。`, + )} + > + +
{( [ ["all", "All", "全部"], @@ -353,22 +357,19 @@ export function PermissionsPage({ ["leftover", "Leftover", "残留"], ] as const ).map(([id, en, zh]) => ( - + ))}
-
-
+
{orderedGroups.map(([software, items]) => { const onCount = items.filter((item) => item.enabled && !isLeftover(item)).length; const allOn = onCount === items.length; @@ -395,32 +394,39 @@ export function PermissionsPage({ return (
0 && leftovers.length === items.length ? "is-leftover" : "" - }`} + className={`perm-group-card ${open ? "is-open" : ""}`} > -

toggleGroupOpen(software)}> - - {software} - {leftovers.length > 0 ? ( - - {t(`${leftovers.length} leftover`, `${leftovers.length} 个残留`)} - - ) : null} - - {allOn + + } + title={ + <> + {software} + {leftovers.length > 0 ? ( + + {t(`${leftovers.length} leftover`, `${leftovers.length} 个残留`)} + + ) : null} + + } + subtitle={ + allOn ? t("All on", "全部开启") : onCount === 0 ? t("All off", "已全部关闭") : t( `${onCount}/${items.length} on`, `部分开启 ${onCount}/${items.length}`, - )} - - event.stopPropagation()} - > + ) + } + trailing={ + event.stopPropagation()}> { @@ -442,86 +448,94 @@ export function PermissionsPage({ onChange={(next) => void workspace.toggleStartupGroup(groupIds, next)} label={`${software} master ${allOn ? "disable" : "enable"}`} /> - -

+ + } + onClick={() => toggleGroupOpen(software)} + /> {open ? ( -
+
{items.map((item) => { const [statusText, statusTone] = statusChip(item, t); const reveal = rowRevealPath(item); return ( -
-
-
- - {item.name}{" "} - {statusText} - - - {item.sourceLabel} · {scopeLabel(item.scope, t)} - {item.command ? ` · ${shortPath(item.command, 72)}` : ""} - - - {item.command || t("(no command line)", "(无命令行记录)")} - -
-
-
- {isLeftover(item) ? ( - + ) : null} + {reveal ? ( + void api.revealPath(reveal).catch(() => {})} + > + + + ) : null} + setRemovingIds([item.id])} - > - {t("Delete entry", "删除启动项")} - - ) : null} - {reveal ? ( - void api.revealPath(reveal).catch(() => {})} - > - - - ) : null} - void workspace.toggleStartup(item.id, next)} - label={`${item.name} ${item.enabled ? "disable" : "enable"}`} - /> -
-
+ onChange={(next) => void workspace.toggleStartup(item.id, next)} + label={`${item.name} ${item.enabled ? "disable" : "enable"}`} + /> + + } + /> ); })} {leftovers.length > 0 && leftovers.length < items.length ? ( -
- - - {t( - `${leftovers.length} leftover entries in this group — their programs are gone.`, - `该组有 ${leftovers.length} 个残留项:程序已不存在,只剩启动配置。`, - )} - - -
+ } + actions={ + + } + > + {t( + `${leftovers.length} leftover entries in this group — their programs are gone.`, + `该组有 ${leftovers.length} 个残留项:程序已不存在,只剩启动配置。`, + )} + ) : null}
) : null} @@ -529,13 +543,13 @@ export function PermissionsPage({ ); })} {startup.length === 0 ? ( -

+

{counts.all === 0 ? t("No matches.", "没有匹配的项目。") : t("Nothing here under this filter.", "当前筛选下没有项目。")}

) : null} -
+
) : null} {workspace.tab === "extensions" ? ( -
- -
-
+
} + title={t("Context menu handlers", "右键菜单扩展")} + hint={t( + "Unregistered handlers disappear immediately; Squid keeps a restore recipe for each.", + "取消注册后右键菜单立即消失;Squid 为每一项保留恢复配方。", + )} + > + +
{extCategories.map((point) => { const entries = groupedExtensions[point]; const on = entries.filter((e) => e.registered).length; return ( - + ); })}
- -
+ + {extGroups.map(([software, items]) => { const onCount = items.filter((entry) => entry.registered).length; const allOn = onCount === items.length; const open = isExtGroupOpen(software); return (
-

toggleExtGroupOpen(software)}> - - {software} - - {allOn + + } + title={software} + subtitle={ + allOn ? t("All on", "全部开启") : onCount === 0 ? t("All off", "已全部关闭") : t( `${onCount}/${items.length} on`, `部分开启 ${onCount}/${items.length}`, - )} - - event.stopPropagation()} - > + ) + } + trailing={ + event.stopPropagation()}> { @@ -654,37 +667,41 @@ export function PermissionsPage({ }} label={`${software} master ${allOn ? "disable" : "enable"}`} /> - -

+ + } + onClick={() => toggleExtGroupOpen(software)} + /> {open ? ( -
+
{items.map((entry) => ( -
-
-
- {entry.friendlyName ?? entry.name} - - {entry.publisher - ? `${t("Creator", "创建者")} ${entry.publisher} · ` - : ""} - {scopeLabel(entry.scope, t)} - {entry.module ? ` · ${shortPath(entry.module, 56)}` : ""} - {!entry.registered ? ` · ${t("removed", "已移除")}` : ""} - -
-
- void workspace.toggleExtension(entry.id, next)} - label={`${entry.name} ${entry.registered ? "remove" : "restore"}`} - /> -
+ title={entry.friendlyName ?? entry.name} + tags={ + !entry.registered ? ( + {t("removed", "已移除")} + ) : undefined + } + subtitle={ + <> + {entry.publisher + ? `${t("Creator", "创建者")} ${entry.publisher} · ` + : ""} + {scopeLabel(entry.scope, t)} + + } + detail={entry.module ?? entry.handler} + muted={!entry.registered} + busy={workspace.busyId === entry.id} + trailing={ + void workspace.toggleExtension(entry.id, next)} + label={`${entry.name} ${entry.registered ? "remove" : "restore"}`} + /> + } + /> ))}
) : null} @@ -692,19 +709,23 @@ export function PermissionsPage({ ); })} {extCategories.length === 0 ? ( -

{t("No matches.", "没有匹配的项目。")}

+

{t("No matches.", "没有匹配的项目。")}

) : null} -
+ ) : null} {workspace.tab === "advanced" ? ( -
-
+
} + title={t("Advanced startup", "进阶启动项")} + > + }> {t( "Advanced rows can break boot or logon if changed carelessly — Squid only displays them here, every change records its original value, and nothing is auto-disabled.", "进阶区的项目改错了可能影响系统行为——默认只展示不勾选,每一项带数字签名与位置说明;改动会原样记录,可逐项恢复。", )} -
+ {workspace.advancedScanning && !workspace.advanced ? (
@@ -717,7 +738,7 @@ export function PermissionsPage({
) : null} {workspace.advanced && workspace.advanced.entries.length === 0 ? ( -

+

{t( "No third-party Winlogon hooks, AppInit DLLs, IFEO debuggers or BHOs found — the machine is clean.", "没有发现第三方 Winlogon 挂钩、AppInit DLL、IFEO 调试器或 BHO——系统很干净。", @@ -735,139 +756,159 @@ export function PermissionsPage({ bho: ["Browser helper objects", "浏览器加载项 BHO"], }; return ( -

- + - {rows.map((entry) => ( -
- - {entry.signature === "microsoft" - ? t("Microsoft signed", "微软签名") - : entry.signature === "vendor" - ? t("Signed by", "已知厂商") - : entry.signature === "unsigned" - ? t("Not signed", "无数字签名") - : entry.signature === "invalid" - ? t("Signature invalid", "签名无效") - : t("Signature n/a", "无签名信息")} - -
- {entry.name} - {shortPath(entry.command, 90)} - {entry.location} - {entry.warning ? ( - {entry.warning} - ) : null} -
- void workspace.toggleAdvanced(entry.id, next)} - label={entry.name} +
+ {rows.map((entry) => ( + + {entry.signature === "microsoft" + ? t("Microsoft signed", "微软签名") + : entry.signature === "vendor" + ? t("Signed by", "已知厂商") + : entry.signature === "unsigned" + ? t("Not signed", "无数字签名") + : entry.signature === "invalid" + ? t("Signature invalid", "签名无效") + : t("Signature n/a", "无签名信息")} + + } + subtitle={shortPath(entry.command, 90)} + detail={ + entry.warning + ? `${entry.location} · ${entry.warning}` + : entry.location + } + busy={workspace.busyId === entry.id} + trailing={ + void workspace.toggleAdvanced(entry.id, next)} + label={entry.name} + /> + } /> -
- ))} + ))} +
); }) : null} {workspace.advanced && workspace.advanced.extras.length > 0 ? ( -
- + - {workspace.advanced.extras.map((entry) => ( -
- {scopeLabel(entry.scope, t)} -
- {entry.displayName || entry.name} - {shortPath(entry.command, 90)} - {entry.sourceLabel} -
- void workspace.toggleStartup(entry.id, next)} - label={entry.name} +
+ {workspace.advanced.extras.map((entry) => ( + {scopeLabel(entry.scope, t)}} + subtitle={shortPath(entry.command, 90)} + detail={entry.sourceLabel} + busy={workspace.busyId === entry.id} + trailing={ + void workspace.toggleStartup(entry.id, next)} + label={entry.name} + /> + } /> -
- ))} + ))} +
) : null} -
+ ) : null} {workspace.tab === "popup" ? ( <> -
- } + title={t("Popup blocker", "弹窗拦截")} + hint={t( + `Blocked ${workspace.closedTotal} popup windows since install.`, + `累计拦截 ${workspace.closedTotal} 次弹窗。`, + )} + actions={ void workspace.setWatcher(next)} label={t("Popup blocker switch", "弹窗拦截总开关")} /> - } - /> + } + > {workspace.recentClosed.length > 0 ? ( -
- - - {workspace.recentClosed[0].process} · {workspace.recentClosed[0].title} - -
+ }> + {workspace.recentClosed[0].process} · {workspace.recentClosed[0].title} + ) : null} -
+ -
- -
+
} + title={t("Rules", "拦截规则")} + hint={t( + "Each rule closes windows from one program whose title contains the text.", + "每条规则会关闭指定程序中标题包含该文字的窗口。", + )} + > +
{view.rules.map((rule, index) => ( -
-
+ -
- {rule.title} - - {shortPath(rule.exe, 64)} ·{" "} - {t(`closed ${rule.closed}×`, `已关闭 ${rule.closed} 次`)} - -
-
-
- void workspace.toggleRule(index, next)} - label={`${rule.title} ${rule.enabled ? "disable" : "enable"}`} - /> - void workspace.removeRule(index)} - > - - -
-
+ } + title={rule.title} + subtitle={`${shortPath(rule.exe, 64)} · ${t( + `closed ${rule.closed}×`, + `已关闭 ${rule.closed} 次`, + )}`} + trailing={ + <> + void workspace.toggleRule(index, next)} + label={`${rule.title} ${rule.enabled ? "disable" : "enable"}`} + /> + void workspace.removeRule(index)} + > + + + + } + /> ))} {view.rules.length === 0 ? ( -

+

{t( "No rules yet — pick a window below.", "还没有规则,先从下面的当前窗口里“拦截”一个。", @@ -875,16 +916,16 @@ export function PermissionsPage({

) : null}
-
+
-
- } + title={t("Current windows", "当前窗口")} + hint={t( + "Refresh, then block a noisy window or close it once.", + "刷新后可直接拦截某个烦人的窗口,或只关闭这一次。", + )} + actions={ - } - /> -
+ } + > +
{workspace.windows.map((window) => ( -
-
- -
- {window.title} - {window.process} -
-
-
- - void workspace.closeWindow(window.hwnd)} - > - - -
-
+ } + title={window.title} + subtitle={window.process} + detail={window.exe ?? undefined} + trailing={ + <> + + void workspace.closeWindow(window.hwnd)} + > + + + + } + /> ))}
-
+ ) : null} diff --git a/src/pages/PrivacyPage.tsx b/src/pages/PrivacyPage.tsx index 79044d1..d348aed 100644 --- a/src/pages/PrivacyPage.tsx +++ b/src/pages/PrivacyPage.tsx @@ -4,11 +4,15 @@ import { api } from "../lib/api"; import { useI18n } from "../i18n"; import { formatBytes, formatCount, messageFrom } from "../lib/format"; import { + Badge, Button, Checkbox, EmptyState, InlineError, + Notice, PageHeader, + Row, + Section, useToast, } from "../components/ui"; import type { CleanupItem } from "../types"; @@ -150,78 +154,108 @@ export function PrivacyPage({ )} {error ? setError(null)} /> : null} -
- {groups.map((group) => { - const Icon = SPEC_ICONS[group.ruleId] ?? ShieldQuestion; - const allOn = group.indexes.every((index) => picked.has(index)); - const warn = WARN_COPY[group.ruleId]; - return ( -
); } diff --git a/src/pages/SecurityPage.tsx b/src/pages/SecurityPage.tsx index 5d07dbe..688b18d 100644 --- a/src/pages/SecurityPage.tsx +++ b/src/pages/SecurityPage.tsx @@ -26,14 +26,17 @@ import { formatBytes, formatCount, messageFrom, shortPath } from "../lib/format" import type { Confidence, Finding, SecurityScan, SecurityStatus } from "../types"; import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace"; import { + Badge, Button, + Chip, ConfirmDialog, EmptyState, InlineError, Modal, PageHeader, ProgressCard, - SectionTitle, + Row, + Section, useToast, } from "../components/ui"; @@ -252,28 +255,25 @@ export function SecurityPage({ onToggleScope={() => setShowScope((current) => !current)} /> -
- - {filterOptions.map(([key, label, count]) => ( - - ))} - - ) : null - } - /> +
+ {filterOptions.map(([key, label, count]) => ( + setFilter(key)} + > + {label} + + ))} + + ) : null + } + > {!scan ? ( } @@ -309,7 +309,7 @@ export function SecurityPage({ } /> ) : ( -
    +
    {findings.map((finding) => ( ))} -
+ )} -
+
+
{unknown ? : }
{providerName} - + {unknown ? t("Could not be confirmed", "无法确认") : t("Read from the system", "来自系统")} - +

{t( @@ -589,7 +589,7 @@ function CoverageCard({ : t("Coverage was complete", "覆盖范围完整"); return ( -

+
{title} @@ -613,7 +613,7 @@ function CoverageCard({ )}

- + {lang === "zh" ? !scan ? "未扫描" @@ -625,7 +625,7 @@ function CoverageCard({ : restricted ? "limited" : "complete"} - +
{access === "denied" || access === "unknown" ? ( @@ -684,8 +684,8 @@ function CoverageCard({ "signed" because a signature would have been accepted if one had been configured is the kind of green that costs trust later. */} {intel.source === "pack" ? ( - + ) : null}
@@ -803,25 +803,31 @@ function FindingRow({ const { t } = useI18n(); const meta = CONFIDENCE_META[finding.confidence]; return ( -
  • - - - {finding.allowlisted ? t("Trusted", "已信任") : t(meta.en, meta.zh)} - {finding.quarantined ? ` · ${t("held", "已隔离")}` : ""} - -
    + + {finding.allowlisted ? t("Trusted", "已信任") : t(meta.en, meta.zh)} + {finding.quarantined ? ` · ${t("held", "已隔离")}` : ""} + + } + subtitle={finding.title} + detail={finding.displayPath ?? t("Machine state", "系统状态")} + muted={finding.quarantined || finding.allowlisted} + onClick={onOpen} + trailing={ +
    event.stopPropagation()}> {finding.path ? (
    -
  • + } + /> ); } @@ -932,32 +939,31 @@ function QuarantineCard({ const { t } = useI18n(); const items = status.quarantine; return ( -
    - } - onClick={() => void api.openQuarantineFolder().catch(() => undefined)} - > - {t("Open folder", "打开目录")} - - } - /> +
    } + onClick={() => void api.openQuarantineFolder().catch(() => undefined)} + > + {t("Open folder", "打开目录")} + + } + > {items.length === 0 ? (

    {t( @@ -966,17 +972,16 @@ function QuarantineCard({ )}

    ) : ( -
      +
      {items.map((item) => ( -
    • -
      - {item.displayPath} - - {item.title} · {formatBytes(item.size)} ·{" "} - {new Date(item.quarantinedMs).toLocaleString()} - -
      -
      + {item.displayPath}} + subtitle={`${item.title} · ${formatBytes(item.size)} · ${new Date( + item.quarantinedMs, + ).toLocaleString()}`} + trailing={ +
      -
    • + } + /> ))} -
    +
    )} -
    + ); } @@ -1015,10 +1021,7 @@ function ActivityCard({ const activity = status.activity; if (!activity.length) return null; return ( -
    - +
      {activity.slice(0, 10).map((entry, index) => (
    • @@ -1032,6 +1035,6 @@ function ActivityCard({ {t("Manage startup items", "管理启动项")} -
    +
    ); } diff --git a/src/pages/SettingsPage.tsx b/src/pages/SettingsPage.tsx index dc4407e..2bd6c2e 100644 --- a/src/pages/SettingsPage.tsx +++ b/src/pages/SettingsPage.tsx @@ -1,5 +1,4 @@ import { - Check, FileCog, FolderClock, FolderOpen, @@ -33,10 +32,16 @@ import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace"; import { SecuritySettingsCard } from "../components/SecuritySettingsCard"; import { UpdatePanel } from "../components/UpdatePanel"; import { + Badge, Button, + ChoiceCard, + IconButton, InlineError, PageHeader, + Row, Select, + Section, + Tabs, Toggle, useToast, } from "../components/ui"; @@ -230,150 +235,99 @@ export function SettingsPage({ {error ? setError(null)} /> : null} -
    - {SETTINGS_TABS.map((item) => { + { const Icon = item.icon; - return ( - - ); + return { + id: item.id, + label: t(item.labelEn, item.labelZh), + icon: , + }; })} -
    + /> {tab === "general" ? (
    -
    -
    -
    -

    - - {t("Language & appearance", "语言与外观")} -

    -
    -
    -
    - - + icon={} + title="English" + description="English (US)" + />
    -
    + -
    -
    -
    -

    - - {t("Startup", "启动")} -

    -
    -
    -
    -
    - {t("Launch Squid at login", "登录时启动 Squid")} - - {t( - "Only Squid itself; other apps are managed under Startup items.", - "仅 Squid 自身,其他程序请到启动项页面管理。", - )} - -
    +
    } title={t("Startup", "启动")}> + void setLaunchAtLogin(enabled)} disabled={autostart === null || savingAutostart} label={t("Launch Squid at login", "登录时启动 Squid")} /> -
    -
    + } + /> +
    ) : null} {tab === "cleanup" ? (
    -
    -
    -
    -

    - - {t("Deletion safety", "删除安全")} -

    -
    -
    -
    - - + icon={} + title={t("Remove permanently", "永久删除")} + description={t( + "No recovery for caches and rebuildable files.", + "缓存与可重建文件无法恢复。", + )} + />
    -
    -
    - {t("Report allocated size", "显示磁盘实际占用")} - - {t( - "Prefer on-disk bytes for sparse and compressed files.", - "对稀疏和压缩文件优先显示磁盘实际占用。", - )} - -
    + -
    -
    -
    - {t("History records to keep", "保留历史记录数量")} -
    + } + /> + void save({ historyKeep: next })} /> -
    -
    + } + /> + -
    -
    -
    -

    - - {t("Protected locations", "受保护的位置")} -

    -

    - {t( - "Never deleted here, even when a cleanup rule matches. The malware scan still reports inside them.", - "这里的内容绝不会被删除。恶意软件扫描仍会检查其中的发现。", - )} -

    -
    -
    +
    } + title={t("Protected locations", "受保护的位置")} + hint={t( + "Never deleted here, even when a cleanup rule matches. The malware scan still reports inside them.", + "这里的内容绝不会被删除。恶意软件扫描仍会检查其中的发现。", + )} + >
    ) : null} -
    +
    {settings.whitelist.length === 0 ? (

    {t("No protected folders yet.", "尚未设置受保护的文件夹。")}

    ) : ( settings.whitelist.map((pattern) => ( -
    - - - - {shortPath(pattern, 88)} - {audit ? ( - - {audit.get(pattern) - ? t("Recently matched", "最近命中") - : t("Never matched", "从未命中")} + + - ) : null} - -
    + } + title={{shortPath(pattern, 88)}} + tags={ + audit ? ( + + {audit.get(pattern) + ? t("Recently matched", "最近命中") + : t("Never matched", "从未命中")} + + ) : undefined + } + trailing={ + void removeWhitelist(pattern)} + disabled={saving} + > + + + } + /> )) )}
    -
    +
    ) : null} {tab === "security" ? ( <> {bootstrap.platform === "macos" ? ( -
    -
    -
    -

    - - {t("System permissions", "系统权限")} -

    -
    -
    -
    +
    } + title={t("System permissions", "系统权限")} + > + -
    - - {t("Full Disk Access", "完全磁盘访问权限")} - - {checkingPermission - ? t("Checking…", "检查中…") - : permission?.fullDiskAccess === "granted" - ? t("Granted", "已授权") - : permission?.fullDiskAccess === "denied" - ? t("Needs attention", "需要授权") - : t("Not confirmed", "未确认")} - - - - {t( - "Enables scans of TCC-protected caches, mail data and app leftovers.", - "用于扫描受 TCC 保护的缓存、邮件数据与应用卸载残留。", - )} - -
    -
    + } + title={t("Full Disk Access", "完全磁盘访问权限")} + tags={ + + {checkingPermission + ? t("Checking…", "检查中…") + : permission?.fullDiskAccess === "granted" + ? t("Granted", "已授权") + : permission?.fullDiskAccess === "denied" + ? t("Needs attention", "需要授权") + : t("Not confirmed", "未确认")} + + } + subtitle={t( + "Enables scans of TCC-protected caches, mail data and app leftovers.", + "用于扫描受 TCC 保护的缓存、邮件数据与应用卸载残留。", + )} + trailing={ +
    -
    -
    -
    +
    + } + /> +
    ) : null} {security.status ? ( ) : ( -
    +

    {t("Security settings are loading…", "安全设置加载中…")}

    -
    +
    )} ) : null} @@ -608,21 +554,15 @@ export function SettingsPage({ ) : null} {tab === "about" ? ( -
    -
    -
    -

    - - {t("About Squid", "关于 Squid")} -

    -

    - {t( - "Configuration and history stay local to this computer.", - "配置与历史记录仅保存在这台电脑上。", - )} -

    -
    -
    +
    } + title={t("About Squid", "关于 Squid")} + hint={t( + "Configuration and history stay local to this computer.", + "配置与历史记录仅保存在这台电脑上。", + )} + >
    @@ -636,49 +576,53 @@ export function SettingsPage({ {bootstrap.osVersion || bootstrap.osName} · {bootstrap.arch}
    -
    -
    - - - -
    - {t("Configuration", "配置文件")} - {bootstrap.configPath} -
    - -
    -
    - - - -
    - {t("History", "历史记录")} - {bootstrap.historyPath} -
    - -
    +
    + + + + } + title={t("Configuration", "配置文件")} + subtitle={{bootstrap.configPath}} + trailing={ + + } + /> + + + + } + title={t("History", "历史记录")} + subtitle={{bootstrap.historyPath}} + trailing={ + + } + />
    -
    +
    ) : null} ); diff --git a/src/pages/SpaceHubPage.tsx b/src/pages/SpaceHubPage.tsx index 6fe74d1..cb68de7 100644 --- a/src/pages/SpaceHubPage.tsx +++ b/src/pages/SpaceHubPage.tsx @@ -1,7 +1,7 @@ import { CopyX, Eraser, FileArchive } from "lucide-react"; import { useEffect, useState } from "react"; import { useI18n } from "../i18n"; -import { PageHeader } from "../components/ui"; +import { PageHeader, Tabs } from "../components/ui"; import { SpacePage } from "./SpacePage"; import { DuplicateFilesPage } from "./DuplicateFilesPage"; import { LargeFilesPage } from "./LargeFilesPage"; @@ -49,26 +49,20 @@ export function SpaceHubPage({ -
    - {TABS.map((item) => { + { const Icon = item.icon; - const badge = badges[item.id]; - return ( - - ); + return { + id: item.id, + label: t(item.en, item.zh), + icon: , + badge: badges[item.id] ?? undefined, + }; })} -
    + />
    -
    - onTick(!allOn)} - label={cluster.label} - /> - {cluster.label} - {dormancy !== null && dormancy >= DORMANT_SECS ? ( - - {t( - `${ageLabel(dormancy, "en").replace(" untouched", "")} dormant`, - ageLabel(dormancy, "zh").replace("未修改", "未使用"), - )} - - ) : null} - - {t( - `${formatCount(cluster.entries.length)} location(s)`, - `${formatCount(cluster.entries.length)} 个位置`, - )} - - - - - - {formatBytes(cluster.total)} -
    + onTick(!allOn)} + label={cluster.label} + /> + } + title={cluster.label} + tags={ + dormancy !== null && dormancy >= DORMANT_SECS ? ( + + {t( + `${ageLabel(dormancy, "en").replace(" untouched", "")} dormant`, + ageLabel(dormancy, "zh").replace("未修改", "未使用"), + )} + + ) : undefined + } + subtitle={t( + `${formatCount(cluster.entries.length)} location(s)`, + `${formatCount(cluster.entries.length)} 个位置`, + )} + trailing={ + <> + + + {formatBytes(cluster.total)} +