Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 支持列出和切换最近打开的文档 https://github.com/siyuan-note/siyuan/issues/3293

Liang Ding72419c907599
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 088860c16e..577e3d6289 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -659,6 +659,8 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size
luteEngine.RenderOptions.NodeIndexStart = index
dom = luteEngine.Tree2BlockDOM(subTree, luteEngine.RenderOptions)
+
+ SetRecentDocByTree(tree)
return
}
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index fe546775dc..5f05274670 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -17,6 +17,7 @@
package model
import (
+ "github.com/88250/lute/parse"
"os"
"path/filepath"
"sync"
@@ -62,6 +63,17 @@ func RemoveRecentDoc(ids []string) {
return
}
+func SetRecentDocByTree(tree *parse.Tree) {
+ recentDoc := &RecentDoc{
+ RootID: tree.Root.ID,
+ Icon: tree.Root.IALAttr("icon"),
+ Title: tree.Root.IALAttr("title"),
+ ScrollAttr: tree.Root.IALAttr("scroll"),
+ }
+
+ SetRecentDoc(recentDoc)
+}
+
func SetRecentDoc(doc *RecentDoc) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()