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: 改进动态加载判断 Fix https://github.com/siyuan-note/siyuan/issues/7693
Liang Dingb81152515c64
diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.tsindex c6b5c1444b..4b0788c7bc 100644--- a/app/src/protyle/scroll/index.ts+++ b/app/src/protyle/scroll/index.ts@@ -82,7 +82,7 @@ export class Scroll {if (protyle.block.showAll) {this.element.classList.add("fn__none");} else {- if (protyle.block.childBlockCount > window.siyuan.config.editor.dynamicLoadBlocks) {+ if (protyle.block.scroll) {this.element.classList.remove("fn__none");} else {this.element.classList.add("fn__none");diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 683617de9b..20da2f73f2 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -72,7 +72,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]protyle.block.showAll = false;protyle.block.mode = data.data.mode;protyle.block.blockCount = data.data.blockCount;- protyle.block.childBlockCount = data.data.childBlockCount;+ protyle.block.scroll = data.data.scroll;protyle.block.action = action;if (!action.includes(Constants.CB_GET_UNCHANGEID)) {protyle.block.id = data.data.id;diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 1fc19c4511..0c1dd906d2 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -409,7 +409,7 @@ interface IProtyle {id: string,block: {id?: string,- childBlockCount?: number,+ scroll?: booleanparentID?: string,parent2ID?: string,rootID?: string,diff --git a/kernel/api/filetree.go b/kernel/api/filetree.goindex 45f9cfd2c0..d35d9462ec 100644--- a/kernel/api/filetree.go+++ b/kernel/api/filetree.go@@ -690,7 +690,7 @@ func getDoc(c *gin.Context) {isBacklink = isBacklinkArg.(bool)}- blockCount, childBlockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)+ blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)if errors.Is(err, filelock.ErrUnableAccessFile) {ret.Code = 2ret.Data = id@@ -719,8 +719,8 @@ func getDoc(c *gin.Context) {"type": typ,"content": content,"blockCount": blockCount,- "childBlockCount": childBlockCount,"eof": eof,+ "scroll": scroll,"box": boxID,"path": docPath,"isSyncing": isSyncing,diff --git a/kernel/model/file.go b/kernel/model/file.goindex 5833b3c2c5..301e1bbc8c 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -414,7 +414,7 @@ func StatTree(id string) (ret *util.BlockStatResult) {}}-func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int, isBacklink bool) (blockCount, childBlockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, isBacklinkExpand bool, err error) {+func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int, isBacklink bool) (blockCount int, dom, parentID, parent2ID, rootID, typ string, eof, scroll bool, boxID, docPath string, isBacklinkExpand bool, err error) {//os.MkdirAll("pprof", 0755)//cpuProfile, _ := os.Create("pprof/GetDoc")//pprof.StartCPUProfile(cpuProfile)@@ -540,7 +540,6 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size}blockCount = tree.DocBlockCount()- childBlockCount = treenode.CountBlockNodes(tree.Root)if ast.NodeDocument == node.Type {parentID = node.IDparent2ID = parentID@@ -561,6 +560,26 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, sizetyp = node.Type.String()}+ // 判断是否需要显示动态加载滚动条 https://github.com/siyuan-note/siyuan/issues/7693+ childCount := 0+ ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if !entering {+ return ast.WalkContinue+ }++ if 1 > childCount {+ childCount = 1+ } else {+ childCount += treenode.CountBlockNodes(n)+ }++ if childCount > Conf.Editor.DynamicLoadBlocks {+ scroll = true+ return ast.WalkStop+ }+ return ast.WalkContinue+ })+var nodes []*ast.Nodeif isBacklink {// 引用计数浮窗请求,需要按照反链逻辑组装 https://github.com/siyuan-note/siyuan/issues/6853