Statistics.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Title from '@/pages/home/components/Title';
  2. import React from 'react';
  3. import './index.less';
  4. type StatisticsItem = {
  5. name: string;
  6. value: number | string;
  7. children: React.ReactNode | string;
  8. permission?: any;
  9. };
  10. interface StatisticsProps {
  11. extra?: React.ReactNode | string;
  12. style?: any;
  13. height?: any;
  14. data: StatisticsItem[];
  15. title: string;
  16. }
  17. const defaultImage = require('/public/images/home/top-1.svg');
  18. const Statistics = (props: StatisticsProps) => {
  19. return (
  20. <div className={'home-statistics'} style={{ height: props.height }}>
  21. <Title title={props.title} extra={props.extra} />
  22. <div className={'home-statistics-body'} style={props.style}>
  23. {props.data.map((item) => (
  24. <div className={'home-guide-item'} key={item.name}>
  25. <div className={'item-english'}>{item.name}</div>
  26. <div className={'item-title'}>{item.permission ? item.permission : item.value}</div>
  27. {typeof item.children === 'string' ? (
  28. <div className={`item-index`}>
  29. <img src={item.children || defaultImage} />
  30. </div>
  31. ) : (
  32. <div className={'item-index-echarts'}>{item.children}</div>
  33. )}
  34. </div>
  35. ))}
  36. </div>
  37. </div>
  38. );
  39. };
  40. export default Statistics;