import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import ButtonComp from '@/components/ButtonComp'; import { useEffect, useRef, useState } from 'react'; import { getGlqInfo } from '@/services/gql'; import ClearInfoDialog from '@/components/ClearInfoDialog'; import SaveAs from '@/components/SaveAs'; // 网络GQL管理 --> 获取服务列表 export default function Page() { const [lines, setLines] = useState([]); const [currentLineIndex, setCurrentLineIndex] = useState(0); const [visibility, setVisibility] = useState(false); const outputRef: any = useRef(null); useEffect(() => { const timer = setInterval(() => { if (currentLineIndex < lines.length) { setCurrentLineIndex((prevIndex) => prevIndex + 1); } else { clearInterval(timer); } }, 300); if (outputRef.current.scrollHeight > 330) { outputRef.current.scrollTop = outputRef.current.scrollHeight; } return () => { clearInterval(timer); // 组件卸载时清除定时器 }; }, [currentLineIndex, lines.length]); const statusQuery = () => { getGlqInfo({type: 1}).then((res) => { if (res?.result == "success") { setLines([ ...lines, '发送命令成功', `获取服务列表`, `正在获取服务列表中...`, `获取服务列表完成` ]) } else { setLines([`${res?.errorMsg}`]) } }) } return (
获取被控端服务列表情况
{lines.slice(0, currentLineIndex).map((line: string, index: number) => (

{line}

))}
{ statusQuery() }} /> setVisibility(true)} />
setVisibility(false)} onOk={() => { setLines([]); setCurrentLineIndex(0); setVisibility(false); }}>
确定清空信息吗?
); }