An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve database field sorting for content containing emojis https://github.com/siyuan-note/siyuan/issues/14323
Daniel650493dcdb31
diff --git a/kernel/av/sort.go b/kernel/av/sort.goindex 4002bc7e8d..f8a1c8621f 100644--- a/kernel/av/sort.go+++ b/kernel/av/sort.go@@ -68,7 +68,7 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {return 0}- if util.PinYinCompare(value.Text.Content, other.Text.Content) {+ if util.EmojiPinYinCompare(value.Text.Content, other.Text.Content) {return -1}return 1@@ -243,7 +243,7 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {return 0}- if util.PinYinCompare(v1, v2) {+ if util.EmojiPinYinCompare(v1, v2) {return -1}return 1@@ -266,7 +266,7 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {return 0}- if util.PinYinCompare(value.Template.Content, other.Template.Content) {+ if util.EmojiPinYinCompare(value.Template.Content, other.Template.Content) {return -1}return 1@@ -314,7 +314,7 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {return 0}- if util.PinYinCompare(vContent, oContent) {+ if util.EmojiPinYinCompare(vContent, oContent) {return -1}return 1@@ -352,7 +352,7 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {return 0}- if util.PinYinCompare(vContent, oContent) {+ if util.EmojiPinYinCompare(vContent, oContent) {return -1}return 1diff --git a/kernel/util/sort.go b/kernel/util/sort.goindex 57c45aedc8..2a6afe0f3c 100644--- a/kernel/util/sort.go+++ b/kernel/util/sort.go@@ -32,6 +32,16 @@ func NaturalCompare(str1, str2 string) bool {return natsort.Compare(str1, str2)}+func EmojiPinYinCompare(str1, str2 string) bool {+ str1_ := strings.TrimSpace(RemoveEmojiInvisible(str1))+ str2_ := strings.TrimSpace(RemoveEmojiInvisible(str2))+ if str1_ == str2_ && 0 == len(str1_) {+ // 全部都是 emoji 的情况按 emoji 字符串排序+ return strings.Compare(str1, str2) < 0+ }+ return PinYinCompare(str1, str2)+}+func PinYinCompare(str1, str2 string) bool {str1 = RemoveEmojiInvisible(str1)str2 = RemoveEmojiInvisible(str2)