fetch(url + 'get_progress/', {
method: 'GET'
}).then(response => {
if (response.ok) {
return response.json()
} else {
throw new Error('获取进度失败')
}
}).then(data => {
// 接收数据
let progress = data.data.progress
// 保留一位小数
progress = Math.round((progress * 10) / 10)
// 实时更新进度条
progressBar.style.width = (progress).toString() + '%'
progressPercent.innerText = (progress).toString() + '%'
// 当100%关闭定时器
if (progress == 100) {
convertComplete = true
progressBar.style.width = "100%"
progressPercent.innerText = "100%"
clearInterval(myInterval)
}
}).catch(error => {
console.error('错误:', error);
convertError.style.display = "inline"
clearInterval(myInterval)
})