mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +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"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/siyuan-note/siyuan/kernel/task"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -41,17 +39,19 @@ import (
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"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/treenode"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Box 笔记本。
|
// Box 笔记本。
|
||||||
type Box struct {
|
type Box struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
Sort int `json:"sort"`
|
Sort int `json:"sort"`
|
||||||
Closed bool `json:"closed"`
|
SortMode int `json:"sortMode"`
|
||||||
|
Closed bool `json:"closed"`
|
||||||
|
|
||||||
historyGenerated int64 // 最近一次历史生成时间
|
historyGenerated int64 // 最近一次历史生成时间
|
||||||
}
|
}
|
||||||
|
|
@ -123,11 +123,12 @@ func ListNotebooks() (ret []*Box, err error) {
|
||||||
|
|
||||||
id := dir.Name()
|
id := dir.Name()
|
||||||
ret = append(ret, &Box{
|
ret = append(ret, &Box{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: boxConf.Name,
|
Name: boxConf.Name,
|
||||||
Icon: boxConf.Icon,
|
Icon: boxConf.Icon,
|
||||||
Sort: boxConf.Sort,
|
Sort: boxConf.Sort,
|
||||||
Closed: boxConf.Closed,
|
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 {
|
if nil != err {
|
||||||
return
|
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()
|
name := f.Name()
|
||||||
if util.IsReservedFilename(name) {
|
if util.IsReservedFilename(name) {
|
||||||
continue
|
continue
|
||||||
|
|
@ -246,7 +253,7 @@ func (box *Box) Ls(p string) (ret []*FileInfo, totals int, err error) {
|
||||||
fi := &FileInfo{}
|
fi := &FileInfo{}
|
||||||
fi.name = name
|
fi.name = name
|
||||||
fi.isdir = f.IsDir()
|
fi.isdir = f.IsDir()
|
||||||
fi.size = f.Size()
|
fi.size = info.Size()
|
||||||
fPath := path.Join(p, name)
|
fPath := path.Join(p, name)
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
fPath += "/"
|
fPath += "/"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue