From d2d0a552df4d5a37230894ef4bdaecb49365a860 Mon Sep 17 00:00:00 2001 From: lan-yonghui Date: Wed, 19 Nov 2025 16:38:11 +0800 Subject: [PATCH] fix: Fix the issue of creating file/folder hierarchy errors --- .../host/file-management/code-editor/index.vue | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/host/file-management/code-editor/index.vue b/frontend/src/views/host/file-management/code-editor/index.vue index 2e868e564..8812d09b4 100644 --- a/frontend/src/views/host/file-management/code-editor/index.vue +++ b/frontend/src/views/host/file-management/code-editor/index.vue @@ -958,6 +958,9 @@ const getRefresh = (path: string) => { search(path).then((res) => { treeData.value = res.data[0].children; loadedNodes.value = new Set(); + isCreate.value = 'none'; + currentPath.value = path; + selectedParentNode.value = null; }); } finally { loading.value = false; @@ -1068,6 +1071,9 @@ const getUpData = async () => { const response = await search(newPath); treeData.value = response.data[0]?.children || []; loadedNodes.value = new Set(); + isCreate.value = 'none'; + currentPath.value = newPath; + selectedParentNode.value = null; } catch (error) { } finally { directoryPath.value = newPath; @@ -1102,17 +1108,17 @@ const handleNodeCollapse = (data: TreeNodeData, node: TreeNode) => { }; const handleNodeExpand = async (data: TreeNodeData, node: TreeNode) => { - if (node.data.isDir) { - currentPath.value = node.data.path; - selectedParentNode.value = node; - expandedNodeIds.value.add(node.data.id); - } if (node.data.id == 'new-dir' || node.data.id == 'new-file') { return; } if (!node.data.isDir || loadedNodes.value.has(node.data.path)) { return; } + if (node.data.isDir && isCreate.value == 'none') { + currentPath.value = node.data.path; + selectedParentNode.value = node; + expandedNodeIds.value.add(node.data.id); + } try { const response = await search(data.path); const newTreeData = JSON.parse(JSON.stringify(treeData.value)); @@ -1261,6 +1267,8 @@ onBeforeUnmount(() => { editor.dispose(); } isCreate.value = 'none'; + currentPath.value = ''; + selectedParentNode.value = null; window.removeEventListener('resize', updateHeights); });