From 0428d050d0c3a13ccd06bc4f59da572fbfb6a712 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 5 Dec 2022 10:53:00 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=97=A0=E6=B3=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=98=E5=A4=B4=E5=9B=BE=E6=A0=87=E7=AD=BE=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/6756?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/search.go | 3 +++ kernel/model/tag.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/kernel/api/search.go b/kernel/api/search.go index c71298faf..19fe7d105 100644 --- a/kernel/api/search.go +++ b/kernel/api/search.go @@ -83,6 +83,9 @@ func searchTag(c *gin.Context) { k := arg["k"].(string) tags := model.SearchTags(k) + if 1 > len(tags) { + tags = []string{} + } ret.Data = map[string]interface{}{ "tags": tags, "k": k, diff --git a/kernel/model/tag.go b/kernel/model/tag.go index a56ce975c..0af770f64 100644 --- a/kernel/model/tag.go +++ b/kernel/model/tag.go @@ -20,6 +20,7 @@ import ( "bytes" "errors" "fmt" + "github.com/siyuan-note/logging" "sort" "strings" @@ -282,6 +283,7 @@ func sortTags(tags Tags) { func SearchTags(keyword string) (ret []string) { ret = []string{} + defer logging.Recover() // TODO: 定位 无法添加题头图标签 https://github.com/siyuan-note/siyuan/issues/6756 labels := labelBlocksByKeyword(keyword) for label, _ := range labels {