/* eslint-disable @next/next/no-img-element */ import { AdSlot } from '@/components/GoogleAdsense' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' import { checkContainHttp, deepClone, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import { useState } from 'react' import CONFIG from '../config' /** * 游戏列表 * @returns */ export const GameListIndexCombine = ({ posts }) => { const gamesClone = deepClone(posts) // 构造一个List const components = [] // 根据序号随机大小;或根据game.recommend 决定 const recommend = siteConfig('GAME_INDEX_EXPAND_RECOMMEND', true, CONFIG) let index = 0 // 无限循环 if (recommend) { // 4合一卡组 let groupItems = [] while (gamesClone?.length > 0) { index++ // 广告位 if (index % 9 === 0) { components.push() continue } // 试图将4合一卡组塞满 while (gamesClone?.length > 0 && groupItems.length < 4) { const item = gamesClone.shift() index++ if ( item.tags?.some( t => t === siteConfig('GAME_RECOMMEND_TAG', 'Recommend', CONFIG) ) ) { components.push( ) continue } else { groupItems.push(item) } } if (groupItems.length === 4) { components.push() // 清空4合一卡片 groupItems = [] } else { // 剩余的4合一不满4个的给他放大卡 while (groupItems.length > 0) { const item = groupItems.shift() index++ components.push( ) } } } } else { while (gamesClone?.length > 0) { index++ if (index % 6 === 0) { components.push() } else if (index % 2 === 0 && gamesClone?.length >= 4) { // 如果是偶数,则从游戏列表中退出4个组成大卡牌 const groupItems = [] for (let i = 1; i <= 4; i++) { groupItems.push(gamesClone.shift()) } components.push() } else { const item = gamesClone.shift() components.push() } } } return (
{components?.map((ItemComponent, index) => { return ItemComponent })}
) } /** * 一个广告游戏大卡 * @returns */ const GameAd = () => { return (

{siteConfig('TITLE')}

{siteConfig('DESCRIPTION')}

) } /** * 大卡由2行2列小卡构成 * @param {*} param0 * @returns */ const GameItemGroup = ({ items }) => { return (
{items.map((item, index) => ( ))}
) } /** * 游戏=单卡 * @param {*} param0 * @returns */ const GameItem = ({ item, isLargeCard }) => { const { title } = item const img = item.pageCoverThumbnail const [showType, setShowType] = useState('img') // img or video const url = checkContainHttp(item.slug) ? sliceUrlFromHttp(item.slug) : `${siteConfig('SUB_PATH', '')}/${item.slug}` const video = item?.ext?.video return ( { setShowType('video') }} onMouseOut={() => { setShowType('img') }}>
{title}
{showType === 'video' && ( )} ) }