You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { useState, useEffect, useRef } from 'react';
  2. import { ProList, PageContainer } from '@ant-design/pro-components';
  3. import { ConfigProvider, Button, Flex, Input, Space, Tabs, Tooltip, Row, Col, Pagination, Tag, Image, Affix, Typography, Anchor } from 'antd';
  4. import { SearchOutlined, LikeOutlined, ArrowRightOutlined, RightOutlined } from '@ant-design/icons';
  5. import { useModel, connect, history, Link } from 'umi';
  6. import { Imageprefix } from '@/constants/index'
  7. import { GetSectionList, GetArticleList, GetSectionDetailByCode } from '@/services/apis/information';
  8. import TitleIndex from '@/components/Common/Title';
  9. import EmptyResult from '@/components/Common/EmptyResult'
  10. const HomePage: React.FC = () => {
  11. const [list, setList] = useState<object[]>([])
  12. const [total, setTotal] = useState<number>(0)
  13. const [page, setPage] = useState<number>(1)
  14. const [pageSize, setPageSize] = useState<number>(7)
  15. useEffect(() => {
  16. GetSectionDetailByCode({ code: 'KCYTZGG' }).then(res => {
  17. GetArticleList({ page: 1, pagesize: 6, section_id: res.data.id }).then(res1 => {
  18. setList(res1.data.articles)
  19. setTotal(res1.data.total)
  20. })
  21. })
  22. }, [])
  23. return (
  24. <>
  25. <ConfigProvider
  26. theme={{
  27. token: {
  28. colorPrimary: '#19be6e',
  29. },
  30. components: {
  31. Button: {
  32. colorText: '#19be6e'
  33. }
  34. }
  35. }}
  36. >
  37. <div style={{ minHeight: 1000 }}>
  38. <Space direction='vertical' size={10} style={{ width: '100%' }}>
  39. {
  40. list && list.length > 0 && list.map((item, index) => (
  41. <>
  42. <Link to={{ pathname: `/sciencetechnologypark/information/detail?id=${item.id}` }} target='_blank'>
  43. <Flex justify='space-between' align='center' style={{ width: '100%', padding: '16px', color: '#000000', background: '#ffffff', cursor: 'pointer' }}>
  44. <Space size={20}>
  45. <h3>{item.title}</h3>
  46. </Space>
  47. <Space size={20}>
  48. <div style={{ color: '#999' }}>
  49. {item.updated_at}
  50. </div>
  51. <RightOutlined style={{ color: '#999' }} />
  52. </Space>
  53. </Flex>
  54. </Link>
  55. {/* <Link to={{pathname: `/sciencetechnologypark/information/detail?id=${item.id}` }} target='_blank'>
  56. <Flex justify='space-between' align='center' style={{ width: '100%', padding: '16px', color: '#000000', background: '#ffffff', borderRadius: 8, cursor: 'pointer' }}>
  57. <Space size={20}>
  58. <Image src={`${Imageprefix}${item.cover_img}`} width={100} height={100}></Image>
  59. <h3>{item.title}</h3>
  60. </Space>
  61. <Space size={20}>
  62. <div>
  63. {item.updated_at}
  64. </div>
  65. <RightOutlined />
  66. </Space>
  67. </Flex>
  68. </Link> */}
  69. </>
  70. ))
  71. }
  72. {
  73. !list || list.length == 0 && <Flex justify='center' align='center' style={{ padding: '16px', borderRadius: 8, cursor: 'pointer' }}>
  74. <EmptyResult description="暂无数据" />
  75. </Flex>
  76. }
  77. </Space>
  78. <Flex justify='center' align='center' style={{ margin: '40px 0' }}>
  79. <Pagination
  80. hideOnSinglePage
  81. total={total}
  82. showTotal={(total) => `总共${total}条`}
  83. current={page}
  84. pageSize={pageSize}
  85. pageSizeOptions={['12', '24', '36']}
  86. onChange={(page, pageSize) => {
  87. setPage(page)
  88. setPageSize(pageSize)
  89. GetSectionDetailByCode({ code: 'KCYTZGG' }).then(res => {
  90. GetArticleList({ page: page, pagesize: pageSize, section_id: res.data.id }).then(res1 => {
  91. setList(res1.data.articles)
  92. setTotal(res1.data.total)
  93. })
  94. })
  95. }}
  96. />
  97. </Flex>
  98. </div>
  99. </ConfigProvider >
  100. </>
  101. );
  102. };
  103. export default HomePage;