An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: The database primary key field displays the icon of the bound doc https://github.com/siyuan-note/siyuan/issues/13378
Daniel807f0df86fdc
diff --git a/kernel/av/value.go b/kernel/av/value.goindex b50d133efb..f7c3b32897 100644--- a/kernel/av/value.go+++ b/kernel/av/value.go@@ -371,6 +371,7 @@ func (value *Value) GetValByType(typ KeyType) (ret interface{}) {type ValueBlock struct {ID string `json:"id"`+ Icon string `json:"icon"`Content string `json:"content"`Created int64 `json:"created"`Updated int64 `json:"updated"`diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 32acba9738..c821a70eb7 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1980,8 +1980,9 @@ func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBlocreturn}+ var blockIcon stringif !isDetached {- addingBlockContent = getNodeAvBlockText(node)+ blockIcon, addingBlockContent = getNodeAvBlockText(node)}// 检查是否重复添加相同的块@@ -1992,6 +1993,7 @@ func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBloc// 重复绑定一下,比如剪切数据库块、取消绑定块后再次添加的场景需要bindBlockAv0(tx, avID, node, tree)blockValue.IsDetached = isDetached+ blockValue.Block.Icon = blockIconblockValue.Block.Content = addingBlockContentblockValue.UpdatedAt = nowerr = av.SaveAttributeView(attrView)@@ -2936,7 +2938,7 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err errorif !operation.IsDetached {bindBlockAv0(tx, operation.AvID, node, tree)value.IsDetached = false- value.Block.Content = getNodeAvBlockText(node)+ value.Block.Icon, value.Block.Content = getNodeAvBlockText(node)value.UpdatedAt = nowerr = av.SaveAttributeView(attrView)}@@ -2973,7 +2975,7 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err errorvalue.Block.ID = operation.NextIDvalue.IsDetached = operation.IsDetachedif !operation.IsDetached {- value.Block.Content = getNodeAvBlockText(node)+ value.Block.Icon, value.Block.Content = getNodeAvBlockText(node)}}diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.goindex 7b844d6d96..760d74b9e3 100644--- a/kernel/model/blockinfo.go+++ b/kernel/model/blockinfo.go@@ -268,22 +268,19 @@ func getNodeRefText(node *ast.Node) string {return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen)}-func getNodeAvBlockText(node *ast.Node) (ret string) {+func getNodeAvBlockText(node *ast.Node) (icon, content string) {if nil == node {- return ""+ return}+ icon = node.IALAttr("icon")if name := node.IALAttr("name"); "" != name {name = strings.TrimSpace(name)name = util.EscapeHTML(name)- ret = name+ content = name} else {- ret = getNodeRefText0(node, 1024)+ content = getNodeRefText0(node, 1024)}-- //if icon := node.IALAttr("icon"); "" != icon {- // ret = icon + " " + ret- //}return}diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.goindex bc54bc0b34..5c58b66a5b 100644--- a/kernel/model/push_reload.go+++ b/kernel/model/push_reload.go@@ -269,7 +269,11 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees mfor _, blockValue := range blockValues.Values {if blockValue.Block.ID == updatedDefNode.ID {- newContent := getNodeAvBlockText(updatedDefNode)+ newIcon, newContent := getNodeAvBlockText(updatedDefNode)+ if newIcon != blockValue.Block.Icon {+ blockValue.Block.Icon = newIcon+ changedAv = true+ }if newContent != blockValue.Block.Content {blockValue.Block.Content = newContentchangedAv = true