فهرست منبع

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 سال پیش
والد
کامیت
1f31a33977
2فایلهای تغییر یافته به همراه20 افزوده شده و 0 حذف شده
  1. 14 0
      kernel/av/table.go
  2. 6 0
      kernel/util/misc.go

+ 14 - 0
kernel/av/table.go

@@ -21,6 +21,8 @@ import (
 	"sort"
 	"strconv"
 	"strings"
+
+	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
 // LayoutTable 描述了表格布局的结构。
@@ -174,6 +176,18 @@ func (value *Value) Compare(other *Value) int {
 		}
 	case KeyTypeTemplate:
 		if nil != value.Template && nil != other.Template {
+			if util.IsNumeric(value.Template.Content) && util.IsNumeric(other.Template.Content) {
+				v1, _ := strconv.ParseFloat(value.Template.Content, 64)
+				v2, _ := strconv.ParseFloat(other.Template.Content, 64)
+				if v1 > v2 {
+					return 1
+				}
+
+				if v1 < v2 {
+					return -1
+				}
+				return 0
+			}
 			return strings.Compare(value.Template.Content, other.Template.Content)
 		}
 	case KeyTypeCheckbox:

+ 6 - 0
kernel/util/misc.go

@@ -18,6 +18,7 @@ package util
 
 import (
 	"bytes"
+	"strconv"
 	"strings"
 	"unicode"
 
@@ -82,3 +83,8 @@ func RemoveRedundantSpace(str string) string {
 	}
 	return buf.String()
 }
+
+func IsNumeric(s string) bool {
+	_, err := strconv.ParseFloat(s, 64)
+	return err == nil
+}