From 1201c37eaf7e3bcc79b5f5027c934bd5241f3eb1 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Tue, 18 Nov 2025 17:36:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/body/GrassrootsDynamics.tsx | 20 ++++++++++ app/components/list/List.tsx | 46 ++++++++++++++++++++++ app/components/list/NewsData.tsx | 19 ++++++++- app/components/list/NewsList.tsx | 10 ++++- app/routes/news.tsx | 4 ++ 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 app/components/body/GrassrootsDynamics.tsx create mode 100644 app/components/list/List.tsx 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 = () => {
diff --git a/app/routes/news.tsx b/app/routes/news.tsx index eaba461..ce5816f 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -3,6 +3,7 @@ import type { Route } from "./+types/news"; import {Header} from "@/components/header/Header"; import {TopNav} from "@/components/header/TopNav"; import NewsList from "@/components/list/NewsList"; +import GrassrootsDynamics from "@/components/body/GrassrootsDynamics"; export function meta( ) { return [ { title: "New React Router App" }, @@ -13,8 +14,11 @@ export function meta( ) { export default function Home() { return (
+
+ +
); }