🎨 Improve recent documents handling 2 (#16908)

* https://ld246.com/article/1769260741412 空间换时间

* https://ld246.com/article/1769260741412 跳过不存在的文档
This commit is contained in:
Jeffrey Chen 2026-01-25 12:07:40 +08:00 committed by GitHub
parent c1a6206f7b
commit 09da39a676
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,11 +66,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
}
if len(deduplicated) <= maxCount {
// 清空 Title 和 Icon
for _, doc := range deduplicated {
doc.Title = ""
doc.Icon = ""
}
return deduplicated
}
@ -129,9 +124,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
result := make([]*RecentDoc, 0, len(docMap))
for _, doc := range docMap {
// 清空 Title 和 Icon
doc.Title = ""
doc.Icon = ""
result = append(result, doc)
}
@ -386,6 +378,11 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
bts := treenode.GetBlockTrees(rootIDs)
for _, sqlBlock := range sqlBlocks {
bt := bts[sqlBlock.ID]
if nil == bt {
continue
}
// 解析 IAL 获取 icon
icon := ""
if sqlBlock.IAL != "" {
@ -400,19 +397,7 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
}
}
// 获取文档标题
title := ""
if bt := bts[sqlBlock.ID]; nil != bt {
title = path.Base(bt.HPath)
}
if title == "" {
title = sqlBlock.Content
if title == "" {
title = sqlBlock.HPath
if title == "" {
title = sqlBlock.ID
}
}
}
title := path.Base(bt.HPath)
doc := &RecentDoc{
RootID: sqlBlock.ID,
Icon: icon,