diff --git a/static/app.js b/static/app.js
index 09abe4f..9299640 100644
--- a/static/app.js
+++ b/static/app.js
@@ -137,7 +137,7 @@
id: file._dzFileId,
fileName: file.name,
totalSize: file.size,
- progress: file._uploadProgress || 0,
+ progress: isNaN(file._uploadProgress) ? 0 : Math.max(0, Math.min(100, file._uploadProgress || 0)),
status: 'uploading',
chunks: null,
startTime: Date.now()
@@ -155,7 +155,8 @@
updateProgress(fileId, progress, chunkInfo) {
const task = this.activeUploads.get(fileId);
if (task) {
- task.progress = progress;
+ // 确保progress是有效的数值
+ task.progress = isNaN(progress) ? 0 : Math.max(0, Math.min(100, progress));
task.chunks = chunkInfo;
this.notifyUIUpdate();
}
@@ -240,16 +241,19 @@
const statusIcon = task.status === 'completed' ? '✓' :
task.status === 'failed' ? '✗' : '⏳';
+ // 确保progress是有效的数值
+ const safeProgress = isNaN(task.progress) ? 0 : Math.max(0, Math.min(100, task.progress));
+
item.innerHTML = `
${getFileIcon(task.fileName)}
${escapeHtml(task.fileName)}
- ${Math.round(task.progress)}%
+ ${Math.round(safeProgress)}%
${task.chunks ? `(${task.chunks})` : ''}
@@ -568,6 +572,7 @@
this.on('uploadprogress', function(file, progress, bytesSent, totalBytesSent, totalBytes) {
var fileId = file._dzFileId;
+ var totalProgress = progress; // 默认值
// 更新悬浮窗中的进度
var progressEl = document.getElementById('progress-' + fileId);
@@ -577,7 +582,7 @@
if (file.totalChunks > 1) {
var currentChunk = file.upload.chunk || 0;
var chunkWeight = 100 / file.totalChunks;
- var totalProgress = (currentChunk * chunkWeight) + (progress * chunkWeight / 100);
+ totalProgress = (currentChunk * chunkWeight) + (progress * chunkWeight / 100);
if (progressEl) {
progressEl.style.width = Math.min(totalProgress, 100) + '%';
@@ -589,6 +594,7 @@
chunksEl.textContent = (currentChunk + 1) + '/' + file.totalChunks;
}
} else {
+ totalProgress = progress;
if (progressEl) {
progressEl.style.width = progress + '%';
}