diff --git a/packages/frontend/src/components/FileManager.vue b/packages/frontend/src/components/FileManager.vue index 74baa84..c251e7b 100644 --- a/packages/frontend/src/components/FileManager.vue +++ b/packages/frontend/src/components/FileManager.vue @@ -49,10 +49,11 @@ const route = useRoute(); // Keep for download URL generation for now // const currentPath = ref('.'); // Access SFTP state and methods from the injected manager instance +// Note: 'error' and 'clearSftpError' are handled by the UI notification store via useSftpActions const { fileList, isLoading, - error, + // error, // Removed, handled by UI notification store loadDirectory, createDirectory, createFile, @@ -63,7 +64,7 @@ const { writeFile, // Provided by the manager joinPath, currentPath, // 从 sftpManager 获取 currentPath - clearSftpError, + // clearSftpError, // Removed, handled by UI notification store cleanup: cleanupSftpHandlers, // Get the cleanup function from the manager } = props.sftpManager; // 直接从 props 获取 @@ -77,9 +78,9 @@ const { currentPath, // 使用从 sftpManager 获取的 currentPath fileList, // 传递来自 sftpManager 的 fileList ref () => loadDirectory(currentPath.value), // Refresh function uses manager's loadDirectory - props.sessionId, // 传递 sessionId - props.dbConnectionId // 传递 dbConnectionId - // useFileUploader 内部创建自己的 ws 连接, 不需要 wsDeps + // props.sessionId, // 不再传递 sessionId + // props.dbConnectionId // 不再传递 dbConnectionId + props.wsDeps // 传递注入的 WebSocket 依赖项 ); // 实例化新的文件编辑器 Store @@ -628,6 +629,7 @@ const stopResize = () => { // --- 路径编辑逻辑 --- const startPathEdit = () => { // 恢复使用 props.sftpManager.isLoading 和 props.wsDeps.isConnected + // 注意:这里仍然使用从 sftpManager 解构的 isLoading if (isLoading.value || !props.wsDeps.isConnected.value) return; editablePath.value = currentPath.value; // 使用 sftpManager 的 currentPath 初始化编辑框 isEditingPath.value = true; @@ -655,10 +657,10 @@ const cancelPathEdit = () => { isEditingPath.value = false; }; -// 清除错误消息的函数 - 调用 props 中的 clearSftpError -const clearError = () => { - clearSftpError(); -}; +// 清除错误消息的函数 - 不再需要,错误由 UI 通知处理 +// const clearError = () => { +// clearSftpError(); +// }; @@ -705,17 +707,17 @@ const clearError = () => { @dragleave.prevent="handleDragLeave" @drop.prevent="handleDrop" > - - + - -
{{ t('fileManager.loading') }}
+ +
{{ t('fileManager.loading') }}
- - - - - + + diff --git a/packages/frontend/src/composables/useFileUploader.ts b/packages/frontend/src/composables/useFileUploader.ts index 535d09d..5d603b2 100644 --- a/packages/frontend/src/composables/useFileUploader.ts +++ b/packages/frontend/src/composables/useFileUploader.ts @@ -7,6 +7,8 @@ import type { WebSocketMessage, MessagePayload } from '../types/websocket.types' // --- 接口定义 (已移至 upload.types.ts) --- +import type { WebSocketDependencies } from './useSftpActions'; // 导入 WebSocketDependencies 类型 + // 辅助函数 (从 FileManager.vue 复制) const generateUploadId = (): string => { // 如果需要,可以使用稍微不同的格式作为上传 ID @@ -24,12 +26,14 @@ export function useFileUploader( currentPathRef: Ref, fileListRef: Readonly>, // 使用 Readonly 类型 refreshDirectory: () => void, // 上传成功后刷新目录的回调函数 - sessionId: string, - dbConnectionId: string + // sessionId: string, // 不再需要,因为 wsDeps 包含了会话上下文 + // dbConnectionId: string, // 不再需要 + wsDeps: WebSocketDependencies // 注入 WebSocket 依赖项 ) { const { t } = useI18n(); - // 使用工厂函数创建WebSocket连接管理器,并传入t函数 - const { sendMessage, onMessage, isConnected } = createWebSocketConnectionManager(sessionId, dbConnectionId, t); + // 不再创建独立的连接管理器,而是使用注入的依赖项 + // const { sendMessage, onMessage, isConnected } = createWebSocketConnectionManager(sessionId, dbConnectionId, t); + const { sendMessage, onMessage, isConnected } = wsDeps; // 使用注入的依赖项 // 对 uploads 字典使用 reactive 以获得更好的深度响应性 const uploads = reactive>({});