🎨 Global search supports pagination to display results https://github.com/siyuan-note/siyuan/issues/7948

This commit is contained in:
Liang Ding 2023-04-21 09:34:35 +08:00
parent 0a489606e3
commit 685b7e1383
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 25 additions and 14 deletions

View file

@ -218,6 +218,14 @@ func fullTextSearchBlock(c *gin.Context) {
return
}
page := 1
if nil != arg["page"] {
page = int(arg["page"].(float64))
}
if 0 >= page {
page = 1
}
query := arg["query"].(string)
pathsArg := arg["paths"]
var paths, boxes []string
@ -259,10 +267,12 @@ func fullTextSearchBlock(c *gin.Context) {
if nil != groupByArg {
groupBy = int(groupByArg.(float64))
}
blocks, matchedBlockCount, matchedRootCount := model.FullTextSearchBlock(query, boxes, paths, types, method, orderBy, groupBy)
blocks, matchedBlockCount, matchedRootCount, pageCount, totalCount := model.FullTextSearchBlock(query, boxes, paths, types, method, orderBy, groupBy, page)
ret.Data = map[string]interface{}{
"blocks": blocks,
"matchedBlockCount": matchedBlockCount,
"matchedRootCount": matchedRootCount,
"pageCount": pageCount,
"totalCount": totalCount,
}
}