From 89cc358121d9650bb23a041e9af3154fa35d0539 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Tue, 15 Apr 2025 23:28:09 +0800 Subject: [PATCH] update --- packages/frontend/src/components/FileManager.vue | 12 +++++++----- packages/frontend/src/composables/useSftpActions.ts | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/FileManager.vue b/packages/frontend/src/components/FileManager.vue index 13b832d..3d0b3bf 100644 --- a/packages/frontend/src/components/FileManager.vue +++ b/packages/frontend/src/components/FileManager.vue @@ -44,7 +44,8 @@ const props = defineProps({ // --- 核心 Composables --- const { t } = useI18n(); const route = useRoute(); // Keep for download URL generation for now -const currentPath = ref('.'); // Current path state remains local, passed to manager if needed +// 移除本地 currentPath ref +// const currentPath = ref('.'); // Access SFTP state and methods from the injected manager instance const { @@ -60,6 +61,7 @@ const { readFile, // Provided by the manager writeFile, // Provided by the manager joinPath, + currentPath, // 从 sftpManager 获取 currentPath clearSftpError, cleanup: cleanupSftpHandlers, // Get the cleanup function from the manager } = props.sftpManager; // 直接从 props 获取 @@ -71,7 +73,7 @@ const { cancelUpload, // cleanup: cleanupUploader, // 假设 uploader 也提供 cleanup } = useFileUploader( - currentPath, + currentPath, // 使用从 sftpManager 获取的 currentPath fileList, // 传递来自 sftpManager 的 fileList ref () => loadDirectory(currentPath.value), // Refresh function uses manager's loadDirectory props.sessionId, // 传递 sessionId @@ -287,7 +289,7 @@ const handleItemClick = (event: MouseEvent, item: FileListItem) => { // item 已 return; } 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 loadDirectory(newPath); // Use loadDirectory from props } else if (item.attrs.isFile) { @@ -622,7 +624,7 @@ const stopResize = () => { const startPathEdit = () => { // 恢复使用 props.sftpManager.isLoading 和 props.wsDeps.isConnected if (isLoading.value || !props.wsDeps.isConnected.value) return; - editablePath.value = currentPath.value; + editablePath.value = currentPath.value; // 使用 sftpManager 的 currentPath 初始化编辑框 isEditingPath.value = true; nextTick(() => { pathInputRef.value?.focus(); @@ -636,7 +638,7 @@ const handlePathInput = async (event?: Event) => { } const newPath = editablePath.value.trim(); isEditingPath.value = false; - if (newPath === currentPath.value || !newPath) { + if (newPath === currentPath.value || !newPath) { // 与 sftpManager 的 currentPath 比较 return; } console.log(`[FileManager ${props.sessionId}] 尝试导航到新路径: ${newPath}`); diff --git a/packages/frontend/src/composables/useSftpActions.ts b/packages/frontend/src/composables/useSftpActions.ts index 7c41106..8792bf4 100644 --- a/packages/frontend/src/composables/useSftpActions.ts +++ b/packages/frontend/src/composables/useSftpActions.ts @@ -323,6 +323,10 @@ export function createSftpActionsManager( joinPath, // 暴露辅助函数 clearSftpError, + // Cleanup function + currentPath: readonly(currentPathRef), // 暴露只读的当前路径 ref + + // Cleanup function // Cleanup function cleanup, };