2025-10-22 15:43:18 +08:00
|
|
|
import React, { useEffect, useState, useRef } from 'react'
|
|
|
|
|
import { PlayCircleOutlined, PauseCircleOutlined } from '@ant-design/icons';
|
|
|
|
|
import {Slider} from 'antd';
|
|
|
|
|
import './index.less'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Page = ({ data, setClock }) => {
|
|
|
|
|
const [player,setPlayer] = useState(false)
|
|
|
|
|
const [index,setIndex] = useState(0)
|
|
|
|
|
const marks = {
|
|
|
|
|
[0]: {
|
|
|
|
|
style: { color: '#333' },
|
2025-10-27 17:55:38 +08:00
|
|
|
label: <span style={{width: "130px", fontSize: "12px", display:'inline-block', marginTop:'3px'}}>{data?.[0]?.tm2||''}</span>,
|
2025-10-22 15:43:18 +08:00
|
|
|
},
|
|
|
|
|
[data.length - 1]: {
|
|
|
|
|
style: { color: '#333' },
|
2025-10-27 17:55:38 +08:00
|
|
|
label: <div style={{width: "130px", fontSize: "12px", display:'inline-block', marginTop:'3px', marginLeft: "-32px"}}>{data?.[data?.length-1]?.tm2||""}</div>,
|
2025-10-22 15:43:18 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
setIndex(0)
|
|
|
|
|
setPlayer(false)
|
|
|
|
|
},[data])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (player) {
|
|
|
|
|
let num = index;
|
|
|
|
|
const h = setInterval(() => {
|
|
|
|
|
num = num + 1;
|
|
|
|
|
if (num >= data.length) {
|
|
|
|
|
num = 0;
|
|
|
|
|
}
|
|
|
|
|
setIndex(num);
|
|
|
|
|
}, 1100);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
clearInterval(h);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [player, index]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
if(index!==null){
|
|
|
|
|
setClock(index)
|
|
|
|
|
}
|
|
|
|
|
},[index])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{
|
|
|
|
|
data.length>0?
|
|
|
|
|
<div className='SliderPlayerBox'>
|
|
|
|
|
<div className='SliderPlayerBox_playbtn' onClick={()=>setPlayer(!player)}>
|
|
|
|
|
{ player?<PauseCircleOutlined style={{color: "#007AFF", fontSize: "25px"}}/>:<PlayCircleOutlined style={{color: "#007AFF", fontSize: "25px"}}/> }
|
|
|
|
|
</div>
|
|
|
|
|
<div className='SliderPlayerBox_slider'>
|
|
|
|
|
<Slider
|
|
|
|
|
disabled={player}
|
|
|
|
|
min={0}
|
|
|
|
|
max={data.length-1}
|
|
|
|
|
value={index}
|
|
|
|
|
marks={marks}
|
2025-10-22 15:51:08 +08:00
|
|
|
tooltip={{
|
|
|
|
|
open:true,
|
2025-10-27 17:55:38 +08:00
|
|
|
formatter:(value) => data[value].tm2
|
2025-10-22 15:51:08 +08:00
|
|
|
}}
|
2025-10-22 15:43:18 +08:00
|
|
|
onChange={(val) => setIndex(val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>:null
|
|
|
|
|
}
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Page
|