diff --git a/app/components/AutoCarousel.tsx b/app/components/AutoCarousel.tsx index 6e8d645..971f2fe 100644 --- a/app/components/AutoCarousel.tsx +++ b/app/components/AutoCarousel.tsx @@ -6,7 +6,7 @@ import { Carousel, CarouselContent, CarouselItem, -} from "@/ui/carousel"; // 注意这里也移除了未使用的导入 +} from "@/ui/carousel"; const imageUrls = [ "/images/carousel-1.jpg", @@ -22,7 +22,7 @@ const imageUrls = [ export function AutoCarouselDemo() { return ( -
+
-
+
(); + + // 当前激活的幻灯片索引(从 0 开始) const [current, setCurrent] = React.useState(0); + + // 总共的幻灯片数量(由 Embla API 动态获取) const [count, setCount] = React.useState(0); + + // 图片总数(用于渲染轮播项) const totalSlides = imageUrls.length; - const [isDotPagination, setIsDotPagination] = React.useState(true); // 控制分页指示器类型 + // 副作用:监听 api 变化,初始化轮播状态并绑定 select 事件 React.useEffect(() => { - if (!api) return; + if (!api) return; // 如果 api 尚未就绪,直接返回 + // 获取所有 snap 点的数量(即幻灯片总数) setCount(api.scrollSnapList().length); + + // 设置当前选中的 snap 索引 setCurrent(api.selectedScrollSnap()); + // 监听轮播切换事件(用户手动滑动或自动播放时触发) api.on("select", () => { - setCurrent(api.selectedScrollSnap()); + setCurrent(api.selectedScrollSnap()); // 更新当前激活项 }); - }, [api]); + }, [api]); // 仅当 api 发生变化时重新执行 + // 渲染组件 return ( + // 外层容器:相对定位,占满父容器宽高
+ + {/* 轮播主容器 */} + {/* 轮播内容区域 */} - {Array.from({ length: totalSlides }).map((_, index) => ( - + {/* 遍历图片数组,为每张图创建一个轮播项 */} + {imageUrls.map((src, index) => ( + + {/* 内部包裹层:无内边距,占满 */}
- -
-
+ {/* 使用 CardContent 包裹图片,移除默认间距 */} + + {/* 图片元素:自动填充容器,保持比例裁剪 */} + {`Slide
))}
- - + + {/* 上一张按钮(左箭头) */} + {/* */} + + {/* 下一张按钮(右箭头) */} + {/* */}
- {/* 分页指示器 - 右下角 */} -
+ {/* 分页指示器容器:绝对定位在底部 */} +
+ {/* 动态生成指示器按钮 */} {Array.from({ length: count }).map((_, index) => (
diff --git a/app/components/news/body/FireNews/Hotline.tsx b/app/components/news/body/FireNews/Hotline.tsx index 8c1e2ff..1c8c46f 100644 --- a/app/components/news/body/FireNews/Hotline.tsx +++ b/app/components/news/body/FireNews/Hotline.tsx @@ -7,8 +7,11 @@ export function Hotline() {
{/* 轮播背景图 */} -
- +
+
diff --git a/app/components/news/body/FireNews/ImportantNews.tsx b/app/components/news/body/FireNews/ImportantNews.tsx index 5aace90..b4a68a2 100644 --- a/app/components/news/body/FireNews/ImportantNews.tsx +++ b/app/components/news/body/FireNews/ImportantNews.tsx @@ -33,8 +33,11 @@ export function ImportantNews() { return(
{/* 轮播背景图 - 确保有明确尺寸 */} -
- +
+
{/* 固定的烽火要闻 */} diff --git a/app/components/news/body/FireNews/LectureHall.tsx b/app/components/news/body/FireNews/LectureHall.tsx index 5c530d8..f9ae809 100644 --- a/app/components/news/body/FireNews/LectureHall.tsx +++ b/app/components/news/body/FireNews/LectureHall.tsx @@ -7,8 +7,11 @@ export function LectureHall() {
{/* 轮播背景图 */} -
- +
+
diff --git a/app/components/news/body/FireNews/MicroVision.tsx b/app/components/news/body/FireNews/MicroVision.tsx index debd79b..ed5eb87 100644 --- a/app/components/news/body/FireNews/MicroVision.tsx +++ b/app/components/news/body/FireNews/MicroVision.tsx @@ -30,8 +30,11 @@ export function MicroVision() {
{/* 轮播背景图 */} -
- +
+
diff --git a/app/components/news/body/ImageGridSection.tsx b/app/components/news/body/ImageGridSection.tsx index 40690d9..a3f8d51 100644 --- a/app/components/news/body/ImageGridSection.tsx +++ b/app/components/news/body/ImageGridSection.tsx @@ -38,7 +38,10 @@ const LearnPage = () => { {/* 上右:轮播图 */}
- +
{/* 下三图 */} @@ -98,7 +101,7 @@ const LearnPage = () => {
-
烽火动态
diff --git a/app/components/news/footer/footer.tsx b/app/components/news/footer/footer.tsx index d009fb0..edc3d4a 100644 --- a/app/components/news/footer/footer.tsx +++ b/app/components/news/footer/footer.tsx @@ -1,11 +1,51 @@ -export function Footer() { +import React from 'react'; + +const Footer: React.FC = () => { return ( -
-
- 春风拂面花开满园心情愉悦 + {/* 主标题 */} +
+

+ 春风拂面花开满园心OO情愉悦 +

+
+ + {/* 版权声明 */} +
+

+ 免责声明:免责条款的提出必须是明示的,不允许以默示方式作出,也不允许法官推定免责条款的存在。 +

+

+ 版权所有:Copyright©2016-2019 包图网ibaotu.com 版权所有 +

+
+ + {/* 导航链接 */} +
- ) -} \ No newline at end of file + ); +}; + +export default Footer; diff --git a/app/routes/news.tsx b/app/routes/news.tsx index f1132ef..d7032a4 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -12,7 +12,8 @@ import { LectureHall } from "@/components/news/body/FireNews/LectureHall"; import { MicroVision } from "@/components/news/body/FireNews/MicroVision"; import { Hotline } from "@/components/news/body/FireNews/Hotline"; import { AutoCarouselDemo } from "@/components/AutoCarousel"; -import { Footer } from "@/components/news/footer/footer"; +import Footer from "@/components/news/footer/footer"; +import { CarouselDemo } from "@/components/Carousel"; export function meta( ) { return [ diff --git a/public/images/footer.png b/public/images/footer.png new file mode 100644 index 0000000..baf51db Binary files /dev/null and b/public/images/footer.png differ