Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-10-26 17:51:31 +07:00
co-authored by Claude Opus 5.5
commit 61d0a11dfa
371 changed files with 35836 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
import { DecryptedImage } from "@/components/common/decrypted-image";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
import { adHref, adTrackProps, pickBannerAds } from "./pick";
type AdBannersProps = {
variant?: "pc" | "h5";
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
className?: string;
};
/** 公共 Banner 广告:对接 advitise.detailbannerList;无数据不渲染 */
export function AdBanners({
variant = "pc",
items,
advitise,
className = "",
}: AdBannersProps) {
const isH5 = variant === "h5";
const apiList = pickBannerAds(items, advitise);
if (!apiList.length) return null;
if (isH5) {
return (
<div
data-component="ad-banners"
data-variant="h5"
className={`flex flex-col gap-[18px] ${className}`}
>
{apiList.map((ad, index) => {
const href = adHref(ad.link, "#h5-download");
const external = Boolean(ad.link?.trim());
return (
<a
key={ad.id || `banner-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="block h-10 overflow-hidden rounded-xl"
{...adTrackProps(ad, {
slotKey: `content_banner_${index + 1}`,
slotName: `内容横幅第${index + 1}位`,
adType: "banner",
})}
>
<DecryptedImage
src={ad.images || null}
fallback={IMG_PLACEHOLDER}
alt={ad.title || "推广"}
className="h-full w-full object-cover"
/>
</a>
);
})}
</div>
);
}
return (
<div
data-component="ad-banners"
data-variant="pc"
className={`grid grid-cols-2 gap-5 ${className}`}
>
{apiList.map((ad, index) => {
const href = adHref(ad.link);
const external = Boolean(ad.link?.trim());
return (
<a
key={ad.id || `banner-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="block h-[97px] overflow-hidden rounded-xl"
{...adTrackProps(ad, {
slotKey: `content_banner_${index + 1}`,
slotName: `内容横幅第${index + 1}位`,
adType: "banner",
})}
>
<DecryptedImage
src={ad.images || null}
fallback={IMG_PLACEHOLDER}
alt={ad.title || "推广"}
className="h-full w-full object-cover"
/>
</a>
);
})}
</div>
);
}