瀏覽代碼

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

Vanessa 7 月之前
父節點
當前提交
7509c10ed6

+ 43 - 6
app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy

@@ -6,7 +6,7 @@
 		"id": "20201204184532-3qm9l8n",
 		"title": "Template snippet",
 		"type": "doc",
-		"updated": "20241212102051"
+		"updated": "20241212163918"
 	},
 	"Children": [
 		{
@@ -57,7 +57,7 @@
 			"HeadingLevel": 2,
 			"Properties": {
 				"id": "20210104091444-jy56z0p",
-				"updated": "20241212102051"
+				"updated": "20241212163918"
 			},
 			"Children": [
 				{
@@ -215,7 +215,7 @@
 			"ListData": {},
 			"Properties": {
 				"id": "20210104091444-mwbvc9m",
-				"updated": "20241212102051"
+				"updated": "20241212163918"
 			},
 			"Children": [
 				{
@@ -495,7 +495,7 @@
 					},
 					"Properties": {
 						"id": "20241212102027-j293sei",
-						"updated": "20241212102051"
+						"updated": "20241212163902"
 					},
 					"Children": [
 						{
@@ -503,7 +503,7 @@
 							"Type": "NodeParagraph",
 							"Properties": {
 								"id": "20241212102028-6c8tlnu",
-								"updated": "20241212102051"
+								"updated": "20241212163902"
 							},
 							"Children": [
 								{
@@ -517,7 +517,7 @@
 								},
 								{
 									"Type": "NodeText",
-									"Data": "​: Statistics block content"
+									"Data": "​: This function is used to count the block content"
 								}
 							]
 						},
@@ -750,6 +750,43 @@
 						}
 					]
 				},
+				{
+					"ID": "20241212163841-3yjhffn",
+					"Type": "NodeListItem",
+					"ListData": {
+						"BulletChar": 42,
+						"Marker": "Kg=="
+					},
+					"Properties": {
+						"id": "20241212163841-3yjhffn",
+						"updated": "20241212163918"
+					},
+					"Children": [
+						{
+							"ID": "20241212163841-d8t3qxb",
+							"Type": "NodeParagraph",
+							"Properties": {
+								"id": "20241212163841-d8t3qxb",
+								"updated": "20241212163918"
+							},
+							"Children": [
+								{
+									"Type": "NodeText",
+									"Data": "​"
+								},
+								{
+									"Type": "NodeTextMark",
+									"TextMarkType": "code",
+									"TextMarkTextContent": "runeLen"
+								},
+								{
+									"Type": "NodeText",
+									"Data": "​: This function is used to return the string length"
+								}
+							]
+						}
+					]
+				},
 				{
 					"ID": "20211213121042-5n981ru",
 					"Type": "NodeListItem",

+ 43 - 6
app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy

@@ -6,7 +6,7 @@
 		"id": "20201204181006-7bkppue",
 		"title": "模板片段",
 		"type": "doc",
-		"updated": "20241212101821"
+		"updated": "20241212163739"
 	},
 	"Children": [
 		{
@@ -69,7 +69,7 @@
 			"HeadingLevel": 2,
 			"Properties": {
 				"id": "20210104091309-fhb549c",
-				"updated": "20241212101821"
+				"updated": "20241212163739"
 			},
 			"Children": [
 				{
@@ -237,7 +237,7 @@
 			"ListData": {},
 			"Properties": {
 				"id": "20210104091309-gjkg3u5",
-				"updated": "20241212101821"
+				"updated": "20241212163739"
 			},
 			"Children": [
 				{
@@ -517,7 +517,7 @@
 					},
 					"Properties": {
 						"id": "20241212101708-0euo6is",
-						"updated": "20241212101821"
+						"updated": "20241212163723"
 					},
 					"Children": [
 						{
@@ -525,7 +525,7 @@
 							"Type": "NodeParagraph",
 							"Properties": {
 								"id": "20241212101708-llv0ngj",
-								"updated": "20241212101734"
+								"updated": "20241212163723"
 							},
 							"Children": [
 								{
@@ -539,7 +539,7 @@
 								},
 								{
 									"Type": "NodeText",
-									"Data": "​:统计块内容"
+									"Data": "​:该函数用于统计块内容"
 								}
 							]
 						},
@@ -772,6 +772,43 @@
 						}
 					]
 				},
+				{
+					"ID": "20241212163704-qmyz1ss",
+					"Type": "NodeListItem",
+					"ListData": {
+						"BulletChar": 42,
+						"Marker": "Kg=="
+					},
+					"Properties": {
+						"id": "20241212163704-qmyz1ss",
+						"updated": "20241212163739"
+					},
+					"Children": [
+						{
+							"ID": "20241212163704-i9p11h6",
+							"Type": "NodeParagraph",
+							"Properties": {
+								"id": "20241212163704-i9p11h6",
+								"updated": "20241212163739"
+							},
+							"Children": [
+								{
+									"Type": "NodeText",
+									"Data": "​"
+								},
+								{
+									"Type": "NodeTextMark",
+									"TextMarkType": "code",
+									"TextMarkTextContent": "runeLen"
+								},
+								{
+									"Type": "NodeText",
+									"Data": "​:该函数用于返回字符串长度"
+								}
+							]
+						}
+					]
+				},
 				{
 					"ID": "20211213120813-ppm3j85",
 					"Type": "NodeListItem",

+ 42 - 5
app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy

@@ -6,7 +6,7 @@
 		"id": "20211226123004-dplpw0o",
 		"title": "範本片段",
 		"type": "doc",
-		"updated": "20241212102113"
+		"updated": "20241212164017"
 	},
 	"Children": [
 		{
@@ -53,7 +53,7 @@
 			"HeadingLevel": 2,
 			"Properties": {
 				"id": "20211226123024-eyagqur",
-				"updated": "20241212102113"
+				"updated": "20241212164017"
 			},
 			"Children": [
 				{
@@ -208,7 +208,7 @@
 			"ListData": {},
 			"Properties": {
 				"id": "20211226123024-pjvw31z",
-				"updated": "20241212102113"
+				"updated": "20241212164017"
 			},
 			"Children": [
 				{
@@ -496,7 +496,7 @@
 							"Type": "NodeParagraph",
 							"Properties": {
 								"id": "20241212102021-54wv84h",
-								"updated": "20241212102113"
+								"updated": "20241212164010"
 							},
 							"Children": [
 								{
@@ -510,7 +510,7 @@
 								},
 								{
 									"Type": "NodeText",
-									"Data": "​:統計區塊內容"
+									"Data": "​:此函數用於統計區塊內容"
 								}
 							]
 						},
@@ -743,6 +743,43 @@
 						}
 					]
 				},
+				{
+					"ID": "20241212164016-nxteno5",
+					"Type": "NodeListItem",
+					"ListData": {
+						"BulletChar": 42,
+						"Marker": "Kg=="
+					},
+					"Properties": {
+						"id": "20241212164016-nxteno5",
+						"updated": "20241212164017"
+					},
+					"Children": [
+						{
+							"ID": "20241212164016-ot8vo9l",
+							"Type": "NodeParagraph",
+							"Properties": {
+								"id": "20241212164016-ot8vo9l",
+								"updated": "20241212164017"
+							},
+							"Children": [
+								{
+									"Type": "NodeText",
+									"Data": "​"
+								},
+								{
+									"Type": "NodeTextMark",
+									"TextMarkType": "code",
+									"TextMarkTextContent": "runeLen"
+								},
+								{
+									"Type": "NodeText",
+									"Data": "​:此函數用於傳回字串長度"
+								}
+							]
+						}
+					]
+				},
 				{
 					"ID": "20211226123024-kca62r8",
 					"Type": "NodeListItem",

+ 42 - 5
app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy

@@ -7,7 +7,7 @@
 		"id": "20240530101000-6x9ivi7",
 		"title": "テンプレートスニペット",
 		"type": "doc",
-		"updated": "20241212102145"
+		"updated": "20241212163955"
 	},
 	"Children": [
 		{
@@ -66,7 +66,7 @@
 			"Properties": {
 				"ID": "20240530101000-5nvn9ad",
 				"id": "20240530101000-pi05yzt",
-				"updated": "20241212102145"
+				"updated": "20241212163955"
 			},
 			"Children": [
 				{
@@ -226,7 +226,7 @@
 			"ListData": {},
 			"Properties": {
 				"id": "20240530101000-by5hqnb",
-				"updated": "20241212102145"
+				"updated": "20241212163955"
 			},
 			"Children": [
 				{
@@ -514,7 +514,7 @@
 							"Type": "NodeParagraph",
 							"Properties": {
 								"id": "20241212102033-d4azb7k",
-								"updated": "20241212102145"
+								"updated": "20241212163936"
 							},
 							"Children": [
 								{
@@ -528,7 +528,7 @@
 								},
 								{
 									"Type": "NodeText",
-									"Data": "​:統計ブロックの内容"
+									"Data": "​:この関数はブロックの内容を数えるために使用されます"
 								}
 							]
 						},
@@ -761,6 +761,43 @@
 						}
 					]
 				},
+				{
+					"ID": "20241212163938-ewajrsj",
+					"Type": "NodeListItem",
+					"ListData": {
+						"BulletChar": 42,
+						"Marker": "Kg=="
+					},
+					"Properties": {
+						"id": "20241212163938-ewajrsj",
+						"updated": "20241212163955"
+					},
+					"Children": [
+						{
+							"ID": "20241212163938-y1al3b9",
+							"Type": "NodeParagraph",
+							"Properties": {
+								"id": "20241212163938-y1al3b9",
+								"updated": "20241212163955"
+							},
+							"Children": [
+								{
+									"Type": "NodeText",
+									"Data": "​"
+								},
+								{
+									"Type": "NodeTextMark",
+									"TextMarkType": "code",
+									"TextMarkTextContent": "runeLen"
+								},
+								{
+									"Type": "NodeText",
+									"Data": "​: この関数は文字列の長さを返すために使用されます"
+								}
+							]
+						}
+					]
+				},
 				{
 					"ID": "20240530101000-xhrxvp5",
 					"Type": "NodeListItem",

+ 6 - 0
kernel/filesys/template.go

@@ -20,6 +20,7 @@ import (
 	"math"
 	"text/template"
 	"time"
+	"unicode/utf8"
 
 	"github.com/88250/go-humanize"
 	"github.com/Masterminds/sprig/v3"
@@ -50,9 +51,14 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {
 	ret["FormatFloat"] = FormatFloat
 	ret["getHPathByID"] = getHPathByID
 	ret["statBlock"] = StatBlock
+	ret["runeLen"] = runeLen
 	return
 }
 
+func runeLen(s string) int {
+	return utf8.RuneCountInString(s)
+}
+
 func pow(a, b interface{}) int64    { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) }
 func powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) }
 func log(a, b interface{}) int64 {

+ 6 - 1
kernel/model/attribute_view.go

@@ -19,6 +19,7 @@ package model
 import (
 	"bytes"
 	"fmt"
+	"math/rand"
 	"os"
 	"path/filepath"
 	"slices"
@@ -3112,7 +3113,11 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID string, valueDa
 			for _, valOpt := range val.MSelect {
 				if opt := key.GetOption(valOpt.Content); nil == opt {
 					// 不存在的选项新建保存
-					opt = &av.SelectOption{Name: valOpt.Content, Color: valOpt.Color}
+					color := valOpt.Color
+					if "" == color {
+						color = fmt.Sprintf("%d", 1+rand.Intn(14))
+					}
+					opt = &av.SelectOption{Name: valOpt.Content, Color: color}
 					key.Options = append(key.Options, opt)
 				} else {
 					// 已经存在的选项颜色需要保持不变