diff --git a/app/components/Carousel.tsx b/app/components/Carousel.tsx index 84a6c44..e93a879 100755 --- a/app/components/Carousel.tsx +++ b/app/components/Carousel.tsx @@ -49,14 +49,23 @@ export function CarouselDemo() { setApi={setApi} className="w-full h-full" > - - {imageUrls.map((src, index) => ( - - {`Slide + + {Array.from({ length: totalSlides }).map((_, index) => ( + +
+ + +
+
+
+
+
))}
diff --git a/app/components/list/List.tsx b/app/components/list/List.tsx index c8c706d..b949fc2 100644 --- a/app/components/list/List.tsx +++ b/app/components/list/List.tsx @@ -1,7 +1,5 @@ import React from 'react'; -import { mockNewsData } from './NewsData'; // 导入新闻数据 - - +import { grassNewsData } from './NewsData'; // 引入基层新闻数据 interface NewsProps { title?: string; @@ -11,7 +9,6 @@ interface NewsProps { url?: string; } - const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { return (
@@ -26,15 +23,18 @@ const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { ); }; -// 使用新闻数据渲染列表 +// 使用基层新闻数据渲染列表 const List: React.FC = () => { + // 调用 grassNewsData 函数获取基层新闻数据 + const baseNews = grassNewsData(); + return ( -
-
-
+
+
+
    - {mockNewsData.map((news) => ( - + {baseNews.map((news) => ( + ))}
diff --git a/app/components/list/NewsData.tsx b/app/components/list/NewsData.tsx index 6d3f24a..0fb8ae8 100644 --- a/app/components/list/NewsData.tsx +++ b/app/components/list/NewsData.tsx @@ -16,6 +16,10 @@ export const NewsData = (): News[] => { { id: "news-4", type: "科技", title: "量子计算研究取得突破性进展", time: "2023-11-04", url: "https://www.baidu.com" }, { id: "news-5", type: "科技", title: "国际空间站完成新一轮科学实验", time: "2023-11-05", url: "https://www.baidu.com" }, { id: "news-6", type: "科技", title: "数字货币监管政策逐步完善", time: "2023-11-06", url: "https://www.baidu.com" }, + { id: "news-7", type: "科技", title: "区块链技术在金融领域应用前景广阔", time: "2023-11-07", url: "https://www.baidu.com" }, + { id: "news-8", type: "科技", title: "物联网技术在工业自动化领域应用广泛", time: "2023-11-08", url: "https://www.baidu.com" }, + { id: "news-8", type: "科技", title: "物联网技术在工业自动化领域应用广泛", time: "2023-11-08", url: "https://www.baidu.com" }, + { id: "edu-1", type: "教育", title: "在线教育平台助力偏远地区学生学习", time: "2025-01-10", url: "https://www.example.com/edu-1" }, { id: "edu-2", type: "教育", title: "人工智能技术推动个性化教学发展", time: "2025-02-15", url: "https://www.example.com/edu-2" }, @@ -23,11 +27,27 @@ export const NewsData = (): News[] => { { id: "edu-4", type: "教育", title: "高校联合企业开展产学研合作新模式", time: "2025-04-05", url: "https://www.example.com/edu-4" }, { id: "edu-5", type: "教育", title: "教育部发布新政策支持职业教育发展", time: "2025-05-12", url: "https://www.example.com/edu-5" }, { id: "edu-6", type: "教育", title: "全球教育公平问题引发广泛讨论", time: "2025-06-18", url: "https://www.example.com/edu-6" }, + { id: "edu-7", type: "教育", title: "国际教育标准制定与落地", time: "2025-07-25", url: "https://www.example.com/edu-7" }, + { id: "edu-8", type: "教育", title: "在线教育平台助力偏远地区学生学习", time: "2025-08-30", url: "https://www.example.com/edu-8" }, + { id: "edu-9", type: "教育", title: "人工智能技术推动个性化教学发展", time: "2025-09-04", url: "https://www.example.com/edu-9" }, ]; }; +export const grassNewsData = (): News[] => { + return [ + { id: "grass-1", type: "基层", title: "社区志愿者服务队开展环保活动", time: "2025-01-10", url: "https://www.example.com/grass-1" }, + { id: "grass-2", type: "基层", title: "乡镇企业助力乡村振兴计划", time: "2025-01-15", url: "https://www.example.com/grass-2" }, + { id: "grass-3", type: "基层", title: "村级文化活动中心正式开放", time: "2025-02-01", url: "https://www.example.com/grass-3" }, + { id: "grass-4", type: "基层", title: "基层医疗站新增远程诊疗服务", time: "2025-02-18", url: "https://www.example.com/grass-4" }, + { id: "grass-5", type: "基层", title: "农村电商培训帮助农民增收", time: "2025-03-05", url: "https://www.example.com/grass-5" }, + { id: "grass-6", type: "基层", title: "社区图书馆举办亲子阅读活动", time: "2025-03-22", url: "https://www.example.com/grass-6" }, + { id: "grass-7", type: "基层", title: "街道办组织居民参与垃圾分类宣传", time: "2025-04-10", url: "https://www.example.com/grass-7" }, + { id: "grass-8", type: "基层", title: "乡村小学引入智能教学设备", time: "2025-04-25", url: "https://www.example.com/grass-8" }, + { id: "grass-9", type: "基层", title: "基层干部走访调研解决民生问题", time: "2025-05-12", url: "https://www.example.com/grass-9" } + ]; +}; - // 默认导出模拟新闻数据 export const mockNewsData = NewsData(); +export const mockGrassNewsData = grassNewsData(); diff --git a/app/components/news/body/FireNews/FireNewsList.tsx b/app/components/news/body/FireNews/FireNewsList.tsx index 77601c8..5c29c71 100644 --- a/app/components/news/body/FireNews/FireNewsList.tsx +++ b/app/components/news/body/FireNews/FireNewsList.tsx @@ -1,63 +1,98 @@ import React from 'react'; -interface NewsItem { - content: string; -} - export function FireNewsList() { - const newsItems: NewsItem[] = [ - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - { - content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...", - }, - ]; + const articles = [ + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: true, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: true, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: true, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + { + date: { month: '11', day: '2025-02' }, + title: '记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262人次,支出达399.7亿元...', + isHighlighted: false, + }, + ]; return ( -
- {/* 标题栏 */} -
-

烽火要闻

- - 查看更多 {'>'} - -
+
+ {/* 文章列表 */} +
+ {/* 标题栏 */} +
+

烽火要闻

+ +
- {/* 新闻列表 */} -
- {newsItems.map((item, index) => ( -
- - {/* 内容部分 */} -
-

- {item.content} - - [MORE] - -

-
-
- ))} -
-
+ {/* 文章列表 */} +
+ {articles.map((article, index) => ( +
+ {/* 左侧竖线和日期 */} +
+
+
+
{article.date.month}
+
{article.date.day}
+
+
+ {/* 右侧文章内容 */} +
+

+ {article.title} + + 【MORE】 + +

+
+
+ ))} +
+
+
); }; diff --git a/app/components/news/body/FireNews/fhjt.tsx b/app/components/news/body/FireNews/fhjt.tsx index 241360e..59cac6c 100644 --- a/app/components/news/body/FireNews/fhjt.tsx +++ b/app/components/news/body/FireNews/fhjt.tsx @@ -4,12 +4,14 @@ import {FireNewsList} from "./FireNewsList"; export function FhjtPage() { return( -
- {/* 轮播背景图 */} -
- -
- +
+
+ {/* 轮播背景图 */} +
+ +
+
+
{/* 标题部分 */}
diff --git a/app/components/news/body/FireNews/fhrx.tsx b/app/components/news/body/FireNews/fhrx.tsx index b9dce29..4f4070e 100644 --- a/app/components/news/body/FireNews/fhrx.tsx +++ b/app/components/news/body/FireNews/fhrx.tsx @@ -4,11 +4,14 @@ import {FireNewsList} from "./FireNewsList"; export function FhrxPage() { return( -
- {/* 轮播背景图 */} -
- -
+
+
+ {/* 轮播背景图 */} +
+ +
+
+
{/* 标题部分 */} diff --git a/app/components/news/body/FireNews/fhws.tsx b/app/components/news/body/FireNews/fhws.tsx index 506ca77..0c3be2c 100644 --- a/app/components/news/body/FireNews/fhws.tsx +++ b/app/components/news/body/FireNews/fhws.tsx @@ -4,16 +4,16 @@ import {FireNewsList} from "./FireNewsList"; export function FhwsPage() { return( -
+
{/* 标题部分 */} -
+

烽火微视

{/* 蓝色装饰线 */}
{/* 列表 */} -
+
一 @@ -28,10 +28,13 @@ export function FhwsPage() {
- {/* 轮播背景图 */} -
- -
+
+ {/* 轮播背景图 */} +
+ +
+
+
) } \ No newline at end of file diff --git a/app/components/news/header/Header.tsx b/app/components/news/header/Header.tsx index 96d3624..c0af4ae 100644 --- a/app/components/news/header/Header.tsx +++ b/app/components/news/header/Header.tsx @@ -7,7 +7,7 @@ export function Header(){ // setInterval是 JavaScript 中的一个全局函数,用于重复执行代码 const timer = setInterval(() => { setCurrentTime(new Date()); - }, 1000); // 每秒更新一次 + }, 24*60*1000); // 每天更新一次 // 清理定时器 return () => clearInterval(timer);// 只在组件卸载时清理定时器 @@ -15,8 +15,8 @@ export function Header(){ return (
{/* 时间显示 只显示日期: "2025/3/15"*/}
diff --git a/app/components/news/header/TopNav.tsx b/app/components/news/header/TopNav.tsx index f5dfd1f..b40a7ad 100644 --- a/app/components/news/header/TopNav.tsx +++ b/app/components/news/header/TopNav.tsx @@ -1,16 +1,11 @@ import { Search } from 'lucide-react'; -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; interface MenuItem { label: string; key: string; } -// 定义 TopNavProps 接口,描述组件的 props 类型 -// menuItems? 菜单项数组 -// activeKey: 当前激活的菜单项 -// onSearch: 搜索回调函数 -// onItemClick: 菜单点击回调函数 interface TopNavProps { menuItems?: MenuItem[]; activeKey?: string; @@ -18,11 +13,6 @@ interface TopNavProps { onItemClick?: (key: string) => void; } -//定义 TopNav 组件,类型为 React 函数组件,接收 TopNavProps 类型的 props -//解构并设置 menuItems 默认值,如果父组件没有传入则使用默认的6个菜单项 -// activeKey: 当前激活的菜单项 -// onSearch: 搜索回调函数 -// onItemClick: 菜单点击回调函数 export function TopNav({ menuItems = [ { label: '首页', key: 'home' }, @@ -32,35 +22,37 @@ export function TopNav({ { label: '联系热线', key: 'hotline' }, { label: '综合服务', key: 'service' }, ], - activeKey: externalActiveKey, // 从外部传入的 activeKey + activeKey: externalActiveKey, onSearch, onItemClick, }: TopNavProps){ - // 使用外部传入的 activeKey,如果没有则使用内部状态 - // 创建内部状态 internalActiveKey,默认值为 'home',用于内部管理激活状态 const [internalActiveKey, setInternalActiveKey] = useState('home'); - // 如果外部传入了 activeKey 则使用外部的,否则使用内部状态(支持受控和非受控模式) const currentActiveKey = externalActiveKey !== undefined ? externalActiveKey : internalActiveKey; - // 创建搜索关键词状态,初始为空字符串 const [searchKeyword, setSearchKeyword] = useState(''); - // 处理搜索提交事件, 阻止默认表单提交行为,调用搜索回调函数 + const [activeIndex, setActiveIndex] = useState(0); + const [prevIndex, setPrevIndex] = useState(0); + + // 监听激活项变化,更新索引和动画方向 + useEffect(() => { + const currentIndex = menuItems.findIndex(item => item.key === currentActiveKey); + setPrevIndex(activeIndex); + setActiveIndex(currentIndex); + }, [currentActiveKey, menuItems, activeIndex]); + const handleSearchSubmit = (e: React.FormEvent) => { e.preventDefault(); - onSearch?.(searchKeyword); // .? 可选链操作符,确保 onSearch 存在时才调用 + onSearch?.(searchKeyword); }; - // 定义菜单项点击处理函数,如果外部没有传入 activeKey 则更新内部状态,调用点击回调函数 const handleItemClick = (item: MenuItem) => { - // 更新内部状态(如果使用内部状态) if (externalActiveKey === undefined) { setInternalActiveKey(item.key); } - // 调用外部回调函数 - onItemClick?.(item.key); // .? 可选链操作符,确保 onItemClick 存在时才调用 + onItemClick?.(item.key); }; return ( -
+
{/* 搜索框与导航菜单组合 */}
{/* 搜索框 */} @@ -71,26 +63,42 @@ export function TopNav({ value={searchKeyword} onChange={(e) => setSearchKeyword(e.target.value)} placeholder="搜索..." - className="pl-10 pr-4 py-2 text-sm rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent w-64 transition-all duration-200 hover:shadow-sm" + className="pl-10 pr-4 py-2 text-sm border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent w-64 transition-all duration-200 hover:shadow-sm" />
- + {/* 导航菜单 */} -
    - {menuItems.map((item) => { - const isActive = currentActiveKey === item.key; // 判断当前项是否激活 +
      + {/* 滑动背景层 */} +
      + + {menuItems.map((item, index) => { + const isActive = currentActiveKey === item.key; return ( -
    • +
); -}; +}; \ No newline at end of file diff --git a/app/routes/news.tsx b/app/routes/news.tsx index 130413b..6daf3fb 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -29,14 +29,17 @@ export default function Home() { - - - - - - - - +
+ + + + + + + +
); } diff --git a/app/images/header.png b/public/images/header.png similarity index 100% rename from app/images/header.png rename to public/images/header.png diff --git a/public/images/jcdt.png b/public/images/jcdt.png new file mode 100644 index 0000000..529c734 Binary files /dev/null and b/public/images/jcdt.png differ