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: Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791
Daniel310c9b844c44
diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.goindex a010ee1d4e..c1cdd274d9 100644--- a/kernel/model/push_reload.go+++ b/kernel/model/push_reload.go@@ -154,8 +154,9 @@ func refreshRefCount(rootID, blockID string) {isDoc := bt.ID == bt.RootIDvar rootRefIDs []stringvar refCount, rootRefCount int- refIDs := sql.QueryRefIDsByDefID(bt.ID, isDoc)+ var refIDs []stringif isDoc {+ refIDs = sql.QueryRefIDsByDefID(bt.ID, isDoc)rootRefIDs = refIDs} else {rootRefIDs = sql.QueryRefIDsByDefID(bt.RootID, true)@@ -169,7 +170,7 @@ func refreshRefCount(rootID, blockID string) {defIDs = append(defIDs, bt.ID)}- util.PushSetDefRefCount(rootID, blockID, refIDs, rootRefIDs, defIDs, refCount, rootRefCount)+ util.PushSetDefRefCount(rootID, blockID, defIDs, refCount, rootRefCount)}// refreshDynamicRefText 用于刷新块引用的动态锚文本。diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.goindex 6f15b9f7d8..f786b8288a 100644--- a/kernel/sql/block_ref_query.go+++ b/kernel/sql/block_ref_query.go@@ -141,7 +141,7 @@ func QueryRootChildrenRefCount(defRootID string) (ret map[string]int) {func QueryRootBlockRefCount() (ret map[string]int) {ret = map[string]int{}- rows, err := query("SELECT def_block_root_id, COUNT(*) AS ref_cnt FROM refs GROUP BY def_block_root_id")+ rows, err := query("SELECT def_block_root_id, COUNT(DISTINCT block_id) AS ref_cnt FROM refs GROUP BY def_block_root_id")if err != nil {logging.LogErrorf("sql query failed: %s", err)returndiff --git a/kernel/util/websocket.go b/kernel/util/websocket.goindex 2bce8851c9..954c427ed2 100644--- a/kernel/util/websocket.go+++ b/kernel/util/websocket.go@@ -271,8 +271,8 @@ func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string) {BroadcastByType("main", "setRefDynamicText", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText})}-func PushSetDefRefCount(rootID, blockID string, refIDs, rootRefIDs, defIDs []string, refCount, rootRefCount int) {- BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "refIDs": refIDs, "rootRefIDs": rootRefIDs, "defIDs": defIDs})+func PushSetDefRefCount(rootID, blockID string, defIDs []string, refCount, rootRefCount int) {+ BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "defIDs": defIDs})}func PushProtyleLoading(rootID, msg string) {