import { Check, Download, LoaderCircle, Monitor, RefreshCw, Sparkles, X, } from "lucide-react"; import { useI18n } from "../i18n"; import { formatBytes } from "../lib/format"; import type { UpdateFlow } from "../hooks/useUpdateFlow"; import type { Bootstrap } from "../types"; import { Badge, Button, Row, Section, Toggle } from "./ui"; function architectureLabel(arch: string): string { if (arch === "aarch64") return "ARM64"; if (arch === "x86_64") return "x64"; return arch; } export function UpdatePanel({ flow, autoCheck, onAutoCheckChange, bootstrap, }: { flow: UpdateFlow; autoCheck: boolean; onAutoCheckChange: (enabled: boolean) => void; bootstrap: Bootstrap; }) { const { t } = useI18n(); const status = flow.status; const verified = status?.state === "ready"; const available = status?.state === "available" || verified; const updateStateLabel = verified ? t("Downloaded and verified", "已下载并校验") : t("Update available", "发现新版本"); const statusError = status?.message && (status.state === "error" || status.state === "unavailable") ? status.message : null; return (
} title={t("Software updates", "软件更新")} actions={ } >
} title={t("Current system", "当前系统")} subtitle={bootstrap.osVersion || bootstrap.osName} tags={ <> {architectureLabel(bootstrap.arch)} Squid {bootstrap.version} } />
{available && status ? (
{updateStateLabel} Squid {status.currentVersion} {status.availableVersion}
{status.date ? : null}
) : null} {available && status?.notes ? (

{status.notes}

) : null} {flow.percent !== null ? (
{flow.progress?.state === "verifying" ? t("Verifying download…", "正在校验下载…") : t("Downloading update…", "正在下载更新…")} {flow.percent}%
{flow.progress ? `${formatBytes(flow.progress.downloaded)} / ${formatBytes( flow.progress.total, )}` : ""}
) : null} {statusError ? (
{statusError}
) : null} {flow.installError ? (
{flow.installError}
) : null}
{available && !verified ? ( ) : null} {verified ? ( ) : null} {verified && !flow.installing ? ( ) : null}
} />
); }