Compare commits

..

2 Commits

Author SHA1 Message Date
qiuchenfan 8ddc36b5fc Merge branch 'main' of http://113.45.67.59:3003/qiuchenfan/news 2025-11-18 16:33:56 +08:00
qiuchenfan d5a25a56bd 轮播图像 2025-11-18 16:32:21 +08:00
9 changed files with 15 additions and 5 deletions

View File

View File

@ -11,13 +11,21 @@ import {
CarouselPrevious,
type CarouselApi,
} from "@/ui/carousel";
const imageUrls = [
"/images/carousel-1.jpg",
"/images/carousel-2.jpg",
"/images/carousel-3.jpg",
"/images/carousel-4.jpg",
"/images/carousel-5.jpg",
"/images/carousel-6.jpg",
];
export function CarouselDemo() {
const [api, setApi] = React.useState<CarouselApi>();
const [current, setCurrent] = React.useState(0);
const [count, setCount] = React.useState(0);
const totalSlides = 6;
const totalSlides = imageUrls.length;
React.useEffect(() => {
if (!api) return;
@ -46,12 +54,16 @@ export function CarouselDemo() {
className="w-full"
>
<CarouselContent>
{Array.from({ length: totalSlides }).map((_, index) => (
{imageUrls.map((src, index) => (
<CarouselItem key={index}>
<div className="p-1">
<Card>
<CardContent className="flex aspect-square items-center justify-center p-6">
<span className="text-4xl font-semibold">{index + 1}</span>
<img
src={src}
alt={`Slide ${index + 1}`}
className="w-full h-full object-cover"
/>
</CardContent>
</Card>
</div>

View File

@ -13,8 +13,6 @@ export function meta( ) {
export default function Home() {
return (
<div>
<Header />
<TopNav />
<CarouselDemo />
<NewsList />
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB