mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 04:18:48 +01:00
🎨 支持列出和切换最近打开的文档 https://github.com/siyuan-note/siyuan/issues/3293
This commit is contained in:
parent
7b2f1a0efc
commit
ae4272eafb
2 changed files with 25 additions and 0 deletions
|
|
@ -1247,6 +1247,7 @@ func removeDoc(box *Box, p string) (err error) {
|
|||
|
||||
treenode.RemoveBlockTreesByPathPrefix(childrenDir)
|
||||
sql.RemoveTreePathQueue(box.ID, childrenDir)
|
||||
RemoveRecentDoc(removeIDs)
|
||||
|
||||
if "/" != dir {
|
||||
others, err := os.ReadDir(filepath.Join(util.DataDir, box.ID, dir))
|
||||
|
|
|
|||
|
|
@ -38,6 +38,30 @@ type RecentDoc struct {
|
|||
|
||||
var recentDocLock = sync.Mutex{}
|
||||
|
||||
func RemoveRecentDoc(ids []string) {
|
||||
recentDocLock.Lock()
|
||||
defer recentDocLock.Unlock()
|
||||
|
||||
recentDocs, err := getRecentDocs()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
ids = gulu.Str.RemoveDuplicatedElem(ids)
|
||||
for i, doc := range recentDocs {
|
||||
if gulu.Str.Contains(doc.RootID, ids) {
|
||||
recentDocs = append(recentDocs[:i], recentDocs[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = setRecentDocs(recentDocs)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetRecentDoc(doc *RecentDoc) (err error) {
|
||||
recentDocLock.Lock()
|
||||
defer recentDocLock.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue