From 07d2134f8c4ec0233c9eeb515d227bcee55c2528 Mon Sep 17 00:00:00 2001 From: cfq Date: Fri, 30 Jan 2026 16:04:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(FileTree):=20=E6=96=B0=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=97=B6=E8=87=AA=E5=8A=A8=E6=B7=BB=E5=8A=A0.md?= =?UTF-8?q?=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当用户新建文件时,如果输入的文件名没有包含后缀,则自动为其添加.md后缀。这避免了用户因忘记输入后缀而导致文件类型不明确的问题,并保持与提示信息“默认.md后缀”的一致性。 --- src/components/FileTree.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/FileTree.vue b/src/components/FileTree.vue index bbc9fad..b442025 100644 --- a/src/components/FileTree.vue +++ b/src/components/FileTree.vue @@ -359,7 +359,7 @@ const handleMenuClick = async ({ key }, node) => { case "newFile": modalTitle.value = "新建文件"; modalInputValue.value = ""; - modalPlaceholder.value = "请输入文件名 (包含后缀)"; + modalPlaceholder.value = "请输入文件名 (默认.md后缀)"; currentAction.value = "newFile"; modalVisible.value = true; break; @@ -398,6 +398,9 @@ const handleModalOk = async () => { message.warning("请输入内容"); return; } + if (currentAction.value === "newFile" && !modalInputValue.value.endsWith(".md")) { + modalInputValue.value += ".md"; + } const node = currentNode.value; // 如果是新建,父目录是 node.path;如果是重命名,父目录是 node 的父级