fix(FileTree): 新建文件时自动添加.md后缀

当用户新建文件时,如果输入的文件名没有包含后缀,则自动为其添加.md后缀。这避免了用户因忘记输入后缀而导致文件类型不明确的问题,并保持与提示信息“默认.md后缀”的一致性。
This commit is contained in:
cfq 2026-01-30 16:04:22 +08:00
parent 7f6d445305
commit 07d2134f8c
1 changed files with 4 additions and 1 deletions

View File

@ -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