From 49b89d7ea1f5caf4bd6bbbe3ba373e4dffdd451a Mon Sep 17 00:00:00 2001 From: cfq Date: Fri, 30 Jan 2026 16:04:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(FileTree):=20=E4=B8=BA=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D/=E6=96=B0=E5=BB=BA=E5=BC=B9=E7=AA=97=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=8A=A8=E8=81=9A=E7=84=A6=E5=92=8C=E5=9B=9E?= =?UTF-8?q?=E8=BD=A6=E7=A1=AE=E8=AE=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 ref 引用输入框并在弹窗显示时自动聚焦 - 为输入框添加 pressEnter 事件监听以支持回车确认 - 统一背景菜单中字符串的引号格式 --- src/components/FileTree.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/FileTree.vue b/src/components/FileTree.vue index b442025..5d61ca6 100644 --- a/src/components/FileTree.vue +++ b/src/components/FileTree.vue @@ -76,7 +76,7 @@ - + @@ -102,6 +102,15 @@ const currentNode = ref(null); const searchKeyword = ref(""); const selectedKeys = ref([]); const treeContentRef = ref(null); +const modalInputRef = ref(null); + +watch(modalVisible, (val) => { + if (val) { + nextTick(() => { + modalInputRef.value?.focus(); + }); + } +}); // 监听 activeTab 变化,实现联动 watch( @@ -374,7 +383,7 @@ const handleMenuClick = async ({ key }, node) => { }; const handleBackgroundMenuClick = ({ key }) => { - if (key === 'refresh') { + if (key === "refresh") { handleRefresh(); return; } @@ -383,11 +392,11 @@ const handleBackgroundMenuClick = ({ key }) => { const separator = window.utools.isWindows() ? "\\" : "/"; // 注意:如果是根驱动器(如 C:\),pop() 可能为空字符串,但 state.rootPath 是完整的 const rootName = state.rootPath.split(separator).pop() || state.rootPath; - + const rootNode = { name: rootName, path: state.rootPath, - type: "directory" + type: "directory", }; handleMenuClick({ key }, rootNode);