GuideHome.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import './index.less';
  2. import { message } from 'antd';
  3. import useHistory from '@/hooks/route/useHistory';
  4. import Title from './Title';
  5. const Image = {
  6. 1: require('/public/images/home/home-1.png'),
  7. 2: require('/public/images/home/home-2.png'),
  8. 3: require('/public/images/home/home-3.png'),
  9. };
  10. interface GuideProps {
  11. title: string;
  12. data: GuideItemProps[];
  13. }
  14. interface GuideItemProps {
  15. key: string;
  16. name: string;
  17. english: string;
  18. url: string;
  19. param?: Record<string, any>;
  20. index?: number;
  21. auth: boolean;
  22. img?: string;
  23. }
  24. const GuideItem = (props: GuideItemProps) => {
  25. const history = useHistory();
  26. const jumpPage = () => {
  27. if (props.url && props.auth) {
  28. history.push(`${props.url}`, props.param);
  29. } else {
  30. message.warning('暂无权限,请联系管理员');
  31. }
  32. };
  33. return (
  34. <div
  35. className={'home-guide-item step-bar pointer'}
  36. onClick={jumpPage}
  37. style={{ marginTop: 12, padding: 10, border: '1px solid #eee' }}
  38. >
  39. <div style={{ display: 'flex', alignItems: 'center' }}>
  40. <div>
  41. <img src={props.img} />
  42. </div>
  43. <div>
  44. <div className={'item-english'}>{`STP${props.index}`}</div>
  45. <div
  46. className={'item-title'}
  47. style={{
  48. margin: 0,
  49. fontSize: '18px',
  50. }}
  51. >
  52. {props.name}
  53. </div>
  54. </div>
  55. </div>
  56. <div className={`item-index`} style={{ width: 37 }}>
  57. <img src={Image[props.index!]} />
  58. </div>
  59. </div>
  60. );
  61. };
  62. const GuideHome = (props: GuideProps) => {
  63. return (
  64. <div className={'home-guide'}>
  65. <Title title={props.title} />
  66. <div>
  67. {props.data.map((item, index) => (
  68. <GuideItem {...item} index={index + 1} key={item.key} />
  69. ))}
  70. </div>
  71. </div>
  72. );
  73. };
  74. export default GuideHome;