An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: https://github.com/siyuan-note/siyuan/security/advisories/GHSA-6r88-8v7q-q4p2
Daniel29566a4479be
diff --git a/kernel/api/tag.go b/kernel/api/tag.goindex 5189021881..3cfbb16115 100644--- a/kernel/api/tag.go+++ b/kernel/api/tag.go@@ -36,24 +36,22 @@ func getTag(c *gin.Context) {var ignoreMaxListHint boolvar app string+ var sortVal float64if !util.ParseJsonArgs(arg, ret,// API `getTag` add an optional parameter `ignoreMaxListHint` https://github.com/siyuan-note/siyuan/issues/16000util.BindJsonArg("ignoreMaxListHint", &ignoreMaxListHint, false, false),util.BindJsonArg("app", &app, false, false),+ util.BindJsonArg("sort", &sortVal, false, false),) {return}- if nil != arg["sort"] {- sortVal, ok := util.ParseJsonArg[float64]("sort", arg, ret, true, false)- if !ok {- return- }+ if model.IsAdminRoleContext(c) && !model.IsReadOnlyRoleContext(c) {model.Conf.Tag.Sort = int(sortVal)model.Conf.Save()}- tags := model.BuildTags(ignoreMaxListHint, app)+ tags := model.BuildTags(ignoreMaxListHint, app, int(sortVal))if model.IsReadOnlyRoleContext(c) {publishAccess := model.GetPublishAccess()diff --git a/kernel/model/tag.go b/kernel/model/tag.goindex 4a20ee8e89..a97afa3ecc 100644--- a/kernel/model/tag.go+++ b/kernel/model/tag.go@@ -247,7 +247,7 @@ type Tag struct {type Tags []*Tag-func BuildTags(ignoreMaxListHintArg bool, appID string) (ret *Tags) {+func BuildTags(ignoreMaxListHintArg bool, appID string, sortVal int) (ret *Tags) {FlushTxQueue()sql.FlushQueue()@@ -257,8 +257,8 @@ func BuildTags(ignoreMaxListHintArg bool, appID string) (ret *Tags) {for label := range labels {tags = buildTags(tags, strings.Split(label, "/"), 0)}- appendTagChildren(&tags, labels)- sortTags(tags)+ appendTagChildren(&tags, labels, sortVal)+ sortTags(tags, sortVal)var total inttmp := &Tags{}@@ -282,8 +282,8 @@ func countTag(tag *Tag, total *int) {}}-func sortTags(tags Tags) {- switch Conf.Tag.Sort {+func sortTags(tags Tags, sortVal int) {+ switch sortVal {case util.SortModeNameASC:sort.Slice(tags, func(i, j int) bool {return util.PinYinCompare(tags[i].Name, tags[j].Name)@@ -387,19 +387,19 @@ func labelTags() (ret map[string]Tags) {return}-func appendTagChildren(tags *Tags, labels map[string]Tags) {+func appendTagChildren(tags *Tags, labels map[string]Tags, sortVal int) {for _, tag := range *tags {tag.Label = tag.Nameif _, ok := labels[tag.Label]; ok {tag.Count = len(labels[tag.Label]) + 1}- appendChildren0(tag, labels)- sortTags(tag.Children)+ appendChildren0(tag, labels, sortVal)+ sortTags(tag.Children, sortVal)}}-func appendChildren0(tag *Tag, labels map[string]Tags) {- sortTags(tag.tags)+func appendChildren0(tag *Tag, labels map[string]Tags, sortVal int) {+ sortTags(tag.tags, sortVal)for _, t := range tag.tags {t.Label = tag.Label + "/" + t.Nameif _, ok := labels[t.Label]; ok {@@ -408,7 +408,7 @@ func appendChildren0(tag *Tag, labels map[string]Tags) {tag.Children = append(tag.Children, t)}for _, child := range tag.tags {- appendChildren0(child, labels)+ appendChildren0(child, labels, sortVal)}}