import { Download, LoaderCircle } from "lucide-react"; import { Link } from "react-router-dom"; import type { Resource } from "../api"; import { assetUrl } from "../api"; import { useI18n } from "../i18n"; import { useMemo, useState } from "react"; import { formatDateYmd } from "../utils/format"; import { officialRecommendationCoverFallbacks } from "./FigmaBanner"; import { downloadAttachment, downloadFile, } from "./messageStream/utils/downloadFile"; function isPlaceholderAsset(path: string | undefined | null) { return !path || path.includes("placeholder-cover"); } const CARD_CLASS = "group flex w-[208px] shrink-0 flex-col overflow-hidden rounded-xl border border-transparent bg-[#1D1E23] transition hover:border-ark-gold/55 md:w-[240px] md:border-ark-line md:bg-ark-panel lg:w-[246.4px] min-[1100px]:max-xl:w-[273px] xl:w-[246.4px]"; type RecommendedResource = Resource & { downloadPostId?: string; downloadAttachmentId?: string; }; export function RecommendedCard({ r, visualIndex = 0, useFigmaDesign = false, }: { r: RecommendedResource; visualIndex?: number; useFigmaDesign?: boolean; }) { const { t } = useI18n(); const [isDownloading, setIsDownloading] = useState(false); const figmaCover = officialRecommendationCoverFallbacks[ visualIndex % officialRecommendationCoverFallbacks.length ]; const cover = useMemo(() => { if (useFigmaDesign) return figmaCover; const original = r.coverImage || r.previewUrl; if (isPlaceholderAsset(original)) { return figmaCover; } return assetUrl(original); }, [figmaCover, r.coverImage, r.previewUrl, useFigmaDesign]); const displayTitle = useFigmaDesign ? "ARK 2026「共识加速计划」 🚀 邀请王霸榜 · 重磅回归" : r.title; const displayCategoryName = useFigmaDesign ? "项目资料" : r.categoryName; const dateStr = useFigmaDesign ? "2026-04-10" : formatDateYmd(r.updatedAt); const dateTime = useFigmaDesign ? "2026-04-10" : r.updatedAt; const dl = r.isDownloadable && (r.fileUrl || r.previewUrl) ? assetUrl(r.fileUrl || r.previewUrl) : ""; return (
{cover ? ( ) : (
)} {r.badgeLabel ? ( {r.badgeLabel} ) : null}
{displayTitle}
{displayCategoryName} ·
{dl ? ( ) : null}
); } export function ComingSoonRecommendedCard({ visualIndex = 0, }: { visualIndex?: number; }) { const cover = officialRecommendationCoverFallbacks[ visualIndex % officialRecommendationCoverFallbacks.length ]; return (
即将到来
即将到来
更多内容准备中
); }