Refactor Docker setup and enhance file transfer progress handling. Updated Dockerfile for multi-stage builds, modified docker-compose.yml to include image and container name, and improved progress bar functionality in app.js for better user feedback during file transfers.

This commit is contained in:
liu
2026-02-03 11:35:29 +08:00
parent 7e288f7c90
commit caf0d97903
6 changed files with 71 additions and 16 deletions

View File

@@ -363,7 +363,7 @@ function handleFileDrop(data, targetPanelId) {
const fileName = getFileNameFromPath(sourcePath);
showTransferCountProgress(0, 1, fileName);
updateTransferProgress(0, '传输中 ' + fileName);
updateTransferProgress(0, '传输中 ' + fileName, true); // 拖拽跨面板传输,后端无流式进度
$.ajax({
url: API_BASE + 'api/files/transfer',
@@ -975,10 +975,18 @@ function showTransferProgress(show, label) {
}
// 更新传输进度条与标签
function updateTransferProgress(percent, label) {
// indeterminate: 当后端无流式进度时(如跨面板传输 API设为 true 显示动画进度条
function updateTransferProgress(percent, label, indeterminate) {
const progressBar = $('#transfer-progress-bar');
progressBar.css('width', percent + '%');
progressBar.text(percent + '%');
if (indeterminate) {
progressBar.css('width', '100%');
progressBar.text('');
progressBar.addClass('progress-bar-striped progress-bar-animated');
} else {
progressBar.removeClass('progress-bar-striped progress-bar-animated');
progressBar.css('width', percent + '%');
progressBar.text(percent + '%');
}
if (label !== undefined) {
$('#transfer-progress-label').text(label);
}
@@ -1083,7 +1091,7 @@ function doTransfer(sourcePanelId, targetPanelId) {
const total = selectedFiles.length;
showTransferCountProgress(0, total, '');
updateTransferProgress(0, '传输中 (0/' + total + ')');
updateTransferProgress(0, '传输中 (0/' + total + ')', true); // 后端无流式进度,使用动画条
selectedFiles.forEach(function(sourcePath) {
$.ajax({
@@ -1105,7 +1113,7 @@ function doTransfer(sourcePanelId, targetPanelId) {
}
const done = completed + failed;
showTransferCountProgress(done, total, getFileNameFromPath(sourcePath));
updateTransferProgress(total > 0 ? Math.round((done / total) * 100) : 0, '传输中 (' + done + '/' + total + ')');
updateTransferProgress(total > 0 ? Math.round((done / total) * 100) : 0, '传输中 (' + done + '/' + total + ')', false);
if (done === total) {
showTransferProgress(false);
if (failed === 0) {
@@ -1122,7 +1130,7 @@ function doTransfer(sourcePanelId, targetPanelId) {
alert('传输失败: ' + errMsg);
const done = completed + failed;
showTransferCountProgress(done, total, getFileNameFromPath(sourcePath));
updateTransferProgress(total > 0 ? Math.round((done / total) * 100) : 0, '传输中 (' + done + '/' + total + ')');
updateTransferProgress(total > 0 ? Math.round((done / total) * 100) : 0, '传输中 (' + done + '/' + total + ')', false);
if (done === total) {
showTransferProgress(false);
updateStatus('传输完成:成功 ' + completed + ',失败 ' + failed);