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={ } onClick={() => void flow.check()} disabled={flow.checking || flow.downloading || !bootstrap.updateFeedUrl} > {flow.checking ? t("Checking…", "检查中…") : t("Check now", "立即检查")} } >
{status.notes}
) : null} {flow.percent !== null ? (