hot_books.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import styles from './index.less'
  2. import Header from "./header";
  3. import { Empty, Tag } from "antd";
  4. import { ReactElement, JSXElementConstructor, ReactNode, ReactPortal, Key } from "react";
  5. import { MyIcon } from "@/global";
  6. // 热门书
  7. export function HotBooks(props: {
  8. data: {
  9. appComponentId: number | string;
  10. componentType: string;
  11. showRightButton?: boolean;
  12. componentName?: string;
  13. remark?: string;
  14. configs?: any[];
  15. }
  16. }) {
  17. const { data: { configs, componentName, showRightButton } } = props
  18. return <div className={`${styles.hot_books}`}>
  19. <Header title={componentName || "今日热书"} showBtn={showRightButton} />
  20. {configs?.[0]?.bookInfo ? <>
  21. <div className={styles.top}>
  22. <span>
  23. {configs?.[0]?.bookInfo?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
  24. <img src={configs?.[0]?.bookInfo?.picUrl} onError={(e: any) => {
  25. e.target.src = localStorage.getItem("nocover")
  26. }} />
  27. </span>
  28. <div>
  29. <strong>{configs?.[0]?.bookInfo?.bookName || "书名"}</strong>
  30. <span>{configs?.[0]?.bookInfo?.bookDesc || "描述"}</span>
  31. <div>
  32. <span>{configs?.[0]?.bookInfo?.authorInfo?.authorName || configs?.[0]?.bookInfo?.authorName }·{configs?.[0]?.bookInfo?.wordCount}万字·{configs?.[0]?.bookInfo?.bookStatus == 0 ? "连载中" : "完结"}</span>
  33. <Tag >{configs?.[0]?.bookInfo?.labelInfoList?.[0]?.name}</Tag>
  34. </div>
  35. </div>
  36. </div>
  37. <div className={styles.list}>
  38. {
  39. configs?.filter((i: any, eq: number) => eq != 0)?.map((item: { bookInfo: { vipFree: any, picUrl: string | undefined; bookName: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; }; }, index: Key | null | undefined) => {
  40. return <div key={index} className={styles.box}>
  41. <div>
  42. {item?.bookInfo?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
  43. <img src={item?.bookInfo?.picUrl} onError={(e: any) => {
  44. e.target.src = localStorage.getItem("nocover")
  45. }} />
  46. </div>
  47. <span>{item?.bookInfo?.bookName}</span>
  48. </div>
  49. })
  50. }
  51. </div>
  52. </> : <div className={styles.banners_box} style={{ display: "flex", alignItems: 'center', justifyContent: 'center', minHeight: 'calc(100vw / 10)', }}>
  53. <div style={{ justifyContent: 'center', display: 'flex', width: '100%' }}><Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无数据请选中后设置,不配置将使用系统默认配置" /></div>
  54. </div>
  55. }
  56. </div>
  57. }