"use client"; import Link from "next/link"; import Image from "next/image"; interface HostLinkProps { host: { id: string; name: string; avatar: string; bio: string; link?: string }; /** 志愿者招募:无审核通过时显示「立即申请」+ 免费标识 */ ctaText?: string; showFreeBadge?: boolean; } /** 移动端优先尝试唤醒小红书 app,PC 新窗口打开 */ export default function HostLink({ host, ctaText, showFreeBadge }: HostLinkProps) { const href = "link" in host ? host.link : `/host/${host.id}`; const isXiaohongshu = typeof href === "string" && (href.includes("xhslink.com") || href.includes("xiaohongshu.com")); const handleClick = (e: React.MouseEvent) => { if (!isXiaohongshu || typeof href !== "string") return; const isMobile = /Android|iPhone|iPad|iPod|webOS|Mobile/i.test(navigator.userAgent); if (isMobile) { e.preventDefault(); // 移动端:同窗口打开,xhslink.com 会尝试唤起小红书 app,未安装则打开网页 window.location.assign(href); } }; if (typeof href !== "string") return null; return (
{host.bio}
{ctaText ?? "查看主页"} →