diff --git a/kernel/conf/box.go b/kernel/conf/box.go index 2108c7889..7cfcfcf60 100644 --- a/kernel/conf/box.go +++ b/kernel/conf/box.go @@ -16,6 +16,8 @@ package conf +import "github.com/siyuan-note/siyuan/kernel/util" + // BoxConf 维护 .siyuan/conf.json 笔记本配置。 type BoxConf struct { Name string `json:"name"` // 笔记本名称 @@ -26,6 +28,7 @@ type BoxConf struct { DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径 DailyNoteSavePath string `json:"dailyNoteSavePath"` // 新建日记存储路径 DailyNoteTemplatePath string `json:"dailyNoteTemplatePath"` // 新建日记使用的模板路径 + SortMode int `json:"sortMode"` // 排序方式 } func NewBoxConf() *BoxConf { @@ -34,5 +37,6 @@ func NewBoxConf() *BoxConf { Closed: true, DailyNoteSavePath: "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}", DailyNoteTemplatePath: "", + SortMode: util.SortModeFileTree, } } diff --git a/kernel/model/file.go b/kernel/model/file.go index 07edca45c..1483d25d9 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -233,6 +233,11 @@ func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err return nil, 0, errors.New(Conf.Language(0)) } + boxConf := box.GetConf() + if util.SortModeFileTree != boxConf.SortMode { + sortMode = boxConf.SortMode + } + var files []*FileInfo start := time.Now() files, totals, err = box.Ls(path) diff --git a/kernel/util/sort.go b/kernel/util/sort.go index a804aabe7..e87236d4c 100644 --- a/kernel/util/sort.go +++ b/kernel/util/sort.go @@ -68,4 +68,5 @@ const ( SortModeSizeDESC // 12:文件大小降序 SortModeSubDocCountASC // 13:子文档数升序 SortModeSubDocCountDESC // 14:子文档数降序 + SortModeFileTree // 15:使用文档树排序规则 )