import { useMemo } from 'react' import type { SituationUpdate, ConflictEvent } from '@/data/mockData' import { processTickerText } from '@/utils/tickerText' interface NewsTickerProps { updates?: SituationUpdate[] conflictEvents?: ConflictEvent[] className?: string } export function NewsTicker({ updates = [], conflictEvents = [], className = '' }: NewsTickerProps) { const items = useMemo(() => { const list: { id: string; text: string }[] = [] for (const e of conflictEvents || []) { const text = processTickerText(e.title || '') if (text) list.push({ id: `ev-${e.event_id}`, text }) } for (const u of updates || []) { const text = processTickerText(u.summary || '') if (text) list.push({ id: `up-${u.id}`, text }) } return list.slice(0, 30) }, [updates, conflictEvents]) const baseCls = 'flex items-center overflow-hidden' const defaultCls = 'border-b border-military-border/50 bg-military-panel/60 py-1.5' const wrapperCls = className ? `${baseCls} ${className}` : `${baseCls} ${defaultCls}` if (items.length === 0) { return (
滚动情报 暂无资讯
) } const content = items.map((i) => i.text).join(' ◆ ') const duration = Math.max(180, Math.min(480, content.length * 0.8)) return (
滚动情报
{content} {content}
) }