update
This commit is contained in:
@@ -315,6 +315,13 @@ const handleItemClick = (event: MouseEvent, item: FileListItem, forceMultiSelect
|
|||||||
originalHandleItemClick(event, item);
|
originalHandleItemClick(event, item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// +++ 计算属性:获取选中的完整文件对象列表 +++
|
||||||
|
const computedSelectedFullItems = computed((): FileListItem[] => {
|
||||||
|
if (!selectedItems.value || selectedItems.value.size === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return filteredFileList.value.filter(item => selectedItems.value.has(item.filename));
|
||||||
|
});
|
||||||
|
|
||||||
// --- 操作模态框辅助函数 ---
|
// --- 操作模态框辅助函数 ---
|
||||||
const openActionModal = (
|
const openActionModal = (
|
||||||
@@ -1619,6 +1626,7 @@ const handleOpenEditorClick = () => {
|
|||||||
:position="contextMenuPosition"
|
:position="contextMenuPosition"
|
||||||
:items="contextMenuItems"
|
:items="contextMenuItems"
|
||||||
:active-context-item="contextTargetItem"
|
:active-context-item="contextTargetItem"
|
||||||
|
:selected-file-items="computedSelectedFullItems"
|
||||||
:current-directory-path="currentSftpManager?.currentPath?.value ?? '/'"
|
:current-directory-path="currentSftpManager?.currentPath?.value ?? '/'"
|
||||||
@close-request="hideContextMenu"
|
@close-request="hideContextMenu"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ const props = defineProps({
|
|||||||
type: Object as PropType<FileListItem | null>,
|
type: Object as PropType<FileListItem | null>,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
selectedFileItems: { // Items currently selected in the file manager
|
||||||
|
type: Array as PropType<FileListItem[]>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
currentDirectoryPath: { // Current path of the file manager
|
currentDirectoryPath: { // Current path of the file manager
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -118,33 +122,46 @@ const handleItemClick = (item: ContextMenuItem) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSendToClick = () => {
|
const handleSendToClick = () => {
|
||||||
if (props.activeContextItem) {
|
const itemsToSend: { name: string; path: string; type: 'file' | 'directory' }[] = [];
|
||||||
|
|
||||||
|
// 优先使用多选的项目
|
||||||
|
if (props.selectedFileItems && props.selectedFileItems.length > 0) {
|
||||||
|
props.selectedFileItems.forEach(item => {
|
||||||
|
const type = item.attrs.isDirectory ? 'directory' : 'file';
|
||||||
|
let fullPath = props.currentDirectoryPath;
|
||||||
|
if (!fullPath.endsWith('/')) {
|
||||||
|
fullPath += '/';
|
||||||
|
}
|
||||||
|
fullPath += item.filename;
|
||||||
|
fullPath = fullPath.replace(/(?<!:)\/\//g, '/'); // Normalize path
|
||||||
|
|
||||||
|
itemsToSend.push({
|
||||||
|
name: item.filename,
|
||||||
|
path: fullPath,
|
||||||
|
type: type,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (props.activeContextItem) { // 如果没有多选项目,则使用右键点击的单个项目
|
||||||
const item = props.activeContextItem;
|
const item = props.activeContextItem;
|
||||||
const type = item.attrs.isDirectory ? 'directory' : 'file';
|
const type = item.attrs.isDirectory ? 'directory' : 'file';
|
||||||
// Ensure path is constructed correctly, assuming currentDirectoryPath ends with / or is root '/'
|
|
||||||
// And filename does not start with /
|
|
||||||
let fullPath = props.currentDirectoryPath;
|
let fullPath = props.currentDirectoryPath;
|
||||||
if (!fullPath.endsWith('/')) {
|
if (!fullPath.endsWith('/')) {
|
||||||
fullPath += '/';
|
fullPath += '/';
|
||||||
}
|
}
|
||||||
fullPath += item.filename;
|
fullPath += item.filename;
|
||||||
|
fullPath = fullPath.replace(/(?<!:)\/\//g, '/'); // Normalize path
|
||||||
|
|
||||||
// Normalize path to remove any double slashes, except for protocol like sftp://
|
itemsToSend.push({
|
||||||
fullPath = fullPath.replace(/(?<!:)\/\//g, '/');
|
|
||||||
|
|
||||||
|
|
||||||
itemsToSendData.value = [{
|
|
||||||
name: item.filename,
|
name: item.filename,
|
||||||
path: fullPath,
|
path: fullPath,
|
||||||
type: type,
|
type: type,
|
||||||
}];
|
});
|
||||||
} else {
|
|
||||||
// No specific item clicked, perhaps send selected items? Or disable "Send To"?
|
|
||||||
// For now, sending an empty array if no activeContextItem.
|
|
||||||
// This scenario should ideally be handled by disabling the "Send to..." option
|
|
||||||
// if no item is targeted or no selection is made that can be sent.
|
|
||||||
itemsToSendData.value = [];
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// 如果两者都为空,itemsToSend 将保持为空数组
|
||||||
|
// }
|
||||||
|
|
||||||
|
itemsToSendData.value = itemsToSend;
|
||||||
showSendFilesModal.value = true;
|
showSendFilesModal.value = true;
|
||||||
emit('close-request');
|
emit('close-request');
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user