🎨 支持笔记本设置独立的排序规则 https://github.com/siyuan-note/siyuan/issues/3623

This commit is contained in:
Liang Ding 2023-02-04 16:31:20 +08:00
parent 4103b380ab
commit 72a8132775
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 10 additions and 0 deletions

View file

@ -16,6 +16,8 @@
package conf package conf
import "github.com/siyuan-note/siyuan/kernel/util"
// BoxConf 维护 .siyuan/conf.json 笔记本配置。 // BoxConf 维护 .siyuan/conf.json 笔记本配置。
type BoxConf struct { type BoxConf struct {
Name string `json:"name"` // 笔记本名称 Name string `json:"name"` // 笔记本名称
@ -26,6 +28,7 @@ type BoxConf struct {
DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径 DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径
DailyNoteSavePath string `json:"dailyNoteSavePath"` // 新建日记存储路径 DailyNoteSavePath string `json:"dailyNoteSavePath"` // 新建日记存储路径
DailyNoteTemplatePath string `json:"dailyNoteTemplatePath"` // 新建日记使用的模板路径 DailyNoteTemplatePath string `json:"dailyNoteTemplatePath"` // 新建日记使用的模板路径
SortMode int `json:"sortMode"` // 排序方式
} }
func NewBoxConf() *BoxConf { func NewBoxConf() *BoxConf {
@ -34,5 +37,6 @@ func NewBoxConf() *BoxConf {
Closed: true, Closed: true,
DailyNoteSavePath: "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}", DailyNoteSavePath: "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}",
DailyNoteTemplatePath: "", DailyNoteTemplatePath: "",
SortMode: util.SortModeFileTree,
} }
} }

View file

@ -233,6 +233,11 @@ func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err
return nil, 0, errors.New(Conf.Language(0)) return nil, 0, errors.New(Conf.Language(0))
} }
boxConf := box.GetConf()
if util.SortModeFileTree != boxConf.SortMode {
sortMode = boxConf.SortMode
}
var files []*FileInfo var files []*FileInfo
start := time.Now() start := time.Now()
files, totals, err = box.Ls(path) files, totals, err = box.Ls(path)

View file

@ -68,4 +68,5 @@ const (
SortModeSizeDESC // 12文件大小降序 SortModeSizeDESC // 12文件大小降序
SortModeSubDocCountASC // 13子文档数升序 SortModeSubDocCountASC // 13子文档数升序
SortModeSubDocCountDESC // 14子文档数降序 SortModeSubDocCountDESC // 14子文档数降序
SortModeFileTree // 15使用文档树排序规则
) )