瀏覽代碼

:art: https://github.com/siyuan-note/siyuan/issues/10671

Vanessa 1 年之前
父節點
當前提交
c8a6d9db0b
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      app/src/util/newFile.ts

+ 6 - 2
app/src/util/newFile.ts

@@ -164,13 +164,17 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
     fetchPost("/api/filetree/getRefCreateSavePath", {
     fetchPost("/api/filetree/getRefCreateSavePath", {
         notebook: notebookId
         notebook: notebookId
     }, (data) => {
     }, (data) => {
+        let targetPath = pathString;
+        if (notebookId !== data.data.box) {
+            targetPath = data.data.path || "/";
+        }
         if (data.data.path) {
         if (data.data.path) {
             if (data.data.path.startsWith("/")) {
             if (data.data.path.startsWith("/")) {
                 cb(getDisplayName(data.data.path, false, true));
                 cb(getDisplayName(data.data.path, false, true));
             } else {
             } else {
                 fetchPost("/api/filetree/getHPathByPath", {
                 fetchPost("/api/filetree/getHPathByPath", {
                     notebook: data.data.box,
                     notebook: data.data.box,
-                    path: pathString
+                    path: targetPath
                 }, (response) => {
                 }, (response) => {
                     cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true));
                     cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true));
                 });
                 });
@@ -178,7 +182,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
         } else {
         } else {
             fetchPost("/api/filetree/getHPathByPath", {
             fetchPost("/api/filetree/getHPathByPath", {
                 notebook: data.data.box,
                 notebook: data.data.box,
-                path: pathString
+                path: targetPath
             }, (response) => {
             }, (response) => {
                 cb(getDisplayName(response.data, false, true));
                 cb(getDisplayName(response.data, false, true));
             });
             });