fix(FileTree): 新建文件时自动添加.md后缀
当用户新建文件时,如果输入的文件名没有包含后缀,则自动为其添加.md后缀。这避免了用户因忘记输入后缀而导致文件类型不明确的问题,并保持与提示信息“默认.md后缀”的一致性。
This commit is contained in:
parent
7f6d445305
commit
07d2134f8c
|
|
@ -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 的父级
|
||||
|
|
|
|||
Loading…
Reference in New Issue