index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { useCallback, useEffect, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { A3listType } from './type'
  4. const imgArrTemp = ['hotListX.png']
  5. const imgArr = imgArrTemp.map(item => require(`@/assets/img/${item}`))
  6. type Props = {
  7. show: boolean
  8. closeFu: () => void
  9. }
  10. function A3hotList({ show, closeFu }: Props) {
  11. const [list, setList] = useState<A3listType[]>([])
  12. useEffect(() => {
  13. if (show && list.length <= 0) setList(window.myHotList || [])
  14. }, [list.length, show])
  15. const openHot = useCallback((item: A3listType) => {
  16. setTimeout(() => {
  17. item && item.examine(window.player, true)
  18. }, 200)
  19. }, [])
  20. return (
  21. <div
  22. className={styles.A3hotList}
  23. style={{ opacity: show ? '1' : '0', pointerEvents: show ? 'auto' : 'none' }}
  24. >
  25. <img onClick={closeFu} className='A3close' src={imgArr[0]} alt='' />
  26. <div className='A3main'>
  27. {list.map((item, index) => (
  28. <div onClick={() => openHot(item)} key={index}>
  29. {item.info.title || '热点'}
  30. </div>
  31. ))}
  32. </div>
  33. </div>
  34. )
  35. }
  36. const MemoA3hotList = React.memo(A3hotList)
  37. export default MemoA3hotList