Merge branch 'main' of http://113.45.67.59:3003/qiuchenfan/news
This commit is contained in:
commit
e6b12574b4
|
|
@ -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<CarouselApi>();
|
||||
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 (
|
||||
<div className="relative w-full max-w-xs">
|
||||
<div className="relative w-full max-w-4xl mx-auto">
|
||||
<Carousel
|
||||
opts={{
|
||||
loop: true,
|
||||
|
|
@ -51,19 +43,21 @@ export function CarouselDemo() {
|
|||
}),
|
||||
]}
|
||||
setApi={setApi}
|
||||
className="w-full"
|
||||
>
|
||||
<CarouselContent>
|
||||
{imageUrls.map((src, index) => (
|
||||
<CarouselItem key={index}>
|
||||
<CarouselContent className="h-full w-full">
|
||||
{Array.from({ length: totalSlides }).map((_, index) => (
|
||||
<CarouselItem key={index} className="w-full h-full">
|
||||
<div className="p-1">
|
||||
<Card>
|
||||
<CardContent className="flex aspect-square items-center justify-center p-6">
|
||||
<img
|
||||
src={src}
|
||||
alt={`Slide ${index + 1}`}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
<CardContent className="flex aspect-square items-center justify-center ">
|
||||
<div
|
||||
className="w-full h-full"
|
||||
style={{
|
||||
backgroundImage: "url('/app/images/header.png')",
|
||||
backgroundSize: '100% 100%',
|
||||
}}
|
||||
>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import React from 'react';
|
||||
import List from '../list/List';
|
||||
|
||||
export default function GrassrootsDynamics() {
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-6 bg-gray-50 p-6 rounded-2xl shadow-xl">
|
||||
{/* 左边图片 */}
|
||||
<div className="w-full h-auto rounded-lg shadow-md">
|
||||
<img
|
||||
src="/images/carousel-1.jpg"
|
||||
alt="基层动态"
|
||||
/>
|
||||
</div>
|
||||
{/* 右边列表 */}
|
||||
<div>
|
||||
<List />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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<NewsProps> = ({ title = '', time = '', url = '' }) => {
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<div
|
||||
onClick={() => url && window.open(url)}
|
||||
className="flex items-center justify-between hover:text-blue-600 cursor-pointer transition duration-300 ease-in-out"
|
||||
>
|
||||
<h3 className="text-lg font-semibold text-gray-800">{title}</h3>
|
||||
<p className="text-sm text-gray-500">{time}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 使用新闻数据渲染列表
|
||||
const List: React.FC = () => {
|
||||
return (
|
||||
<div className=" ">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 ">
|
||||
<div className=" p-6 rounded-lg ">
|
||||
<ul className="space-y-4">
|
||||
{mockNewsData.map((news) => (
|
||||
<NewsItem title={news.title} time={news.time} url={news.url} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default List;
|
||||
|
|
@ -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();
|
||||
export const mockNewsTitleData = NewsTitleData();
|
||||
|
|
@ -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<NewsProps> = ({ title = '', time = '', url = '' }) => {
|
||||
return (
|
||||
<div className="mb-4">
|
||||
|
|
@ -37,8 +43,8 @@ const NewsList: React.FC = () => {
|
|||
</button>
|
||||
</div>
|
||||
<ul className="space-y-4">
|
||||
{mockNewsData.map((news, index) => (
|
||||
<NewsItem key={index} title={news.title} time={news.time} url={news.url} />
|
||||
{mockNewsData.map((news) => (
|
||||
<NewsItem title={news.title} time={news.time} url={news.url} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export function Header(){
|
|||
|
||||
return (
|
||||
<div
|
||||
className="relative w-[1280px] h-[704px] bg-cover bg-center left-1/2 transform -translate-x-1/2"
|
||||
className="relative w-full h-180 bg-cover bg-center left-1/2 transform -translate-x-1/2"
|
||||
style={{ backgroundImage: "url('/app/images/header.png')" }}
|
||||
>
|
||||
{/* 时间显示 只显示日期: "2025/3/15"*/}
|
||||
|
|
|
|||
|
|
@ -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() {
|
|||
<div>
|
||||
<Header />
|
||||
<TopNav />
|
||||
<CarouselDemo />
|
||||
<NewsList />
|
||||
<<<<<<< HEAD
|
||||
<ImageGridSection />
|
||||
{/* <Integrated /> */}
|
||||
<CultureBgPage />
|
||||
<Integrated />
|
||||
|
||||
=======
|
||||
>>>>>>> 858176d3dcd4442d093f13eeca279711b756adb8
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue