fix: filter same-name docs from tree display, keep in externalDocs for folder click

This commit is contained in:
2026-03-18 20:24:45 +08:00
parent 86f84d4349
commit 66c3f8596d

View File

@@ -71,7 +71,15 @@ export const ApiDocViewer = ({ onDocsPathChange, showAddModal, onCloseAddModal }
setExternalDocs(docs) setExternalDocs(docs)
const fileList = docs.map(d => d.relativePath) const fileList = docs
.filter(doc => {
const parts = doc.relativePath.split('/')
if (parts.length < 2) return true
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, '/') const tree = buildFileTree(fileList, '/')
setFileTree(tree) setFileTree(tree)