import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import styles from './index.module.scss' import { baseURL, myData } from '@/utils/http' import classNames from 'classnames' import HotIcon from '@/components/HotIcon' import Hot2 from '@/pages/A2visit/PanoVideo/Hot2' import history from '@/utils/history' import ZHot0 from '@/components/ZHot0' type Props = { hidden: boolean } const dataTemp = myData.more['汉代百科'] const data1 = dataTemp['物'] function S2mien({ hidden }: Props) { const sroolDomRef = useRef(null) // 选中的索引 const [hotInd, setHotInd] = useState(-1) // 打开热点的索引 const [opnInd, setOpenInd] = useState(-1) // 从热点图标子组件点击 const clickSon = useCallback((index: number) => { const name = data1.hot[index].name // 打开热点 / 跳云起图页面 if (name === '四神云气图') history.push('/yun') else setOpenInd(index) // 移动端点击 高亮 setHotInd(index) }, []) useEffect(() => { if (hotInd === -1) return else { // 左侧滚动到中间 if (sroolDomRef.current) { // sroolDomRef.current.scrollTop = 40 * hotInd - 120 sroolDomRef.current.scrollTo({ top: 40 * hotInd - 120, behavior: 'smooth' }) } } }, [hotInd]) const hotName = useMemo(() => { let name = '' if (opnInd > -1 && data1.hot[opnInd]) name = data1.hot[opnInd].name return name }, [opnInd]) return ( ) } const MemoS2mien = React.memo(S2mien) export default MemoS2mien