"use client"; import React, { useEffect, useRef } from "react"; interface PageHeroProps { title: string; subtitle?: string; locale?: string; } export function PageHero({ title, subtitle, locale = "zh-CN" }: PageHeroProps) { const canvasRef = useRef(null); useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext("2d"); if (!ctx) return; function resize() { if (!canvas) return; canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight; } window.addEventListener("resize", resize); resize(); const particles: Array<{ x: number; y: number; r: number; vx: number; vy: number; alpha: number; }> = []; if (canvas) { for (let i = 0; i < 60; i++) { particles.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, r: Math.random() * 1.8 + 0.6, vx: (Math.random() - 0.5) * 0.2, vy: (Math.random() - 0.5) * 0.2, alpha: Math.random() * 0.6 + 0.2, }); } } function draw() { if (!ctx || !canvas) return; ctx.clearRect(0, 0, canvas.width, canvas.height); for (const p of particles) { p.x += p.vx; p.y += p.vy; if (p.x < -10) p.x = canvas.width + 10; if (p.x > canvas.width + 10) p.x = -10; if (p.y < -10) p.y = canvas.height + 10; if (p.y > canvas.height + 10) p.y = -10; ctx.beginPath(); ctx.fillStyle = `rgba(196,161,75,${p.alpha})`; ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2); ctx.fill(); } requestAnimationFrame(draw); } draw(); return () => { window.removeEventListener("resize", resize); }; }, []); return (

{title}

{subtitle && (

{subtitle}

)}
); }