mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-20 23:36:10 +01:00
🎨 支持列出和切换最近打开的文档 https://github.com/siyuan-note/siyuan/issues/3293
This commit is contained in:
parent
ec8f27f5fe
commit
d679bedd77
1 changed files with 16 additions and 3 deletions
|
|
@ -17,14 +17,15 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/88250/lute/parse"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ func setRecentDocs(recentDocs []*RecentDoc) (err error) {
|
|||
}
|
||||
|
||||
func getRecentDocs() (ret []*RecentDoc, err error) {
|
||||
ret = []*RecentDoc{}
|
||||
tmp := []*RecentDoc{}
|
||||
dataPath := filepath.Join(util.DataDir, "storage/recent-doc.json")
|
||||
if !gulu.File.IsExist(dataPath) {
|
||||
return
|
||||
|
|
@ -139,10 +140,22 @@ func getRecentDocs() (ret []*RecentDoc, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &tmp); nil != err {
|
||||
logging.LogErrorf("unmarshal storage [recent-doc] failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
var notExists []string
|
||||
for _, doc := range tmp {
|
||||
if nil != treenode.GetBlockTree(doc.RootID) {
|
||||
ret = append(ret, doc)
|
||||
} else {
|
||||
notExists = append(notExists, doc.RootID)
|
||||
}
|
||||
}
|
||||
if 0 < len(notExists) {
|
||||
setRecentDocs(ret)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue