import React, { useState, useEffect, useRef } from "react"; import { connect } from "react-redux"; import moment from 'moment' import { Col, Row, } from "@douyinfe/semi-ui"; import { IconReply } from '@douyinfe/semi-icons'; import TextScroll from '../textScroll' import './videoPlay.less'; const timeFormat = 'YYYY-MM-DD HH:mm:ss' const VideoHeader = ({ operationState, changeSelectState, setProcessDisX, name, showTime, histroyTime,content }) => { const time = useRef(moment(showTime || undefined)) const upTimeInterval = useRef(null) const [showTime_, setShowTime] = useState(' ') const updateTime = () => { if (!showTime) { setShowTime('') clearInterval(upTimeInterval.current) return } time.current = moment(showTime || undefined) if (upTimeInterval.current) { clearInterval(upTimeInterval.current) } const upTime = () => { time.current.add(1, 's') if (operationState && operationState.histroy.select) { // setProcessDisX(Math.random() * 300 + 100) if (time.current.isSameOrAfter(histroyTime[1])) { clearInterval(upTimeInterval.current) } setProcessDisX( time.current.diff(moment(histroyTime[0]), 'seconds') / moment(histroyTime[1]).diff(moment(histroyTime[0]), 'seconds') * document.getElementById('process_point').parentElement.offsetWidth ) } setShowTime(time.current.format(timeFormat)) } upTime() upTimeInterval.current = setInterval(upTime, 1000) } useEffect(() => { updateTime() return () => { if (upTimeInterval.current) { clearInterval(upTimeInterval.current) } } }, []) useEffect(() => { updateTime() }, [showTime]) return (