Pārlūkot izejas kodu

:bug: 包含较大列表的文档加载不全 https://github.com/siyuan-note/siyuan/issues/5798

Liang Ding 2 gadi atpakaļ
vecāks
revīzija
39b4587eb5
2 mainītis faili ar 15 papildinājumiem un 13 dzēšanām
  1. 13 12
      kernel/api/filetree.go
  2. 2 1
      kernel/model/file.go

+ 13 - 12
kernel/api/filetree.go

@@ -634,7 +634,7 @@ func getDoc(c *gin.Context) {
 		size = 36
 	}
 
-	blockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, err := model.GetDoc(startID, endID, id, index, keyword, mode, size)
+	blockCount, childBlockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, err := model.GetDoc(startID, endID, id, index, keyword, mode, size)
 	if errors.Is(err, filelock.ErrUnableLockFile) {
 		ret.Code = 2
 		ret.Data = id
@@ -652,17 +652,18 @@ func getDoc(c *gin.Context) {
 	}
 
 	ret.Data = map[string]interface{}{
-		"id":         id,
-		"mode":       mode,
-		"parentID":   parentID,
-		"parent2ID":  parent2ID,
-		"rootID":     rootID,
-		"type":       typ,
-		"content":    content,
-		"blockCount": blockCount,
-		"eof":        eof,
-		"box":        boxID,
-		"path":       docPath,
+		"id":              id,
+		"mode":            mode,
+		"parentID":        parentID,
+		"parent2ID":       parent2ID,
+		"rootID":          rootID,
+		"type":            typ,
+		"content":         content,
+		"blockCount":      blockCount,
+		"childBlockCount": childBlockCount,
+		"eof":             eof,
+		"box":             boxID,
+		"path":            docPath,
 	}
 }
 

+ 2 - 1
kernel/model/file.go

@@ -421,7 +421,7 @@ func BlockWordCount(id string) (blockRuneCount, blockWordCount, rootBlockRuneCou
 	return
 }
 
-func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int) (blockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, err error) {
+func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int) (blockCount, childBlockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, err error) {
 	WaitForWritingFiles() // 写入数据时阻塞,避免获取到的数据不一致
 
 	inputIndex := index
@@ -529,6 +529,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size
 	}
 
 	blockCount = tree.DocBlockCount()
+	childBlockCount = treenode.CountBlockNodes(tree.Root)
 	if ast.NodeDocument == node.Type {
 		parentID = node.ID
 		parent2ID = parentID