"use client"; import styles from "@/app/_assets/page.module.css"; import Image from "next/image"; import trumpetIcon from "@/app/_assets/trumpet-icon.png"; import { articleDetail, listArticles } from "@/app/_services/articles"; import { htmlToText } from "html-to-text"; import Link from "next/link"; import { useEffect, useRef, useState } from "react"; import { Article, ArticleDetail } from "@/app/_types/article"; import useSWR from "swr"; import { axiosClientInstance } from "@/app/_lib/request"; import { BaseResponse, PageData } from "@/app/_types/base"; import Swiper from "swiper"; import { Pagination, Autoplay } from "swiper/modules"; // import Swiper and modules styles import "swiper/css"; import "swiper/css/pagination"; import "swiper/css/autoplay"; const BranchLifeSketch = () => { const { data } = useSWR("/article/list?cid=13", (key: string) => axiosClientInstance.get>>(key), ); const swiperRef = useRef(null); useEffect(() => { let swiper: Swiper | null = null; if (swiperRef.current && data) { swiper = new Swiper(swiperRef.current, { modules: [Pagination, Autoplay], loop: true, slidesPerView: 2, direction: "vertical", mousewheel: true, autoplay: { delay: 1500, pauseOnMouseEnter: true, }, }); } return () => { swiper?.destroy(); swiper = null; }; }, [data]); return ( <>
{"trumpet 分院生活剪影
{data?.data.lists?.map((article) => { return (
); })}
); }; const ArticleItem = ({ article }: { article: Article }) => { const { data } = useSWR(`/pc/articleDetail?id=${article.id}`, (key) => axiosClientInstance.get>(key), ); const cover_path = article.image?.match(/\/uploads\/.*/)?.[0]; return (
{""}
{article.title}
{data?.data.content && htmlToText(data.data.content, { selectors: [ { selector: "img", format: "skip", }, ], })}
); }; export default BranchLifeSketch;