From 1b0426b9877e50854e48a1af2949ca2b2a601720 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 5 Oct 2022 21:36:40 +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=20https://github.?= =?UTF-8?q?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 | 14 ++++++++++++++ kernel/model/conf.go | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index c2f5e647f..017cdb93e 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -317,6 +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 { @@ -325,6 +326,14 @@ 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 { @@ -361,6 +370,11 @@ 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: diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 3cb2d567b..57d663a66 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -467,6 +467,21 @@ func (conf *AppConf) Box(boxID string) *Box { return nil } +func (conf *AppConf) BoxNames(boxIDs []string) (ret map[string]string) { + ret = map[string]string{} + + boxes := conf.GetOpenedBoxes() + for _, boxID := range boxIDs { + for _, box := range boxes { + if box.ID == boxID { + ret[boxID] = box.Name + break + } + } + } + return +} + func (conf *AppConf) GetBoxes() (ret []*Box) { ret = []*Box{} notebooks, err := ListNotebooks()