|
@@ -94,7 +94,7 @@ export const newFile = (optios: {
|
|
if (data.data.path.startsWith("/") || optios.currentPath === "/") {
|
|
if (data.data.path.startsWith("/") || optios.currentPath === "/") {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
notebook: optios.notebookId,
|
|
notebook: optios.notebookId,
|
|
- path: pathPosix().join(data.data.path, optios.name || ""),
|
|
|
|
|
|
+ path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? "Untitled" : "")),
|
|
// 根目录时无法确定 parentID
|
|
// 根目录时无法确定 parentID
|
|
markdown: ""
|
|
markdown: ""
|
|
}, response => {
|
|
}, response => {
|
|
@@ -115,7 +115,7 @@ export const newFile = (optios: {
|
|
}, (responseHPath) => {
|
|
}, (responseHPath) => {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
notebook: optios.notebookId,
|
|
notebook: optios.notebookId,
|
|
- path: pathPosix().join(responseHPath.data, data.data.path, optios.name || ""),
|
|
|
|
|
|
+ path: pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? "Untitled" : "")),
|
|
parentID: getDisplayName(optios.currentPath, true, true),
|
|
parentID: getDisplayName(optios.currentPath, true, true),
|
|
markdown: ""
|
|
markdown: ""
|
|
}, response => {
|
|
}, response => {
|
|
@@ -132,8 +132,7 @@ export const newFile = (optios: {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- let title = data.data.path || "Untitled";
|
|
|
|
- title = title.substring(title.lastIndexOf("/") + 1);
|
|
|
|
|
|
+ const title = pathPosix().basename(data.data.path || "Untitled");
|
|
if (!validateName(title)) {
|
|
if (!validateName(title)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|