mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
47d201eb3f
2 changed files with 10 additions and 3 deletions
|
|
@ -48,8 +48,9 @@ func getBackmentionDoc(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
defID := arg["defID"].(string)
|
defID := arg["defID"].(string)
|
||||||
|
refTreeID := arg["refTreeID"].(string)
|
||||||
keyword := ""
|
keyword := ""
|
||||||
backlinks := model.GetBackmentionDoc(defID, keyword)
|
backlinks := model.GetBackmentionDoc(defID, refTreeID, keyword)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"backmentions": backlinks,
|
"backmentions": backlinks,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ type Backlink struct {
|
||||||
Expand bool `json:"expand"`
|
Expand bool `json:"expand"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBackmentionDoc(defID, keyword string) (ret []*Backlink) {
|
func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
||||||
ret = []*Backlink{}
|
ret = []*Backlink{}
|
||||||
beforeLen := 12
|
beforeLen := 12
|
||||||
sqlBlock := sql.GetBlock(defID)
|
sqlBlock := sql.GetBlock(defID)
|
||||||
|
|
@ -177,9 +177,15 @@ func GetBackmentionDoc(defID, keyword string) (ret []*Backlink) {
|
||||||
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
linkRefs, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
|
linkRefs, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
|
||||||
mentions := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
|
tmpMentions := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
treeCache := map[string]*parse.Tree{}
|
treeCache := map[string]*parse.Tree{}
|
||||||
|
var mentions []*Block
|
||||||
|
for _, mention := range tmpMentions {
|
||||||
|
if mention.RootID == refTreeID {
|
||||||
|
mentions = append(mentions, mention)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, mention := range mentions {
|
for _, mention := range mentions {
|
||||||
refTree := treeCache[mention.RootID]
|
refTree := treeCache[mention.RootID]
|
||||||
if nil == refTree {
|
if nil == refTree {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue