"use client" import {useRef, useEffect, useState} from "react" import {AnimatePresence, motion, useScroll, useTransform} from "framer-motion" import gsap from "gsap" import {ScrollTrigger} from "gsap/ScrollTrigger" import {TextPlugin} from "gsap/TextPlugin" import {Github, Mail, ExternalLink, Code, Heart, Coffee} from "lucide-react" import {Button} from "@/components/ui/button" import {useTheme} from "next-themes" import dynamic from "next/dynamic"; const RandomItems = dynamic(() => (import('@/components/ui/random-items')), { ssr: false, }); export default function GsapPersonalIntro() { const containerRef = useRef(null) const textRef = useRef(null) const imageRef = useRef(null) const {theme, resolvedTheme} = useTheme() const [isDark, setIsDark] = useState(false) useEffect(() => { if (resolvedTheme === "dark") { setIsDark(true) } else { setIsDark(false) } }, [resolvedTheme]); const {scrollYProgress} = useScroll({ target: containerRef, offset: ["start start", "end start"], }) const y = useTransform(scrollYProgress, [0, 1], ["0%", "40%"]) const scale = useTransform(scrollYProgress, [0, 1], [1, 0.9]) const opacity = useTransform(scrollYProgress, [0, 0.8], [1, 0]) useEffect(() => { gsap.registerPlugin(ScrollTrigger, TextPlugin); if (!containerRef.current) return; const container = containerRef.current; // 清理所有 ScrollTrigger 实例 ScrollTrigger.getAll().forEach((trigger) => trigger.kill()); const tl = gsap.timeline({ scrollTrigger: { trigger: container, start: "top 80%", end: "bottom 20%", toggleActions: "play none none reverse", }, }); if (textRef.current) { const headings = textRef.current.querySelectorAll("h3, h4"); const paragraphs = textRef.current.querySelectorAll("p"); const buttons = textRef.current.querySelectorAll("button, a"); const icons = textRef.current.querySelectorAll(".icon-item"); tl.from(headings, {opacity: 0, y: 50, duration: 0.8, stagger: 0.2, ease: "power3.out"}) .from(paragraphs, {opacity: 0, y: 30, duration: 0.6, stagger: 0.2, ease: "power2.out"}, "-=0.4") .from(buttons, { opacity: 0, y: 20, scale: 0.9, duration: 0.5, stagger: 0.1, ease: "back.out(1.7)" }, "-=0.3") .from(icons, { opacity: 0, scale: 0, rotation: -30, duration: 0.6, stagger: 0.1, ease: "back.out(2)" }, "-=0.4"); } if (imageRef.current) { const shapes = imageRef.current.querySelectorAll(".shape"); const particles = imageRef.current.querySelectorAll(".particle"); tl.from(shapes, { opacity: 0, scale: 0, rotation: -60, transformOrigin: "center", duration: 0.8, stagger: 0.1, ease: "back.out(2)" }, "-=0.8"); particles.forEach((particle) => { gsap.to(particle, { y: "random(-30, 30)", x: "random(-30, 30)", rotation: "random(-360, 360)", duration: "random(3, 6)", repeat: -1, yoyo: true, ease: "sine.inOut", }); }); } return () => { // 确保清理所有 ScrollTrigger 实例 ScrollTrigger.getAll().forEach((trigger) => trigger.kill()); }; }, [theme, resolvedTheme, isDark]); const words = ["全栈开发者", "设计者", "创造者"] const [currentWord, setCurrentWord] = useState(0) useEffect(() => { const interval = setInterval(() => { setCurrentWord((prev) => (prev + 1) % words.length) }, 2000) return () => clearInterval(interval) }, []) return ( {/* Background elements */}

你好,我是

grtsinry43

热爱生活的{" "} {words[currentWord]}

我专注于构建优雅、高效的应用程序,无论是 Web 应用还是 Android 应用。 我相信良好的用户体验和干净的代码同样重要。

开发者
热爱创造
咖啡爱好者
grtsinry43 {isDark && (
)}

grtsinry43

全栈开发者 & 设计爱好者

) }