From 39a3ac1fabf5df9bdfe16b07567b4810242d9e4e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 5 Oct 2022 21:48:53 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=8F=8D=E9=93=BE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=A1=A3=E6=A0=87=E9=A2=98=E5=9C=A8=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E6=82=AC=E6=B5=AE=E6=97=B6=E6=98=BE=E7=A4=BA=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=AE=8C=E6=95=B4=E8=B7=AF=E5=BE=84=20Fix=20https://g?= =?UTF-8?q?ithub.com/siyuan-note/insider/issues/1088?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/backlink.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 017cdb93e..fb39805e5 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -317,7 +317,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs) tmpBacklinks := toFlatTree(linkRefs, 0, "backlink") - var boxIDs []string + for _, l := range tmpBacklinks { l.Blocks = nil if "" != keyword { @@ -326,14 +326,6 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode } } backlinks = append(backlinks, l) - boxIDs = append(boxIDs, l.Box) - } - boxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs) - - boxNames := Conf.BoxNames(boxIDs) - for _, l := range backlinks { - name := boxNames[l.Box] - l.HPath = name + "/" + l.HPath } sort.Slice(backlinks, func(i, j int) bool { @@ -370,11 +362,6 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode backmentions = append(backmentions, l) } - for _, l := range backmentions { - name := boxNames[l.Box] - l.HPath = name + "/" + l.HPath - } - sort.Slice(backmentions, func(i, j int) bool { switch mentionSortMode { case util.SortModeUpdatedDESC: @@ -398,6 +385,25 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode }) mentionsCount = len(backmentions) + + // 添加笔记本名称 + var boxIDs []string + for _, l := range backlinks { + boxIDs = append(boxIDs, l.Box) + } + for _, l := range backmentions { + boxIDs = append(boxIDs, l.Box) + } + boxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs) + boxNames := Conf.BoxNames(boxIDs) + for _, l := range backlinks { + name := boxNames[l.Box] + l.HPath = name + l.HPath + } + for _, l := range backmentions { + name := boxNames[l.Box] + l.HPath = name + l.HPath + } return }