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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: 'KCYPPHD' }).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. {/* <Flex justify='space-between' align='center' style={{ width: '100%', padding: '16px', background: '#ffffff', borderRadius: 8, cursor: 'pointer' }}>
  56. <Space size={20}>
  57. <Image src={`${Imageprefix}${item.image_url}`} width={100} height={100}></Image>
  58. <h3>{item.title}</h3>
  59. </Space>
  60. <Space size={20}>
  61. <div>
  62. {item.updated_at}
  63. </div>
  64. <RightOutlined />
  65. </Space>
  66. </Flex> */}
  67. </>
  68. ))
  69. }
  70. {
  71. !list || list.length == 0 && <Flex justify='center' align='center' style={{ padding: '16px', borderRadius: 8, cursor: 'pointer' }}>
  72. <EmptyResult description="暂无数据" />
  73. </Flex>
  74. }
  75. </Space>
  76. <Flex justify='center' align='center' style={{ margin: '40px 0' }}>
  77. <Pagination
  78. hideOnSinglePage
  79. total={total}
  80. showTotal={(total) => `总共${total}条`}
  81. current={page}
  82. pageSize={pageSize}
  83. pageSizeOptions={['12', '24', '36']}
  84. onChange={(page, pageSize) => {
  85. setPage(page)
  86. setPageSize(pageSize)
  87. GetSectionDetailByCode({ code: 'KCYCGZH' }).then(res => {
  88. GetArticleList({ page: page, pagesize: pageSize, section_id: res.data.id }).then(res1 => {
  89. setList(res1.data.articles)
  90. setTotal(res1.data.total)
  91. })
  92. })
  93. }}
  94. />
  95. </Flex>
  96. </div>
  97. </ConfigProvider >
  98. </>
  99. );
  100. };
  101. export default HomePage;