From e003fe65137c887448d55db9473ddd203a8c480c Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Wed, 18 Mar 2026 20:30:47 +0800 Subject: [PATCH] Revert "fix: hide docs in leaf directories from tree display" This reverts commit d95e6c11ecec2d4b119cc6b13aa60bda407c2642. --- src/components/ApiDocViewer.tsx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/components/ApiDocViewer.tsx b/src/components/ApiDocViewer.tsx index ec48f0e..5f30ad5 100644 --- a/src/components/ApiDocViewer.tsx +++ b/src/components/ApiDocViewer.tsx @@ -71,25 +71,13 @@ export const ApiDocViewer = ({ onDocsPathChange, showAddModal, onCloseAddModal } setExternalDocs(docs) - const dirs = new Set(docs.map(d => { - const parts = d.relativePath.split('/') - return parts.length >= 2 ? parts.slice(0, -1).join('/') : '' - })) - - const dirsWithSubdirs = new Set( - docs - .filter(d => d.relativePath.split('/').length >= 3) - .map(d => d.relativePath.split('/').slice(0, -1).join('/')) - ) - - const leafDirs = new Set([...dirs].filter(d => !dirsWithSubdirs.has(d))) - const fileList = docs .filter(doc => { const parts = doc.relativePath.split('/') if (parts.length < 2) return true - const parentDir = parts.slice(0, -1).join('/') - return !leafDirs.has(parentDir) + const filename = parts[parts.length - 1].replace(/\.md$/, '') + const parentFolder = parts[parts.length - 2] + return filename !== parentFolder }) .map(d => d.relativePath) const tree = buildFileTree(fileList, '/')