mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🧑💻 Add a parameter containChildren for the kernel API /api/ref/getBacklinkDoc
接口 `/api/ref/getBacklinkDoc` 和 `/api/ref/getBackmentionDoc` 添加参数 `containChildren` 。 Co-authored-by: weizelong <1710010123@qq.com>
This commit is contained in:
parent
380cee6e10
commit
13140edd6b
4 changed files with 18 additions and 8 deletions
|
|
@ -436,7 +436,8 @@ export class Backlink extends Model {
|
||||||
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
||||||
defID: this.blockId,
|
defID: this.blockId,
|
||||||
refTreeID: docId,
|
refTreeID: docId,
|
||||||
keyword: isMention ? this.inputsElement[1].value : this.inputsElement[0].value
|
keyword: isMention ? this.inputsElement[1].value : this.inputsElement[0].value,
|
||||||
|
containChildren: true
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
svgElement.removeAttribute("disabled");
|
svgElement.removeAttribute("disabled");
|
||||||
svgElement.classList.add("b3-list-item__arrow--open");
|
svgElement.classList.add("b3-list-item__arrow--open");
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
|
||||||
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
||||||
defID: protyle.element.getAttribute("data-defid"),
|
defID: protyle.element.getAttribute("data-defid"),
|
||||||
refTreeID: protyle.block.rootID,
|
refTreeID: protyle.block.rootID,
|
||||||
keyword: isMention ? inputsElement[1].value : inputsElement[0].value
|
keyword: isMention ? inputsElement[1].value : inputsElement[0].value,
|
||||||
|
containChildren: true
|
||||||
}, response => {
|
}, response => {
|
||||||
protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks;
|
protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks;
|
||||||
renderBacklink(protyle, protyle.options.backlinkData);
|
renderBacklink(protyle, protyle.options.backlinkData);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,11 @@ func getBackmentionDoc(c *gin.Context) {
|
||||||
defID := arg["defID"].(string)
|
defID := arg["defID"].(string)
|
||||||
refTreeID := arg["refTreeID"].(string)
|
refTreeID := arg["refTreeID"].(string)
|
||||||
keyword := arg["keyword"].(string)
|
keyword := arg["keyword"].(string)
|
||||||
backlinks := model.GetBackmentionDoc(defID, refTreeID, keyword)
|
containChildren := true
|
||||||
|
if val, ok := arg["containChildren"]; ok {
|
||||||
|
containChildren = val.(bool)
|
||||||
|
}
|
||||||
|
backlinks := model.GetBackmentionDoc(defID, refTreeID, keyword, containChildren)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"backmentions": backlinks,
|
"backmentions": backlinks,
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +73,11 @@ func getBacklinkDoc(c *gin.Context) {
|
||||||
defID := arg["defID"].(string)
|
defID := arg["defID"].(string)
|
||||||
refTreeID := arg["refTreeID"].(string)
|
refTreeID := arg["refTreeID"].(string)
|
||||||
keyword := arg["keyword"].(string)
|
keyword := arg["keyword"].(string)
|
||||||
backlinks := model.GetBacklinkDoc(defID, refTreeID, keyword)
|
containChildren := true
|
||||||
|
if val, ok := arg["containChildren"]; ok {
|
||||||
|
containChildren = val.(bool)
|
||||||
|
}
|
||||||
|
backlinks := model.GetBacklinkDoc(defID, refTreeID, keyword, containChildren)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"backlinks": backlinks,
|
"backlinks": backlinks,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ type Backlink struct {
|
||||||
Expand bool `json:"expand"`
|
Expand bool `json:"expand"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren bool) (ret []*Backlink) {
|
||||||
keyword = strings.TrimSpace(keyword)
|
keyword = strings.TrimSpace(keyword)
|
||||||
ret = []*Backlink{}
|
ret = []*Backlink{}
|
||||||
beforeLen := 12
|
beforeLen := 12
|
||||||
|
|
@ -78,7 +78,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
||||||
}
|
}
|
||||||
rootID := sqlBlock.RootID
|
rootID := sqlBlock.RootID
|
||||||
|
|
||||||
refs := sql.QueryRefsByDefID(defID, true)
|
refs := sql.QueryRefsByDefID(defID, containChildren)
|
||||||
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, keyword)
|
linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
|
||||||
|
|
@ -114,7 +114,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBacklinkDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren bool) (ret []*Backlink) {
|
||||||
keyword = strings.TrimSpace(keyword)
|
keyword = strings.TrimSpace(keyword)
|
||||||
ret = []*Backlink{}
|
ret = []*Backlink{}
|
||||||
sqlBlock := sql.GetBlock(defID)
|
sqlBlock := sql.GetBlock(defID)
|
||||||
|
|
@ -123,7 +123,7 @@ func GetBacklinkDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
||||||
}
|
}
|
||||||
rootID := sqlBlock.RootID
|
rootID := sqlBlock.RootID
|
||||||
|
|
||||||
tmpRefs := sql.QueryRefsByDefID(defID, true)
|
tmpRefs := sql.QueryRefsByDefID(defID, containChildren)
|
||||||
var refs []*sql.Ref
|
var refs []*sql.Ref
|
||||||
for _, ref := range tmpRefs {
|
for _, ref := range tmpRefs {
|
||||||
if ref.RootID == refTreeID {
|
if ref.RootID == refTreeID {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue