diff --git a/app/components/Carousel.tsx b/app/components/Carousel.tsx index e0c744a..02dff13 100755 --- a/app/components/Carousel.tsx +++ b/app/components/Carousel.tsx @@ -11,21 +11,13 @@ import { type CarouselApi, } from "@/ui/carousel"; import FireNewsList from "./FireNewsList"; - 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(); const [current, setCurrent] = React.useState(0); const [count, setCount] = React.useState(0); - const totalSlides = imageUrls.length; + const totalSlides = 6; React.useEffect(() => { if (!api) return; @@ -39,7 +31,7 @@ export function CarouselDemo() { }, [api]); return ( -
+
- - {imageUrls.map((src, index) => ( - + + {Array.from({ length: totalSlides }).map((_, index) => ( +
- - {`Slide + +
+
diff --git a/app/components/body/GrassrootsDynamics.tsx b/app/components/body/GrassrootsDynamics.tsx new file mode 100644 index 0000000..3c64040 --- /dev/null +++ b/app/components/body/GrassrootsDynamics.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import List from '../list/List'; + +export default function GrassrootsDynamics() { + return ( +
+ {/* 左边图片 */} +
+ 基层动态 +
+ {/* 右边列表 */} +
+ +
+
+ ); +} \ No newline at end of file diff --git a/app/components/list/List.tsx b/app/components/list/List.tsx new file mode 100644 index 0000000..0034864 --- /dev/null +++ b/app/components/list/List.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import { mockNewsData } from './NewsData'; // 导入新闻数据 + + + +interface NewsProps { + title?: string; + description?: string; + time?: string; + type?: string; + url?: string; +} + + +const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { + return ( +
+
url && window.open(url)} + className="flex items-center justify-between hover:text-blue-600 cursor-pointer transition duration-300 ease-in-out" + > +

{title}

+

{time}

+
+
+ ); +}; + +// 使用新闻数据渲染列表 +const List: React.FC = () => { + return ( +
+
+
+
    + {mockNewsData.map((news) => ( + + ))} +
+
+
+
+ ); +}; + +export default List; \ No newline at end of file diff --git a/app/components/list/NewsData.tsx b/app/components/list/NewsData.tsx index 4d22885..d1d6c17 100644 --- a/app/components/list/NewsData.tsx +++ b/app/components/list/NewsData.tsx @@ -6,6 +6,10 @@ export interface News { url?: string; } +export interface NewsTitle { + id: string; + name: string; +} // 导出生成的模拟新闻数据 export const NewsData = (): News[] => { return [ @@ -25,5 +29,18 @@ export const NewsData = (): News[] => { ]; }; +export const NewsTitleData = (): NewsTitle[] => { + return [ + { id: "news-1", name: "科技" }, + { id: "news-2", name: "财经" }, + { id: "news-3", name: "娱乐" }, + { id: "news-4", name: "体育" }, + { id: "news-5", name: "教育" }, + { id: "news-6", name: "军事" }, + ] +} + + // 默认导出模拟新闻数据 -export const mockNewsData = NewsData(); \ No newline at end of file +export const mockNewsData = NewsData(); +export const mockNewsTitleData = NewsTitleData(); \ No newline at end of file diff --git a/app/components/list/NewsList.tsx b/app/components/list/NewsList.tsx index bdc5959..34160e7 100644 --- a/app/components/list/NewsList.tsx +++ b/app/components/list/NewsList.tsx @@ -1,5 +1,7 @@ import React from 'react'; import { mockNewsData } from './NewsData'; // 导入新闻数据 +import { mockNewsTitleData } from './NewsData'; // 导入新闻标题数据 + interface NewsProps { title?: string; @@ -9,6 +11,10 @@ interface NewsProps { url?: string; } +interface NewsTitle { + id: string; + name: string; +} const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { return (
@@ -37,8 +43,8 @@ const NewsList: React.FC = () => {
    - {mockNewsData.map((news, index) => ( - + {mockNewsData.map((news) => ( + ))}
diff --git a/app/components/news/header/Header.tsx b/app/components/news/header/Header.tsx index 1714f94..96d3624 100644 --- a/app/components/news/header/Header.tsx +++ b/app/components/news/header/Header.tsx @@ -15,7 +15,7 @@ export function Header(){ return (
{/* 时间显示 只显示日期: "2025/3/15"*/} diff --git a/app/routes/news.tsx b/app/routes/news.tsx index b8d524d..6d132a5 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -1,11 +1,16 @@ -import { CarouselDemo } from "@/components/Carousel"; + import type { Route } from "./+types/news"; import Integrated from "@/components/news/body/Integrated"; import CultureBgPage from "@/components/news/body/Culturebg"; import {Header} from "@/components/news/header/Header"; import {TopNav} from "@/components/news/header/TopNav"; import NewsList from "@/components/list/NewsList"; +<<<<<<< HEAD import ImageGridSection from "@/components/body/ImageGridSection"; +import { CarouselDemo } from "@/components/Carousel"; +======= +import GrassrootsDynamics from "@/components/body/GrassrootsDynamics"; +>>>>>>> 858176d3dcd4442d093f13eeca279711b756adb8 export function meta( ) { return [ { title: "New React Router App" }, @@ -19,11 +24,14 @@ export default function Home() {
+ +<<<<<<< HEAD + {/* */} - - +======= +>>>>>>> 858176d3dcd4442d093f13eeca279711b756adb8
); }