import { X, Download } from "lucide-react"; import { useUpdate } from "@/contexts/UpdateContext"; import { useTranslation } from "react-i18next"; interface UpdateBadgeProps { className?: string; onClick?: () => void; } export function UpdateBadge({ className = "", onClick }: UpdateBadgeProps) { const { hasUpdate, updateInfo, isDismissed, dismissUpdate } = useUpdate(); const { t } = useTranslation(); // 如果没有更新或已关闭,不显示 if (!hasUpdate || isDismissed || !updateInfo) { return null; } return (
{ if (!onClick) return; if (e.key === "Enter" || e.key === " ") { e.preventDefault(); onClick(); } }} > v{updateInfo.availableVersion}
); }