From 2c12174d6b399fb014358f24a42614687b02e5b0 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Tue, 18 Nov 2025 15:32:13 +0800 Subject: [PATCH 1/5] .. --- app/routes/news.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/routes/news.tsx b/app/routes/news.tsx index e0acc43..42308ab 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -1,8 +1,8 @@ import { CarouselDemo } from "@/components/untils/Carousel"; -import type { Route } from "./+types/news"; +import NewsList from "@/components/list/NewsList"; -export function meta({}: Route.MetaArgs) { +export function meta( ) { return [ { title: "New React Router App" }, { name: "description", content: "Welcome to React Router!" }, @@ -10,5 +10,5 @@ export function meta({}: Route.MetaArgs) { } export default function Home() { - return ; + return ; } From 388429a79c1f710b83de047d9018a90411bdcc3e Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Tue, 18 Nov 2025 15:52:22 +0800 Subject: [PATCH 2/5] 1 --- app/components/header/Header.tsx | 13 +++++++------ app/routes/news.tsx | 10 +++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/components/header/Header.tsx b/app/components/header/Header.tsx index a707a6e..1714f94 100644 --- a/app/components/header/Header.tsx +++ b/app/components/header/Header.tsx @@ -4,27 +4,28 @@ export function Header(){ const [currentTime, setCurrentTime] = useState(new Date()); useEffect(() => { + // setInterval是 JavaScript 中的一个全局函数,用于重复执行代码 const timer = setInterval(() => { setCurrentTime(new Date()); }, 1000); // 每秒更新一次 // 清理定时器 - return () => clearInterval(timer); - }, []); + return () => clearInterval(timer);// 只在组件卸载时清理定时器 + }, []); // 只在组件首次挂载时设置定时器 return (
- {/* 时间显示 */} + {/* 时间显示 只显示日期: "2025/3/15"*/}
- {currentTime.toLocaleString('zh-CN')} + {currentTime.toLocaleDateString('zh-CN')}
-
-

console.log('登录')}>登录

+
+

console.log('登录')}>登录

console.log('注册')}>注册

diff --git a/app/routes/news.tsx b/app/routes/news.tsx index 743cbbd..15dc361 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -1,5 +1,7 @@ import { CarouselDemo } from "@/components/untils/Carousel"; import type { Route } from "./+types/news"; +import { Header } from "@/components/header/Header"; +import { TopNav } from "@/components/header/TopNav"; export function meta( ) { @@ -10,5 +12,11 @@ export function meta( ) { } export default function Home() { - return ; + return ( +
+
+ + +
+ ); } From 42a0d3a16cad2e341a9166c512a17902239e8f21 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Tue, 18 Nov 2025 16:02:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/list/NewsList.tsx | 2 +- app/routes/news.tsx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/components/list/NewsList.tsx b/app/components/list/NewsList.tsx index 0f74f38..6e3f68c 100644 --- a/app/components/list/NewsList.tsx +++ b/app/components/list/NewsList.tsx @@ -26,7 +26,7 @@ const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { const NewsList: React.FC = () => { return (
-
    +
      {mockNewsData.map((news) => ( ))} diff --git a/app/routes/news.tsx b/app/routes/news.tsx index 743cbbd..78916a2 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -1,7 +1,8 @@ import { CarouselDemo } from "@/components/untils/Carousel"; import type { Route } from "./+types/news"; - - +import NewsList from "@/components/list/NewsList"; +import {Header} from "@/components/header/Header"; +import {TopNav} from "@/components/header/TopNav"; export function meta( ) { return [ { title: "New React Router App" }, @@ -10,5 +11,12 @@ export function meta( ) { } export default function Home() { - return ; + return ( + <> +
      + + + + ) + ; } From 7fbeca06bbab10ec43e87610c473a8a73feff2c3 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Tue, 18 Nov 2025 16:20:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/list/NewsList.tsx | 59 +++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/app/components/list/NewsList.tsx b/app/components/list/NewsList.tsx index 6e3f68c..bdc5959 100644 --- a/app/components/list/NewsList.tsx +++ b/app/components/list/NewsList.tsx @@ -2,21 +2,22 @@ import React from 'react'; import { mockNewsData } from './NewsData'; // 导入新闻数据 interface NewsProps { - title?: string; - description?: string; - time?: string; + 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-500 - cursor-pointer w-96"> -

      {title}

      -

      {time}

      +
      +
      url && window.open(url)} + className="flex items-center justify-between hover:text-blue-600 cursor-pointer transition duration-300 ease-in-out" + > +

      {title}

      +

      {time}

      ); @@ -25,16 +26,40 @@ const NewsItem: React.FC = ({ title = '', time = '', url = '' }) => { // 使用新闻数据渲染列表 const NewsList: React.FC = () => { return ( -
      -
        - {mockNewsData.map((news) => ( - - ))} -
      +
      +
      + {/* 科技新闻 */} +
      +
      +

      科技新闻

      + +
      +
        + {mockNewsData.map((news, index) => ( + + ))} +
      +
      + + {/* 社会新闻 */} +
      +
      +

      社会新闻

      + +
      +
        + {mockNewsData.map((news, index) => ( + + ))} +
      +
      +
      ); }; - - export default NewsList; \ No newline at end of file From e31bbdf78e55e00065ed3d89dc758d27a80210ad Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Tue, 18 Nov 2025 16:20:51 +0800 Subject: [PATCH 5/5] 1 --- app/components/untils/Carousel.tsx | 21 +++++++++++++++------ app/routes/news.tsx | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/components/untils/Carousel.tsx b/app/components/untils/Carousel.tsx index e9eff99..6f8ea42 100755 --- a/app/components/untils/Carousel.tsx +++ b/app/components/untils/Carousel.tsx @@ -31,7 +31,7 @@ export function CarouselDemo() { }, [api]); return ( -
      +
      - + {Array.from({ length: totalSlides }).map((_, index) => ( - +
      - - {index + 1} + +
      +
      + +
      +
      diff --git a/app/routes/news.tsx b/app/routes/news.tsx index 15dc361..973aa4a 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -2,6 +2,7 @@ import { CarouselDemo } from "@/components/untils/Carousel"; import type { Route } from "./+types/news"; import { Header } from "@/components/header/Header"; import { TopNav } from "@/components/header/TopNav"; +import NewsList from "@/components/list/NewsList"; export function meta( ) { @@ -17,6 +18,7 @@ export default function Home() {
      +
      ); }