فهرست منبع

:art: Clean code https://github.com/siyuan-note/siyuan/issues/13378

Daniel 7 ماه پیش
والد
کامیت
96c59433e2
2فایلهای تغییر یافته به همراه13 افزوده شده و 7 حذف شده
  1. 12 6
      kernel/model/blockinfo.go
  2. 1 1
      kernel/model/push_reload.go

+ 12 - 6
kernel/model/blockinfo.go

@@ -267,17 +267,23 @@ func getNodeRefText(node *ast.Node) string {
 	return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen)
 }
 
-func getNodeAvBlockText(node *ast.Node) string {
+func getNodeAvBlockText(node *ast.Node) (ret string) {
 	if nil == node {
 		return ""
 	}
 
-	if ret := node.IALAttr("name"); "" != ret {
-		ret = strings.TrimSpace(ret)
-		ret = util.EscapeHTML(ret)
-		return ret
+	if name := node.IALAttr("name"); "" != name {
+		name = strings.TrimSpace(name)
+		name = util.EscapeHTML(name)
+		ret = name
+	} else {
+		ret = getNodeRefText0(node, 1024)
 	}
-	return getNodeRefText0(node, 1024)
+
+	//if icon := node.IALAttr("icon"); "" != icon {
+	//	ret = icon + " " + ret
+	//}
+	return
 }
 
 func getNodeRefText0(node *ast.Node, maxLen int) string {

+ 1 - 1
kernel/model/push_reload.go

@@ -269,7 +269,7 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
 
 			for _, blockValue := range blockValues.Values {
 				if blockValue.Block.ID == updatedDefNode.ID {
-					newContent := getNodeRefText(updatedDefNode)
+					newContent := getNodeAvBlockText(updatedDefNode)
 					if newContent != blockValue.Block.Content {
 						blockValue.Block.Content = newContent
 						changedAv = true