Kaynağa Gözat

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

Vanessa 1 yıl önce
ebeveyn
işleme
414f57a7e1
1 değiştirilmiş dosya ile 12 ekleme ve 1 silme
  1. 12 1
      app/src/editor/rename.ts

+ 12 - 1
app/src/editor/rename.ts

@@ -8,6 +8,7 @@ import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/
 import {fetchPost} from "../util/fetch";
 import {Constants} from "../constants";
 import {showTooltip} from "../dialog/tooltip";
+import {getAllEditor, getAllModels} from "../layout/getAll";
 
 export const validateName = (name: string, targetElement?: HTMLElement) => {
     if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
@@ -132,7 +133,17 @@ export const renameAsset = (assetPath: string) => {
             dialog.destroy();
             return false;
         }
-        fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value});
+
+        fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value}, (response) => {
+            getAllModels().asset.forEach(item => {
+                if (item.path === assetPath) {
+                    item.parent.updateTitle(getDisplayName(response.data.newPath));
+                }
+            })
+            getAllEditor().forEach(item => {
+                item.reload(false);
+            })
+        });
     });
 };