ChapterCard.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { Link } from "react-router-dom";
  2. import { Row, Col } 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 { TagNode } from "../tag/TagArea";
  8. import type { ChannelInfoProps } from "../api/Channel";
  9. import ChannelListItem from "../channel/ChannelListItem";
  10. const { Title, Paragraph, Text } = Typography;
  11. export interface ChapterData {
  12. title: string;
  13. paliTitle: string;
  14. path: string;
  15. book: number;
  16. paragraph: number;
  17. summary: string;
  18. tag: TagNode[];
  19. channel: ChannelInfoProps;
  20. createdAt: string;
  21. updatedAt: string;
  22. hit: number;
  23. like: number;
  24. }
  25. interface IWidgetChapterCard {
  26. data: ChapterData;
  27. }
  28. const Widget = ({ data }: IWidgetChapterCard) => {
  29. const path = JSON.parse(data.path);
  30. const tags = data.tag;
  31. return (
  32. <>
  33. <Row>
  34. <Col>
  35. <Row>
  36. <Col span={16}>
  37. <Title level={5}>
  38. <Link
  39. to={`/article/chapter/${data.book}-${data.paragraph}_${data.channel.channelId}`}
  40. target="_blank"
  41. >
  42. {data.title}
  43. </Link>
  44. </Title>
  45. <Text type="secondary">{data.paliTitle}</Text>
  46. <TocPath data={path} />
  47. </Col>
  48. <Col span={8}>进度条</Col>
  49. </Row>
  50. <Row>
  51. <Col>
  52. <Paragraph
  53. ellipsis={{
  54. rows: 2,
  55. expandable: false,
  56. symbol: "more",
  57. }}
  58. >
  59. {data.summary}
  60. </Paragraph>
  61. </Col>
  62. </Row>
  63. <Row>
  64. <Col span={16}>
  65. <TagArea data={tags} />
  66. </Col>
  67. <Col span={5}>
  68. <ChannelListItem data={data.channel} />
  69. </Col>
  70. <Col span={3}>
  71. <TimeShow time={data.updatedAt} title="UpdatedAt" />
  72. </Col>
  73. </Row>
  74. </Col>
  75. </Row>
  76. </>
  77. );
  78. };
  79. export default Widget;