mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-31 13:58:49 +01:00
🎨 搜索 指定路径 支持多选 https://github.com/siyuan-note/siyuan/issues/6743
This commit is contained in:
parent
85477cc30a
commit
891f765cfb
2 changed files with 67 additions and 48 deletions
|
|
@ -194,15 +194,18 @@ func fullTextSearchBlock(c *gin.Context) {
|
|||
}
|
||||
|
||||
query := arg["query"].(string)
|
||||
pathArg := arg["path"]
|
||||
var path string
|
||||
if nil != pathArg {
|
||||
path = pathArg.(string)
|
||||
}
|
||||
var box string
|
||||
if "" != path {
|
||||
box = strings.Split(path, "/")[0]
|
||||
path = strings.TrimPrefix(path, box)
|
||||
pathsArg := arg["paths"]
|
||||
var paths, boxes []string
|
||||
if nil != pathsArg {
|
||||
for _, p := range pathsArg.([]interface{}) {
|
||||
path := p.(string)
|
||||
box := strings.Split(path, "/")[0]
|
||||
boxes = append(boxes, box)
|
||||
path = strings.TrimPrefix(path, box)
|
||||
paths = append(paths, path)
|
||||
}
|
||||
paths = gulu.Str.RemoveDuplicatedElem(paths)
|
||||
boxes = gulu.Str.RemoveDuplicatedElem(boxes)
|
||||
}
|
||||
var types map[string]bool
|
||||
if nil != arg["types"] {
|
||||
|
|
@ -222,7 +225,7 @@ func fullTextSearchBlock(c *gin.Context) {
|
|||
if nil != groupByArg {
|
||||
groupBy = int(groupByArg.(float64))
|
||||
}
|
||||
blocks, matchedBlockCount, matchedRootCount := model.FullTextSearchBlock(query, box, path, types, method, groupBy)
|
||||
blocks, matchedBlockCount, matchedRootCount := model.FullTextSearchBlock(query, boxes, paths, types, method, groupBy)
|
||||
ret.Data = map[string]interface{}{
|
||||
"blocks": blocks,
|
||||
"matchedBlockCount": matchedBlockCount,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue