import React, { FC, useEffect, useState } from 'react'; import styles from './index.less'; import { Input, Progress, message } from 'antd'; interface PageProps { open: boolean; onCancel: (name?: string) => void; setInstallExe: (index: number, text: string) => void; } const MSXML: FC = ({ open = false, onCancel, setInstallExe }) => { const [active, setActive] = useState(1); const [percentVal, setPercentVal] = useState(0); // 监听是否到安装进度条步骤 useEffect(() => { if (active == 6) { const interval = setInterval(() => { setPercentVal((val) => { const randomStep = Math.round(Math.random() * (100 / 10)); const newPercent = val + randomStep; if (newPercent >= 100) { clearInterval(interval); setValue() return 100; } return newPercent; }); }, 500); return () => clearInterval(interval); } }, [active]) // 设置安装步骤进度 const setValue = () => { setActive((e) => { return e + 1 }) } // 安装完成后 记录安装的信息 const installSuccess = () => { setInstallExe(3, 'MSXML安装成功!') onCancel() } return <> { open &&
{![6, 7].includes(active) &&
setValue()}>
} {active == 6 &&
} {active == 7 &&
installSuccess()}>
}
} }; export default MSXML;