mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🎨 Improve database field sorting for content containing emojis https://github.com/siyuan-note/siyuan/issues/14323
This commit is contained in:
parent
020dfabcb0
commit
650493dcdb
2 changed files with 15 additions and 5 deletions
|
@ -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 1
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue