This commit is contained in:
Baobhan Sith
2025-04-15 23:28:09 +08:00
parent 1f0200b82a
commit 89cc358121
2 changed files with 11 additions and 5 deletions
@@ -44,7 +44,8 @@ const props = defineProps({
// --- 核心 Composables --- // --- 核心 Composables ---
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); // Keep for download URL generation for now const route = useRoute(); // Keep for download URL generation for now
const currentPath = ref<string>('.'); // Current path state remains local, passed to manager if needed // 移除本地 currentPath ref
// const currentPath = ref<string>('.');
// Access SFTP state and methods from the injected manager instance // Access SFTP state and methods from the injected manager instance
const { const {
@@ -60,6 +61,7 @@ const {
readFile, // Provided by the manager readFile, // Provided by the manager
writeFile, // Provided by the manager writeFile, // Provided by the manager
joinPath, joinPath,
currentPath, // 从 sftpManager 获取 currentPath
clearSftpError, clearSftpError,
cleanup: cleanupSftpHandlers, // Get the cleanup function from the manager cleanup: cleanupSftpHandlers, // Get the cleanup function from the manager
} = props.sftpManager; // 直接从 props 获取 } = props.sftpManager; // 直接从 props 获取
@@ -71,7 +73,7 @@ const {
cancelUpload, cancelUpload,
// cleanup: cleanupUploader, // 假设 uploader 也提供 cleanup // cleanup: cleanupUploader, // 假设 uploader 也提供 cleanup
} = useFileUploader( } = useFileUploader(
currentPath, currentPath, // 使用从 sftpManager 获取的 currentPath
fileList, // 传递来自 sftpManager 的 fileList ref fileList, // 传递来自 sftpManager 的 fileList ref
() => loadDirectory(currentPath.value), // Refresh function uses manager's loadDirectory () => loadDirectory(currentPath.value), // Refresh function uses manager's loadDirectory
props.sessionId, // 传递 sessionId props.sessionId, // 传递 sessionId
@@ -287,7 +289,7 @@ const handleItemClick = (event: MouseEvent, item: FileListItem) => { // item 已
return; return;
} }
const newPath = item.filename === '..' const newPath = item.filename === '..'
? currentPath.value.substring(0, currentPath.value.lastIndexOf('/')) || '/' ? currentPath.value.substring(0, currentPath.value.lastIndexOf('/')) || '/' // 使用 sftpManager 的 currentPath
: joinPath(currentPath.value, item.filename); // Use joinPath from props : joinPath(currentPath.value, item.filename); // Use joinPath from props
loadDirectory(newPath); // Use loadDirectory from props loadDirectory(newPath); // Use loadDirectory from props
} else if (item.attrs.isFile) { } else if (item.attrs.isFile) {
@@ -622,7 +624,7 @@ const stopResize = () => {
const startPathEdit = () => { const startPathEdit = () => {
// 恢复使用 props.sftpManager.isLoading 和 props.wsDeps.isConnected // 恢复使用 props.sftpManager.isLoading 和 props.wsDeps.isConnected
if (isLoading.value || !props.wsDeps.isConnected.value) return; if (isLoading.value || !props.wsDeps.isConnected.value) return;
editablePath.value = currentPath.value; editablePath.value = currentPath.value; // 使用 sftpManager 的 currentPath 初始化编辑框
isEditingPath.value = true; isEditingPath.value = true;
nextTick(() => { nextTick(() => {
pathInputRef.value?.focus(); pathInputRef.value?.focus();
@@ -636,7 +638,7 @@ const handlePathInput = async (event?: Event) => {
} }
const newPath = editablePath.value.trim(); const newPath = editablePath.value.trim();
isEditingPath.value = false; isEditingPath.value = false;
if (newPath === currentPath.value || !newPath) { if (newPath === currentPath.value || !newPath) { // 与 sftpManager 的 currentPath 比较
return; return;
} }
console.log(`[FileManager ${props.sessionId}] 尝试导航到新路径: ${newPath}`); console.log(`[FileManager ${props.sessionId}] 尝试导航到新路径: ${newPath}`);
@@ -323,6 +323,10 @@ export function createSftpActionsManager(
joinPath, // 暴露辅助函数 joinPath, // 暴露辅助函数
clearSftpError, clearSftpError,
// Cleanup function
currentPath: readonly(currentPathRef), // 暴露只读的当前路径 ref
// Cleanup function
// Cleanup function // Cleanup function
cleanup, cleanup,
}; };