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 { Button, 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 (

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

{t("Current system", "当前系统")} {bootstrap.osName} {bootstrap.osVersion}
{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}
{t("Check for updates daily", "每天自动检查更新")} {t("At most once a day, when Squid starts.", "每天最多一次,在启动时进行。")}
); }