Enhance file transfer functionality by updating error handling in FileController and improving UI interactions in index.html and app.js. Added specific error messages for different transfer scenarios and refactored transfer functions for clarity and usability.

This commit is contained in:
liu
2026-02-03 11:18:14 +08:00
parent 96f78dea87
commit 7e288f7c90
4 changed files with 35 additions and 14 deletions

View File

@@ -354,7 +354,7 @@ function handleFileDrop(data, targetPanelId) {
const targetPath = panelState[targetPanelId].currentPath;
if (sourcePanelId === targetPanelId) {
updateStatus('同面板内移动功能开发中,请使用「传输到右侧」按钮');
updateStatus('同面板内移动功能开发中,请使用「传输到右侧」或「传输到左侧」按钮');
return;
}
@@ -1061,19 +1061,15 @@ function downloadFiles() {
});
}
// 传输到对面面板
function transferFiles() {
const sourcePanelId = getSourcePanelId();
const targetPanelId = sourcePanelId === 'left' ? 'right' : 'left';
// 按方向执行跨面板传输(源面板 -> 目标面板
function doTransfer(sourcePanelId, targetPanelId) {
const sourceSessionId = panelState[sourcePanelId].sessionId;
const targetSessionId = panelState[targetPanelId].sessionId;
const targetPath = panelState[targetPanelId].currentPath;
const selectedFiles = panelState[sourcePanelId].selectedFiles;
if (selectedFiles.length === 0) {
alert('请选择要传输的文件');
alert('请在' + (sourcePanelId === 'left' ? '左侧' : '右侧') + '面板选择要传输的文件');
return;
}
@@ -1089,7 +1085,7 @@ function transferFiles() {
showTransferCountProgress(0, total, '');
updateTransferProgress(0, '传输中 (0/' + total + ')');
selectedFiles.forEach(function(sourcePath, index) {
selectedFiles.forEach(function(sourcePath) {
$.ajax({
url: API_BASE + 'api/files/transfer',
method: 'POST',
@@ -1139,6 +1135,16 @@ function transferFiles() {
updateStatus('正在传输 ' + total + ' 个文件...');
}
// 传输到右侧:左侧面板选中的文件 -> 右侧面板
function transferToRight() {
doTransfer('left', 'right');
}
// 传输到左侧:右侧面板选中的文件 -> 左侧面板
function transferToLeft() {
doTransfer('right', 'left');
}
// ========== 文件删除功能模块06==========
// 工具栏删除:删除当前活动面板中选中的文件