Преглед на файлове

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

Liang Ding преди 2 години
родител
ревизия
c5c24994a8
променени са 2 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 1 2
      kernel/api/search.go
  2. 2 1
      kernel/model/search.go

+ 1 - 2
kernel/api/search.go

@@ -267,12 +267,11 @@ func fullTextSearchBlock(c *gin.Context) {
 	if nil != groupByArg {
 		groupBy = int(groupByArg.(float64))
 	}
-	blocks, matchedBlockCount, matchedRootCount, pageCount, totalCount := model.FullTextSearchBlock(query, boxes, paths, types, method, orderBy, groupBy, page)
+	blocks, matchedBlockCount, matchedRootCount, pageCount := 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,
 	}
 }

+ 2 - 1
kernel/model/search.go

@@ -397,7 +397,7 @@ const pageSize = 32
 // method:0:关键字,1:查询语法,2:SQL,3:正则表达式
 // orderBy: 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
 // groupBy:0:不分组,1:按文档分组
-func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount, totalCount int) {
+func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount int) {
 	query = strings.TrimSpace(query)
 	beforeLen := 36
 	var blocks []*Block
@@ -421,6 +421,7 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
 		pathFilter := buildPathsFilter(paths)
 		blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, filter, orderByClause, beforeLen, page)
 	}
+	pageCount = (matchedBlockCount + pageSize - 1) / pageSize
 
 	switch groupBy {
 	case 0: // 不分组