This commit is contained in:
Daniel 2024-04-13 11:45:33 +08:00
parent 86f92208bf
commit 47aa891f34
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 31 additions and 28 deletions

View file

@ -18,7 +18,6 @@ package av
import (
"bytes"
"strconv"
"strings"
"github.com/siyuan-note/siyuan/kernel/util"
@ -196,11 +195,9 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
}
case KeyTypeTemplate:
if nil != value.Template && nil != other.Template {
vContent := strings.TrimSpace(value.Template.Content)
oContent := strings.TrimSpace(other.Template.Content)
if util.IsNumeric(vContent) && util.IsNumeric(oContent) {
v1, _ := strconv.ParseFloat(vContent, 64)
v2, _ := strconv.ParseFloat(oContent, 64)
v1, ok1 := util.Convert2Float(value.Template.Content)
v2, ok2 := util.Convert2Float(other.Template.Content)
if ok1 && ok2 {
if v1 > v2 {
return 1
}
@ -236,9 +233,9 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
}
oContent := strings.TrimSpace(oContentBuf.String())
if util.IsNumeric(vContent) && util.IsNumeric(oContent) {
v1, _ := strconv.ParseFloat(vContent, 64)
v2, _ := strconv.ParseFloat(oContent, 64)
v1, ok1 := util.Convert2Float(value.Template.Content)
v2, ok2 := util.Convert2Float(other.Template.Content)
if ok1 && ok2 {
if v1 > v2 {
return 1
}
@ -265,9 +262,9 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
}
oContent := strings.TrimSpace(oContentBuf.String())
if util.IsNumeric(vContent) && util.IsNumeric(oContent) {
v1, _ := strconv.ParseFloat(vContent, 64)
v2, _ := strconv.ParseFloat(oContent, 64)
v1, ok1 := util.Convert2Float(value.Template.Content)
v2, ok2 := util.Convert2Float(other.Template.Content)
if ok1 && ok2 {
if v1 > v2 {
return 1
}