video-shuoshan/web/src/components/AmbientBackground.tsx
seaislee1209 f8358a28c6 feat: 前端UI重构 — Air Spark设计系统对标
- 全局样式对标Air Spark设计系统(背景、glass card、配色、圆角)
- 视频详情弹窗(VideoDetailModal)全屏预览+信息面板
- GenerationCard重构:fixed定位tooltip、9:16视频适配、blob下载
- 个人中心:总额度/今日/本月三卡片布局
- Dashboard图表配色统一为#6c63ff主色调
- Sidebar、InputBar、Toolbar等组件样式优化
- 新增AmbientBackground、AssetsPage组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 18:48:07 +08:00

49 lines
1.3 KiB
TypeScript

import { useEffect, useRef } from 'react';
export function AmbientBackground() {
const glowRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = glowRef.current;
if (!el) return;
let rafId: number;
let targetX = 50;
let targetY = 50;
let currentX = 50;
let currentY = 50;
const handleMouseMove = (e: MouseEvent) => {
targetX = (e.clientX / window.innerWidth) * 100;
targetY = (e.clientY / window.innerHeight) * 100;
};
const animate = () => {
currentX += (targetX - currentX) * 0.08;
currentY += (targetY - currentY) * 0.08;
el.style.setProperty('--mouse-x', `${currentX}%`);
el.style.setProperty('--mouse-y', `${currentY}%`);
rafId = requestAnimationFrame(animate);
};
window.addEventListener('mousemove', handleMouseMove, { passive: true });
rafId = requestAnimationFrame(animate);
return () => {
window.removeEventListener('mousemove', handleMouseMove);
cancelAnimationFrame(rafId);
};
}, []);
return (
<>
<div className="aurora-bg" aria-hidden="true">
<div className="aurora-blob-3" />
</div>
<div className="grid-pattern" aria-hidden="true" />
<div className="noise-overlay" aria-hidden="true" />
<div ref={glowRef} className="cursor-glow" aria-hidden="true" />
</>
);
}