From ae9d84f86def0f1bba6a309f351e2a916c41ae8b Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Wed, 19 Nov 2025 17:03:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BD=AE=E6=92=AD=E6=9C=80=E7=BB=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/AutoCarousel.tsx | 114 ++++++++++++-------------------- 1 file changed, 42 insertions(+), 72 deletions(-) diff --git a/app/components/AutoCarousel.tsx b/app/components/AutoCarousel.tsx index 0ab7c5f..6e8d645 100644 --- a/app/components/AutoCarousel.tsx +++ b/app/components/AutoCarousel.tsx @@ -1,14 +1,12 @@ import * as React from "react"; import Autoplay from "embla-carousel-autoplay"; +import { Card, CardContent } from "@/ui/card"; import { Carousel, CarouselContent, CarouselItem, - CarouselNext, - CarouselPrevious, - type CarouselApi, -} from "@/ui/carousel"; +} from "@/ui/carousel"; // 注意这里也移除了未使用的导入 const imageUrls = [ "/images/carousel-1.jpg", @@ -17,86 +15,58 @@ const imageUrls = [ "/images/carousel-4.jpg", "/images/carousel-5.jpg", "/images/carousel-6.jpg", - "/images/carousel-7.jpg", - "/images/carousel-8.jpg", - "/images/carousel-9.jpg", "/images/book1.png", "/images/header.png", "/images/jcdt.png", ]; export function AutoCarouselDemo() { - const [api, setApi] = React.useState(); - const [current, setCurrent] = React.useState(0); - const totalSlides = imageUrls.length; - - React.useEffect(() => { - if (!api) return; - setCurrent(api.selectedScrollSnap()); - api.on("select", () => { - setCurrent(api.selectedScrollSnap()); - }); - }, [api]); - - const getScaleByDistance = (index: number, current: number, total: number): number => { - const directDist = Math.abs(index - current); - const wrapDist = total - directDist; - const minDist = Math.min(directDist, wrapDist); - return Math.max(0.5, 1.4 - minDist * 0.15); - }; - return ( - // 最外层:允许内容溢出(关键!) -
- - {/* 内容区域也要 visible */} - - {imageUrls.map((src, index) => { - const scale = getScaleByDistance(index, current, totalSlides); - const isCurrent = scale > 1.2; +
- return ( - + + {imageUrls.map((src, index) => ( + +
- {/* 这个 div 是真正要缩放的整体卡片 */} -
- {`Slide +
+ + {`Slide +
- - ); - })} +
+ + ))} - - +
); From 92089fad1fd4f5167acf7a0f3b3c43b08f981dc4 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Wed, 19 Nov 2025 17:20:09 +0800 Subject: [PATCH 2/2] list --- app/components/news/list/NewsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/news/list/NewsList.tsx b/app/components/news/list/NewsList.tsx index 12a9606..361b0c4 100644 --- a/app/components/news/list/NewsList.tsx +++ b/app/components/news/list/NewsList.tsx @@ -28,7 +28,7 @@ const NewsList: React.FC = () => { const educationNews = mockNewsData.filter((news) => news.type === "教育"); return ( -
+
{/* 使用 Flexbox 将两个列表放在一行 */}
{/* 科技新闻 */}