🎨 Improve search result highlight and positioning https://github.com/siyuan-note/siyuan/issues/8274

This commit is contained in:
Liang Ding 2023-05-19 10:18:25 +08:00
parent 19dd0cd796
commit 0f90105527
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 55 additions and 8 deletions

View file

@ -675,11 +675,24 @@ func getDoc(c *gin.Context) {
if nil != idx {
index = int(idx.(float64))
}
k := arg["k"]
var keyword string
if nil != k {
keyword = k.(string)
var query string
if queryArg := arg["query"]; nil != queryArg {
query = queryArg.(string)
}
var queryMethod int
if queryMethodArg := arg["queryMethod"]; nil != queryMethodArg {
queryMethod = int(queryMethodArg.(float64))
}
var queryTypes map[string]bool
if queryTypesArg := arg["queryTypes"]; nil != queryTypesArg {
typesArg := queryTypesArg.(map[string]interface{})
queryTypes = map[string]bool{}
for t, b := range typesArg {
queryTypes[t] = b.(bool)
}
}
m := arg["mode"] // 0: 仅当前 ID1向上 2向下3上下都加载4加载末尾
mode := 0
if nil != m {
@ -705,7 +718,7 @@ func getDoc(c *gin.Context) {
isBacklink = isBacklinkArg.(bool)
}
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, query, queryTypes, queryMethod, mode, size, isBacklink)
if model.ErrBlockNotFound == err {
ret.Code = 3
return