2
0

ChapterCard.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { Link } from "react-router-dom";
  2. import { Row, Col, Progress, Space } from "antd";
  3. import { Typography } from "antd";
  4. import TimeShow from "../general/TimeShow";
  5. import TocPath from "../corpus/TocPath";
  6. import TagArea from "../tag/TagArea";
  7. import type { IChannelApiData } from "../api/Channel";
  8. import ChannelListItem from "../channel/ChannelListItem";
  9. import { IStudio } from "../auth/StudioName";
  10. import { ITagData } from "./ChapterTagList";
  11. const { Title, Paragraph, Text } = Typography;
  12. export interface ChapterData {
  13. title: string;
  14. paliTitle: string;
  15. path: string;
  16. book: number;
  17. paragraph: number;
  18. summary: string;
  19. tag: ITagData[];
  20. channel: IChannelApiData;
  21. studio: IStudio;
  22. progress: number;
  23. createdAt: string;
  24. updatedAt: string;
  25. hit: number;
  26. like: number;
  27. }
  28. interface IWidgetChapterCard {
  29. data: ChapterData;
  30. onTagClick?: Function;
  31. }
  32. const Widget = ({ data, onTagClick }: IWidgetChapterCard) => {
  33. const path = JSON.parse(data.path);
  34. console.log("path", data.path);
  35. return (
  36. <>
  37. <Row>
  38. <Col>
  39. <Row>
  40. <Col span={16}>
  41. <Title level={5}>
  42. <Link
  43. to={`/article/chapter/${data.book}-${data.paragraph}_${data.channel.id}`}
  44. target="_blank"
  45. >
  46. {data.title ? data.title : data.paliTitle}
  47. </Link>
  48. </Title>
  49. <Text type="secondary">{data.paliTitle}</Text>
  50. <TocPath data={path} />
  51. </Col>
  52. <Col span={8}>
  53. <Progress percent={data.progress} size="small" />
  54. </Col>
  55. </Row>
  56. <Row>
  57. <Col>
  58. <Paragraph
  59. ellipsis={{
  60. rows: 2,
  61. expandable: false,
  62. symbol: "more",
  63. }}
  64. >
  65. {data.summary}
  66. </Paragraph>
  67. </Col>
  68. </Row>
  69. <div style={{ display: "flex", justifyContent: "space-between" }}>
  70. <div>
  71. <TagArea
  72. data={data.tag}
  73. onTagClick={(tag: string) => {
  74. if (typeof onTagClick !== "undefined") {
  75. onTagClick(tag);
  76. }
  77. }}
  78. />
  79. </div>
  80. <Space>
  81. <ChannelListItem channel={data.channel} studio={data.studio} />
  82. <TimeShow time={data.updatedAt} title="UpdatedAt" />
  83. </Space>
  84. </div>
  85. </Col>
  86. </Row>
  87. </>
  88. );
  89. };
  90. export default Widget;