mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 支持笔记本设置独立的排序规则 https://github.com/siyuan-note/siyuan/issues/3623
This commit is contained in:
parent
002dbb02b3
commit
2b0788db6c
1 changed files with 22 additions and 15 deletions
|
|
@ -20,8 +20,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
|
@ -41,17 +39,19 @@ import (
|
|||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
// Box 笔记本。
|
||||
type Box struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Sort int `json:"sort"`
|
||||
Closed bool `json:"closed"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Sort int `json:"sort"`
|
||||
SortMode int `json:"sortMode"`
|
||||
Closed bool `json:"closed"`
|
||||
|
||||
historyGenerated int64 // 最近一次历史生成时间
|
||||
}
|
||||
|
|
@ -123,11 +123,12 @@ func ListNotebooks() (ret []*Box, err error) {
|
|||
|
||||
id := dir.Name()
|
||||
ret = append(ret, &Box{
|
||||
ID: id,
|
||||
Name: boxConf.Name,
|
||||
Icon: boxConf.Icon,
|
||||
Sort: boxConf.Sort,
|
||||
Closed: boxConf.Closed,
|
||||
ID: id,
|
||||
Name: boxConf.Name,
|
||||
Icon: boxConf.Icon,
|
||||
Sort: boxConf.Sort,
|
||||
SortMode: boxConf.SortMode,
|
||||
Closed: boxConf.Closed,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -226,12 +227,18 @@ func (box *Box) Ls(p string) (ret []*FileInfo, totals int, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(filepath.Join(util.DataDir, box.ID, p))
|
||||
entries, err := os.ReadDir(filepath.Join(util.DataDir, box.ID, p))
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
for _, f := range entries {
|
||||
info, infoErr := f.Info()
|
||||
if nil != infoErr {
|
||||
logging.LogErrorf("read file info failed: %s", infoErr)
|
||||
continue
|
||||
}
|
||||
|
||||
name := f.Name()
|
||||
if util.IsReservedFilename(name) {
|
||||
continue
|
||||
|
|
@ -246,7 +253,7 @@ func (box *Box) Ls(p string) (ret []*FileInfo, totals int, err error) {
|
|||
fi := &FileInfo{}
|
||||
fi.name = name
|
||||
fi.isdir = f.IsDir()
|
||||
fi.size = f.Size()
|
||||
fi.size = info.Size()
|
||||
fPath := path.Join(p, name)
|
||||
if f.IsDir() {
|
||||
fPath += "/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue