This commit is contained in:
Vanessa 2024-07-09 10:47:19 +08:00
parent d0e64e4af1
commit a683464b75

View file

@ -8,7 +8,10 @@ import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/
import {fetchPost} from "../util/fetch";
import {Constants} from "../constants";
import {showTooltip} from "../dialog/tooltip";
/// #if !MOBILE
import {getAllEditor, getAllModels} from "../layout/getAll";
import {getCurrentEditor} from "../mobile/editor";
/// #endif
export const validateName = (name: string, targetElement?: HTMLElement) => {
if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
@ -135,6 +138,9 @@ export const renameAsset = (assetPath: string) => {
}
fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value}, (response) => {
/// #if MOBILE
getCurrentEditor()?.reload(false);
/// #else
getAllModels().asset.forEach(item => {
if (item.path === assetPath) {
item.path = response.data.newPath;
@ -144,6 +150,7 @@ export const renameAsset = (assetPath: string) => {
getAllEditor().forEach(item => {
item.reload(false);
});
/// #endif
dialog.destroy();
});
});