2023-11-01 17:27:06 +08:00
|
|
|
"use client";
|
2023-11-06 17:27:50 +08:00
|
|
|
import React, { useEffect, useRef } from "react";
|
2023-11-01 17:27:06 +08:00
|
|
|
|
2023-11-03 17:25:10 +08:00
|
|
|
import Swiper from "swiper";
|
|
|
|
import { Pagination, EffectCoverflow, Autoplay } from "swiper/modules";
|
|
|
|
|
|
|
|
// import Swiper and modules styles
|
|
|
|
import "swiper/css";
|
|
|
|
import "swiper/css/pagination";
|
|
|
|
import "swiper/css/effect-coverflow";
|
|
|
|
import "swiper/css/autoplay";
|
2023-11-07 17:14:42 +08:00
|
|
|
import Image from "next/image";
|
2023-11-01 17:27:06 +08:00
|
|
|
|
2023-11-06 17:27:50 +08:00
|
|
|
const data = [
|
2023-11-01 17:27:06 +08:00
|
|
|
{
|
|
|
|
id: 28,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah9.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/99c2f8c3-aba8-4872-a9b9-dfbcf128c062.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/99c2f8c3-aba8-4872-a9b9-dfbcf128c062.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "40KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 27,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah7.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/aba2a38f-ee62-4730-af7a-5b8933ed7497.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/aba2a38f-ee62-4730-af7a-5b8933ed7497.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "4KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 26,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah8.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/63523f59-9b59-40d1-a654-c4678f8a1913.jpeg",
|
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/63523f59-9b59-40d1-a654-c4678f8a1913.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
ext: "jpeg",
|
|
|
|
size: "29KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 25,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah2.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/5bedf085-841a-48cc-bca2-9c9b2c751b48.jpeg",
|
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/5bedf085-841a-48cc-bca2-9c9b2c751b48.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
ext: "jpeg",
|
|
|
|
size: "26KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 24,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah5.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/2f19a501-89f7-4f78-9487-096a3799736d.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/2f19a501-89f7-4f78-9487-096a3799736d.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "22KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 23,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah6.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/70f4bea2-77a4-4595-a3a5-5c60711afae6.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/70f4bea2-77a4-4595-a3a5-5c60711afae6.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "22KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 22,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah3.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/82309b4a-22e8-4b06-8e9d-d2b114ef3aad.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/82309b4a-22e8-4b06-8e9d-d2b114ef3aad.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "14KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 21,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah1.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/5e3a02dc-2c7c-4671-9151-79315a53a3d2.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/5e3a02dc-2c7c-4671-9151-79315a53a3d2.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "9KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 20,
|
|
|
|
cid: 3,
|
|
|
|
name: "ah4.jpeg",
|
2023-11-06 17:27:50 +08:00
|
|
|
path: "api/uploads/image/20231101/106409ac-e454-47f2-a383-8ea572718b3d.jpeg",
|
2023-11-01 17:27:06 +08:00
|
|
|
uri: "http://localhost:8082/api/uploads/image/20231101/106409ac-e454-47f2-a383-8ea572718b3d.jpeg",
|
|
|
|
ext: "jpeg",
|
|
|
|
size: "31KB",
|
|
|
|
createTime: "2023-11-01 10:40:15",
|
|
|
|
updateTime: "2023-11-01 10:40:15",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const AnhuiSwiper = () => {
|
2023-11-06 17:27:50 +08:00
|
|
|
const swiperRef = useRef<HTMLDivElement>(null);
|
2023-11-03 17:25:10 +08:00
|
|
|
useEffect(() => {
|
|
|
|
let swiper: Swiper | null = null;
|
2023-11-06 17:27:50 +08:00
|
|
|
if (swiperRef.current && data) {
|
|
|
|
swiper = new Swiper(swiperRef.current, {
|
|
|
|
modules: [Pagination, EffectCoverflow, Autoplay],
|
|
|
|
autoplay: {
|
|
|
|
delay: 2000,
|
|
|
|
},
|
|
|
|
loop: true,
|
|
|
|
slidesPerView: 3,
|
|
|
|
effect: "coverflow",
|
|
|
|
pagination: {
|
|
|
|
el: ".swiper-pagination",
|
|
|
|
dynamicBullets: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2023-11-03 17:25:10 +08:00
|
|
|
return () => {
|
|
|
|
swiper?.destroy();
|
|
|
|
swiper = null;
|
|
|
|
};
|
2023-11-07 17:14:42 +08:00
|
|
|
}, []);
|
2023-11-01 17:27:06 +08:00
|
|
|
return (
|
2023-11-03 17:25:10 +08:00
|
|
|
<div className={"flex h-[205px] flex-col bg-white"}>
|
2023-11-01 17:27:06 +08:00
|
|
|
<div
|
|
|
|
className={
|
2023-11-03 17:25:10 +08:00
|
|
|
"flex h-[30px] items-center bg-[#1f87e8] pl-[5px] text-white"
|
2023-11-01 17:27:06 +08:00
|
|
|
}
|
|
|
|
>
|
|
|
|
安徽风采
|
|
|
|
</div>
|
2023-11-03 17:25:10 +08:00
|
|
|
<div className={"h-0 flex-1"}>
|
2023-11-06 17:27:50 +08:00
|
|
|
<div ref={swiperRef} className={"swiper h-full"}>
|
2023-11-03 17:25:10 +08:00
|
|
|
<div className={"swiper-wrapper"}>
|
2023-11-06 17:27:50 +08:00
|
|
|
{data.map((el) => (
|
2023-11-03 17:25:10 +08:00
|
|
|
<div className={"swiper-slide"} key={el.id}>
|
|
|
|
<img
|
|
|
|
className={"h-full w-full object-contain"}
|
2023-11-06 17:27:50 +08:00
|
|
|
src={`${
|
|
|
|
process.env.NEXT_PUBLIC_CLIENT_ADMIN_BASE_URL
|
2023-11-08 15:42:55 +08:00
|
|
|
}${el.path.match(/\/uploads\/.*/)?.[0]}`}
|
2023-11-03 17:25:10 +08:00
|
|
|
alt={""}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
<div className={"swiper-pagination"}></div>
|
|
|
|
</div>
|
2023-11-01 17:27:06 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AnhuiSwiper;
|