Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
补偿
daoyian8aa0277f3944
diff --git a/src/app/[lng]/page.tsx b/src/app/[lng]/page.tsxindex ceb003db..5948a5c2 100644--- a/src/app/[lng]/page.tsx+++ b/src/app/[lng]/page.tsx@@ -194,11 +194,11 @@ function BrandBar() {);}-// 功能介绍区+// 灵感创意function BuildSection() {const [currentImageIndex, setCurrentImageIndex] = useState(0);const [autoRotate, setAutoRotate] = useState(true);- const images = [logo.src, logo2.src];+ const images = [logo.src];const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);@@ -342,8 +342,76 @@ function BuildSection() {);}-// CONNECT 功能介绍区+// 功能介绍区function ConnectSection() {+ const [currentImageIndex, setCurrentImageIndex] = useState(0);+ const [autoRotate, setAutoRotate] = useState(true);+ const images = [logo.src, logo.src ]; // 功能介绍相关的图片+ const autoRotateRef = useRef<NodeJS.Timeout | null>(null);+ const carouselRef = useRef<HTMLDivElement>(null);++ // 自动轮播+ useEffect(() => {+ if (autoRotate) {+ autoRotateRef.current = setInterval(() => {+ setCurrentImageIndex(prev => (prev + 1) % images.length);+ }, 3000);+ } else {+ if (autoRotateRef.current) {+ clearInterval(autoRotateRef.current);+ autoRotateRef.current = null;+ }+ }++ return () => {+ if (autoRotateRef.current) {+ clearInterval(autoRotateRef.current);+ }+ };+ }, [autoRotate, images.length]);++ // 滚轮控制+ useEffect(() => {+ const handleWheel = (e: WheelEvent) => {+ // 检查是否在轮播区域内+ if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {+ e.preventDefault();++ if (e.deltaY > 0) {+ // 向下滚动+ if (currentImageIndex < images.length - 1) {+ setCurrentImageIndex(prev => prev + 1);+ setAutoRotate(false); // 用户操作时暂停自动轮播+ } else {+ // 到达最后一张图,恢复页面滚动+ setAutoRotate(true);+ return;+ }+ } else {+ // 向上滚动+ if (currentImageIndex > 0) {+ setCurrentImageIndex(prev => prev - 1);+ setAutoRotate(false);+ }+ }++ // 3秒后恢复自动轮播+ setTimeout(() => {+ setAutoRotate(true);+ }, 3000);+ }+ };++ const carousel = carouselRef.current;+ if (carousel) {+ carousel.addEventListener('wheel', handleWheel, { passive: false });++ return () => {+ carousel.removeEventListener('wheel', handleWheel);+ };+ }+ }, [currentImageIndex, images.length]);+return (<section className={styles.connectSection}><div className={styles.connectContainer}>@@ -385,8 +453,42 @@ function ConnectSection() {</div><div className={styles.connectRight}>- <div className={styles.productScreenshot}>- <img src="/api/placeholder/600/400" alt="Dify Data Source Interface" className={styles.screenshotImg} />+ <div+ className={styles.imageCarousel}+ ref={carouselRef}+ >+ <div className={styles.carouselContainer}>+ {images.map((image, index) => (+ <div+ key={index}+ className={`${styles.carouselSlide} ${index === currentImageIndex ? styles.active : ''}`}+ >+ <img+ src={image}+ alt={`AI ToEarn Function ${index + 1}`}+ className={styles.carouselImage}+ />+ </div>+ ))}+ </div>++ <div className={styles.carouselIndicators}>+ {images.map((_, index) => (+ <button+ key={index}+ className={`${styles.indicator} ${index === currentImageIndex ? styles.active : ''}`}+ onClick={() => {+ setCurrentImageIndex(index);+ setAutoRotate(false);+ setTimeout(() => setAutoRotate(true), 3000);+ }}+ />+ ))}+ </div>++ <div className={styles.carouselHint}>+ <span>使用滚轮切换图片</span>+ </div></div></div></div>diff --git a/src/app/[lng]/styles/difyHome.module.scss b/src/app/[lng]/styles/difyHome.module.scssindex 4e2734fd..40331f57 100644--- a/src/app/[lng]/styles/difyHome.module.scss+++ b/src/app/[lng]/styles/difyHome.module.scss@@ -490,7 +490,15 @@display: grid;grid-template-columns: 1fr 1fr;gap: 80px;- align-items: center;+ align-items: stretch;+ min-height: 500px;+}++.connectLeft,+.connectRight {+ display: flex;+ flex-direction: column;+ justify-content: center;}.connectTitle {diff --git a/src/app/layout/routerData.ts b/src/app/layout/routerData.tsindex a8edf779..c033b537 100644--- a/src/app/layout/routerData.ts+++ b/src/app/layout/routerData.ts@@ -37,11 +37,11 @@ export const routerData: IRouterDataItem[] = [translationKey: "hotContent",path: "/hot-content",},- {- name: "Youtobe",- translationKey: "youtube",- path: "/youtube",- },+ // {+ // name: "Youtobe",+ // translationKey: "youtube",+ // path: "/youtube",+ // },];const recursion = (