diff --git a/packages/frontend/src/components/FileManager.vue b/packages/frontend/src/components/FileManager.vue index 78faaa5..4620db0 100644 --- a/packages/frontend/src/components/FileManager.vue +++ b/packages/frontend/src/components/FileManager.vue @@ -129,6 +129,8 @@ const initialLoadDone = ref(false); const isFetchingInitialPath = ref(false); const isEditingPath = ref(false); const searchQuery = ref(''); // 新增:搜索查询 ref +const isSearchActive = ref(false); // 新增:控制搜索框激活状态 +const searchInputRef = ref(null); // 新增:搜索输入框 ref const pathInputRef = ref(null); const editablePath = ref(''); const contextMenuRef = ref(null); // <-- Add ref for context menu element @@ -717,6 +719,28 @@ const cancelPathEdit = () => { // clearSftpError(); // }; +// --- 搜索框激活/取消逻辑 --- +const activateSearch = () => { + isSearchActive.value = true; + nextTick(() => { + searchInputRef.value?.focus(); + }); +}; + +const deactivateSearch = () => { + // 延迟失活以允许点击内部元素(如果需要) + // setTimeout(() => { + // if (!searchInputRef.value?.contains(document.activeElement)) { // 检查焦点是否还在输入框内 + isSearchActive.value = false; + // } + // }, 100); // 100ms 延迟 +}; + +const cancelSearch = () => { + searchQuery.value = ''; // 按 Esc 清空并失活 + isSearchActive.value = false; +}; +