From 15fc11e6000308cddfa72b52590411fd8e04f84a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 29 Oct 2025 10:43:17 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16233 https://github.com/siyuan-note/siyuan/issues/16121 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/outline.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/kernel/model/outline.go b/kernel/model/outline.go index 766fbf9a1..d63d1cf91 100644 --- a/kernel/model/outline.go +++ b/kernel/model/outline.go @@ -239,10 +239,15 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) { ret = outline(tree) storage, _ := GetOutlineStorage(rootID) - if nil == storage { - // 默认展开顶层 + if nil == storage || 0 == len(storage) { + // 默认全部展开 for _, p := range ret { - p.Folded = false + for _, b := range p.Blocks { + b.Folded = false + for _, c := range b.Children { + walkChildren(c, []string{"expandAll"}) + } + } } } @@ -254,8 +259,6 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) { } for _, p := range ret { - p.Folded = false // 顶层默认展开 - for _, b := range p.Blocks { b.Folded = !gulu.Str.Contains(b.ID, expandIDs) for _, c := range b.Children { @@ -268,7 +271,12 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) { } func walkChildren(b *Block, expandIDs []string) { - b.Folded = !gulu.Str.Contains(b.ID, expandIDs) + if 1 == len(expandIDs) && "expandAll" == expandIDs[0] { + b.Folded = false + } else { + b.Folded = !gulu.Str.Contains(b.ID, expandIDs) + } + for _, c := range b.Children { walkChildren(c, expandIDs) }