mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
🎨 Improve sort when importing markdown files https://github.com/siyuan-note/siyuan/issues/11390
This commit is contained in:
parent
a63c545ad5
commit
91a068ff52
1 changed files with 18 additions and 1 deletions
|
|
@ -680,7 +680,10 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
||||||
}
|
}
|
||||||
boxLocalPath = filepath.Join(util.DataDir, boxID)
|
boxLocalPath = filepath.Join(util.DataDir, boxID)
|
||||||
|
|
||||||
if gulu.File.IsDir(localPath) {
|
hPathsIDs := map[string]string{}
|
||||||
|
idPaths := map[string]string{}
|
||||||
|
|
||||||
|
if gulu.File.IsDir(localPath) { // 导入文件夹
|
||||||
// 收集所有资源文件
|
// 收集所有资源文件
|
||||||
assets := map[string]string{}
|
assets := map[string]string{}
|
||||||
filelock.Walk(localPath, func(currentPath string, info os.FileInfo, walkErr error) error {
|
filelock.Walk(localPath, func(currentPath string, info os.FileInfo, walkErr error) error {
|
||||||
|
|
@ -843,6 +846,9 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
||||||
|
|
||||||
reassignIDUpdated(tree)
|
reassignIDUpdated(tree)
|
||||||
importTrees = append(importTrees, tree)
|
importTrees = append(importTrees, tree)
|
||||||
|
|
||||||
|
hPathsIDs[tree.HPath] = tree.ID
|
||||||
|
idPaths[tree.ID] = tree.Path
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
} else { // 导入单个文件
|
} else { // 导入单个文件
|
||||||
|
|
@ -953,6 +959,17 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
||||||
|
|
||||||
importTrees = []*parse.Tree{}
|
importTrees = []*parse.Tree{}
|
||||||
searchLinks = map[string]string{}
|
searchLinks = map[string]string{}
|
||||||
|
|
||||||
|
// 按照路径排序 Improve sort when importing markdown files https://github.com/siyuan-note/siyuan/issues/11390
|
||||||
|
var paths, hPaths []string
|
||||||
|
for hPath := range hPathsIDs {
|
||||||
|
hPaths = append(hPaths, hPath)
|
||||||
|
}
|
||||||
|
sort.Strings(hPaths)
|
||||||
|
for _, hPath := range hPaths {
|
||||||
|
paths = append(paths, idPaths[hPathsIDs[hPath]])
|
||||||
|
}
|
||||||
|
ChangeFileTreeSort(boxID, paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue