Merge branch 'main' of http://113.45.67.59:3003/qiuchenfan/news
This commit is contained in:
commit
b477d75218
|
|
@ -0,0 +1,78 @@
|
||||||
|
// src/components/CarouselDemo.tsx
|
||||||
|
import * as React from "react";
|
||||||
|
import Autoplay from "embla-carousel-autoplay";
|
||||||
|
|
||||||
|
import { Card, CardContent } from "@/ui/card";
|
||||||
|
import {
|
||||||
|
Carousel,
|
||||||
|
CarouselContent,
|
||||||
|
CarouselItem,
|
||||||
|
CarouselNext,
|
||||||
|
CarouselPrevious,
|
||||||
|
} from "@/ui/carousel";
|
||||||
|
|
||||||
|
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 AutoCarouselDemo() {
|
||||||
|
return (
|
||||||
|
<div className="relative w-full mx-auto overflow-hidden">
|
||||||
|
{/* 左右渐隐遮罩 */}
|
||||||
|
<div className="absolute inset-y-0 left-0 w-16 bg-gradient-to-r from-black/70 via-transparent pointer-events-none z-10" />
|
||||||
|
<div className="absolute inset-y-0 right-0 w-16 bg-gradient-to-l from-black/70 via-transparent pointer-events-none z-10" />
|
||||||
|
|
||||||
|
<Carousel
|
||||||
|
opts={{
|
||||||
|
loop: true,
|
||||||
|
align: "start",
|
||||||
|
}}
|
||||||
|
plugins={[
|
||||||
|
Autoplay({
|
||||||
|
delay: 3000,
|
||||||
|
stopOnInteraction: false,
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
<CarouselContent className="flex gap-4">
|
||||||
|
{imageUrls.map((src, index) => (
|
||||||
|
<CarouselItem
|
||||||
|
key={index}
|
||||||
|
className="basis-1/4 md:basis-1/3 lg:basis-1/4 flex-shrink-0 relative"
|
||||||
|
>
|
||||||
|
{/* 悬停放大容器 */}
|
||||||
|
<div
|
||||||
|
className="p-1 transition-transform duration-500 hover:scale-105 cursor-pointer"
|
||||||
|
style={{
|
||||||
|
transform: 'scale(1)',
|
||||||
|
transition: 'all 0.5s ease',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Card className="overflow-hidden border-none shadow-lg">
|
||||||
|
<CardContent className="flex aspect-square items-center justify-center p-0 relative">
|
||||||
|
<img
|
||||||
|
src={src}
|
||||||
|
alt={`Slide ${index + 1}`}
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
loading="lazy" // 启用懒加载
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</CarouselItem>
|
||||||
|
))}
|
||||||
|
</CarouselContent>
|
||||||
|
|
||||||
|
{/* 左右箭头控制 */}
|
||||||
|
<CarouselPrevious className="absolute left-2 top-1/2 -translate-y-1/2 z-20" />
|
||||||
|
<CarouselNext className="absolute right-2 top-1/2 -translate-y-1/2 z-20" />
|
||||||
|
</Carousel>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// src/components/CarouselDemo.tsx
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import Autoplay from "embla-carousel-autoplay";
|
import Autoplay from "embla-carousel-autoplay";
|
||||||
|
|
||||||
|
|
@ -10,22 +11,14 @@ import {
|
||||||
CarouselPrevious,
|
CarouselPrevious,
|
||||||
type CarouselApi,
|
type CarouselApi,
|
||||||
} from "@/ui/carousel";
|
} 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() {
|
export function CarouselDemo() {
|
||||||
const [api, setApi] = React.useState<CarouselApi>();
|
const [api, setApi] = React.useState<CarouselApi>();
|
||||||
const [current, setCurrent] = React.useState(0);
|
const [current, setCurrent] = React.useState(0);
|
||||||
const [count, setCount] = React.useState(0);
|
const [count, setCount] = React.useState(0);
|
||||||
|
|
||||||
const totalSlides = imageUrls.length;
|
const totalSlides = 6;
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
|
@ -39,7 +32,7 @@ export function CarouselDemo() {
|
||||||
}, [api]);
|
}, [api]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full max-w-xs">
|
<div className="relative w-full max-w-4xl mx-auto">
|
||||||
<Carousel
|
<Carousel
|
||||||
opts={{
|
opts={{
|
||||||
loop: true,
|
loop: true,
|
||||||
|
|
@ -51,19 +44,21 @@ export function CarouselDemo() {
|
||||||
}),
|
}),
|
||||||
]}
|
]}
|
||||||
setApi={setApi}
|
setApi={setApi}
|
||||||
className="w-full"
|
|
||||||
>
|
>
|
||||||
<CarouselContent>
|
<CarouselContent className="h-full w-full">
|
||||||
{imageUrls.map((src, index) => (
|
{Array.from({ length: totalSlides }).map((_, index) => (
|
||||||
<CarouselItem key={index}>
|
<CarouselItem key={index} className="w-full h-full">
|
||||||
<div className="p-1">
|
<div className="p-1">
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="flex aspect-square items-center justify-center p-6">
|
<CardContent className="flex aspect-square items-center justify-center ">
|
||||||
<img
|
<div
|
||||||
src={src}
|
className="w-full h-full"
|
||||||
alt={`Slide ${index + 1}`}
|
style={{
|
||||||
className="w-full h-full object-cover"
|
backgroundImage: "url('/app/images/header.png')",
|
||||||
/>
|
backgroundSize: '100% 100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ interface NewsItem {
|
||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FireNewsList: React.FC = () => {
|
export function FireNewsList() {
|
||||||
const newsItems: NewsItem[] = [
|
const newsItems: NewsItem[] = [
|
||||||
{
|
{
|
||||||
content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...",
|
content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...",
|
||||||
|
|
@ -21,11 +21,13 @@ const FireNewsList: React.FC = () => {
|
||||||
{
|
{
|
||||||
content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...",
|
content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
content: "记者从16日召开的海南省政府新闻发布会上获悉,2018年,海南旅游总收入达1,262万人次,支出达399.7亿元...",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-gray-200 p-4 rounded-lg">
|
<div className="bg-gray-200 p-4 rounded-lg h-full">
|
||||||
{/* 标题栏 */}
|
{/* 标题栏 */}
|
||||||
<div className="flex justify-between items-center mb-4">
|
<div className="flex justify-between items-center mb-4">
|
||||||
<h2 className="text-xl font-bold text-gray-800">烽火要闻</h2>
|
<h2 className="text-xl font-bold text-gray-800">烽火要闻</h2>
|
||||||
|
|
@ -59,5 +61,3 @@ const FireNewsList: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FireNewsList;
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { CarouselDemo } from "../Carousel";
|
||||||
|
import {FireNewsList} from "./FireNewsList";
|
||||||
|
|
||||||
|
|
||||||
|
export function FhjtPage() {
|
||||||
|
return(
|
||||||
|
<div className="relative w-full max-w-4xl mx-auto overflow-hidden aspect-square">
|
||||||
|
{/* 轮播背景图 */}
|
||||||
|
<div className="absolute inset-0 z-0">
|
||||||
|
<CarouselDemo />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 固定的烽火要闻 */}
|
||||||
|
<div className="absolute top-0 right-0 w-1/3 h-full p-1">
|
||||||
|
<FireNewsList />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { CarouselDemo } from "../Carousel";
|
||||||
|
import {FireNewsList} from "./FireNewsList";
|
||||||
|
|
||||||
|
|
||||||
|
export function FhrxPage() {
|
||||||
|
return(
|
||||||
|
<div className="relative w-full max-w-4xl mx-auto overflow-hidden aspect-square">
|
||||||
|
{/* 轮播背景图 */}
|
||||||
|
<div className="absolute inset-0 z-0">
|
||||||
|
<CarouselDemo />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 固定的烽火要闻 */}
|
||||||
|
<div className="absolute top-0 right-0 w-1/3 h-full p-1">
|
||||||
|
<FireNewsList />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { CarouselDemo } from "../Carousel";
|
||||||
|
import {FireNewsList} from "./FireNewsList";
|
||||||
|
|
||||||
|
|
||||||
|
export function FhwsPage() {
|
||||||
|
return(
|
||||||
|
<div className="relative w-full max-w-4xl mx-auto overflow-hidden aspect-square">
|
||||||
|
{/* 轮播背景图 */}
|
||||||
|
<div className="absolute inset-0 z-0">
|
||||||
|
<CarouselDemo />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 固定的烽火要闻 */}
|
||||||
|
<div className="absolute top-0 left-0 w-1/3 h-full p-1">
|
||||||
|
<FireNewsList />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { CarouselDemo } from "../Carousel";
|
||||||
|
import {FireNewsList} from "./FireNewsList";
|
||||||
|
|
||||||
|
|
||||||
|
export function FhywPage() {
|
||||||
|
return(
|
||||||
|
<div className="relative w-full max-w-4xl mx-auto overflow-hidden aspect-square">
|
||||||
|
{/* 轮播背景图 */}
|
||||||
|
<div className="absolute inset-0 z-0">
|
||||||
|
<CarouselDemo />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 固定的烽火要闻 */}
|
||||||
|
<div className="absolute top-0 right-0 w-1/3 h-full p-1">
|
||||||
|
<FireNewsList />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ export function Header(){
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<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')" }}
|
style={{ backgroundImage: "url('/app/images/header.png')" }}
|
||||||
>
|
>
|
||||||
{/* 时间显示 只显示日期: "2025/3/15"*/}
|
{/* 时间显示 只显示日期: "2025/3/15"*/}
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
import { CarouselDemo } from "@/components/Carousel";
|
|
||||||
import type { Route } from "./+types/news";
|
import type { Route } from "./+types/news";
|
||||||
import Integrated from "@/components/news/body/Integrated";
|
import Integrated from "@/components/news/body/Integrated";
|
||||||
import CultureBgPage from "@/components/news/body/Culturebg";
|
import CultureBgPage from "@/components/news/body/Culturebg";
|
||||||
import {Header} from "@/components/header/Header";
|
import {Header} from "@/components/news/header/Header";
|
||||||
import {TopNav} from "@/components/header/TopNav";
|
import {TopNav} from "@/components/news/header/TopNav";
|
||||||
import NewsList from "@/components/list/NewsList";
|
import NewsList from "@/components/list/NewsList";
|
||||||
|
import ImageGridSection from "@/components/body/ImageGridSection";
|
||||||
import GrassrootsDynamics from "@/components/body/GrassrootsDynamics";
|
import GrassrootsDynamics from "@/components/body/GrassrootsDynamics";
|
||||||
|
import { FhywPage } from "@/components/FireNews/fhyw";
|
||||||
|
import { FhjtPage } from "@/components/FireNews/fhjt";
|
||||||
|
import { FhwsPage } from "@/components/FireNews/fhws";
|
||||||
|
import { FhrxPage } from "@/components/FireNews/fhrx";
|
||||||
export function meta( ) {
|
export function meta( ) {
|
||||||
return [
|
return [
|
||||||
{ title: "New React Router App" },
|
{ title: "New React Router App" },
|
||||||
|
|
@ -19,8 +24,14 @@ export default function Home() {
|
||||||
<div>
|
<div>
|
||||||
<Header />
|
<Header />
|
||||||
<TopNav />
|
<TopNav />
|
||||||
<CarouselDemo />
|
<FhywPage />
|
||||||
<NewsList />
|
<NewsList />
|
||||||
|
<ImageGridSection />
|
||||||
|
<FhjtPage/>
|
||||||
|
<FhwsPage/>
|
||||||
|
<FhrxPage />
|
||||||
|
<Integrated />
|
||||||
|
<CultureBgPage />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue