import { useVirtualList } from "ahooks"; import { Button, Col, Row, Image, Spin, Space, Drawer, Empty } from "antd"; import { JSXElementConstructor, Key, ReactElement, ReactFragment, ReactPortal, useEffect, useMemo, useRef, useState } from "react"; import { MyIcon } from "@/global"; import { useToken } from "@ant-design/pro-components"; function ReadBook(props: { next: (listData: { id: number }) => Promise, listData: any }) { let { next, listData } = props; const divRef = useRef(null); let { token } = useToken() const [isFetching, setIsFetching] = useState(true); const [newData, setNewData] = useState(null); const [content, setContent] = useState(null) const containerRef = useRef(null); const wrapperRef = useRef(null); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (divRef.current) { if (event.key === "ArrowDown") { divRef.current.scrollBy(0, 50); } else if (event.key === "ArrowUp") { divRef.current.scrollBy(0, -50); } } }; window.addEventListener("keydown", handleKeyDown); return () => { window.removeEventListener("keydown", handleKeyDown); }; }, []); async function getBookContent(id: any) { let content = await next(id) console.log(content) // setContent(content) } useEffect(() => { if (divRef.current) { divRef.current.scrollTop = 0 } }, [content, divRef]) return ( listData &&
{listData?.vipFree && } { e.target.src = localStorage.getItem("nocover") }} />
作者{listData?.authorInfo?.authorName} 类别{listData?.categoryInfo?.name} 来源{({ "UPLOAD": "管理员", "CREATOR": "创作者" } as any)[listData.source]} 频道{listData?.corpUserName == 0 ? "男频" : "女频"} 标签: { listData?.labelInfoList?.map((tags: { id: string, name: string }, index: number) => { return tags?.name }).join(',') } 状态{["连载中", "已完结"][listData.bookStatus]} 评分:{listData?.score || 0} 点击量:{listData?.visitCount || 0} 总字数:{listData?.wordCount || 0} 上架状态:{["上架中", "已下架"][listData.shelveStatus]} 描述:{listData?.bookDesc}
{listData.list?.map((ele: any, index: number) => ( { getBookContent(ele?.chapterInfo?.id) }} >
{ele.needPay && } {ele?.chapterInfo?.chapterName}
))} {listData.list?.length === 0 &&
暂无章节
} />
}
{/* 阅读小说 */} { setContent(null) }} footer={null} width={'60%'} destroyOnClose={true} styles={{ body: { padding: 0 } }} closeIcon={false} // title={
{content?.chapterName}
} > { content && <>
') }}>
{content?.chapterNo > 1 && } {content?.chapterNo < listData?.list?.length && }
}
); } export default ReadBook;