box.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Popover, Space } from 'antd'
  2. import React, { useMemo } from 'react'
  3. function Box(props: { b: any }) {
  4. const { b } = props
  5. let el = useMemo(() => {
  6. if (b?.imagePreviewUrl?.length > 0 || b?.videoKeyFrameImageUrl) {//图片存在? 或者视频首针图存在?
  7. return <div className='imagesConfig'>
  8. <Popover placement='right' content={
  9. <div>
  10. {b?.title && <div style={{ maxWidth: 300 }}><strong style={{ fontSize: 15 }}>标题:</strong>{b?.title}</div>}
  11. <Space style={{ maxWidth: 300, display: 'flex', flexFlow: 'row wrap',margin:'10px 0' }}>
  12. {
  13. b?.imagePreviewUrl?.length > 0 ? b?.imagePreviewUrl?.map((img: string | undefined) => {
  14. return <img src={img} key={img} width={b?.imagePreviewUrl?.length === 1 ? 200 : b?.imagePreviewUrl?.length === 3 ? 70 : b?.imagePreviewUrl?.length === 4 ? 100 : 70} />
  15. }) : <img src={b?.videoKeyFrameImageUrl} width={200} />
  16. }
  17. </Space>
  18. {b?.description && <small style={{ fontSize: 10, maxWidth: 300, display: 'inline-block' }}><strong style={{ fontSize: 13 }}>描述:</strong>{b?.description}</small>}
  19. </div>
  20. }>
  21. <img src={b?.imagePreviewUrl ? b?.imagePreviewUrl[0] : b?.videoKeyFrameImageUrl} width={24} />
  22. </Popover>
  23. </div>
  24. } else if (b?.videoPreviewUrl) {//视频存在?
  25. return <Popover placement='right' content={
  26. <div>
  27. {b?.title && <div style={{ maxWidth: 300 }}><strong style={{ fontSize: 15 }}>标题:</strong>{b?.title}</div>}
  28. <video src='https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/b946235d4e4f078cdfe5099736e1dbc8_preview.mp4' style={{ maxWidth: 300 }} controls />
  29. {b?.description && <small style={{ fontSize: 10, maxWidth: 300, display: 'inline-block' }}><strong style={{ fontSize: 13 }}>描述:</strong>{b?.description}</small>}
  30. </div>
  31. }>
  32. <video src='https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/b946235d4e4f078cdfe5099736e1dbc8_preview.mp4' style={{ width: 24 }} />
  33. </Popover>
  34. } else {
  35. return <Popover placement='right' content={
  36. <div>
  37. {b?.title && <div style={{ maxWidth: 300 }}><strong style={{ fontSize: 15 }}>标题:</strong>{b?.title}</div>}
  38. {b?.description && <small style={{ fontSize: 10, maxWidth: 300, display: 'inline-block' }}><strong style={{ fontSize: 13 }}>描述:</strong>{b?.description}</small>}
  39. </div>
  40. }>
  41. <div style={{width:'100%',height:'100%'}}>
  42. --
  43. </div>
  44. </Popover>
  45. }
  46. }, [b])
  47. return el
  48. }
  49. export default React.memo(Box)