mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
:octocat: 补充 PR 模板 https://github.com/siyuan-note/siyuan/pull/6471
This commit is contained in:
parent
89166ca0d5
commit
75925c9e4f
2 changed files with 25 additions and 10 deletions
|
|
@ -1028,12 +1028,6 @@ func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err e
|
|||
}
|
||||
|
||||
func MoveDocs(fromPaths []string, toPath string) (err error) {
|
||||
util.PushEndlessProgress(Conf.Language(116))
|
||||
|
||||
WaitForWritingFiles()
|
||||
fromPaths = util.FilterMoveDocFromPaths(fromPaths, toPath)
|
||||
pathsBoxes := getBoxesByPaths(fromPaths)
|
||||
|
||||
toID := strings.TrimSuffix(path.Base(toPath), ".sy")
|
||||
toBlock := treenode.GetBlockTree(toID)
|
||||
if nil == toBlock {
|
||||
|
|
@ -1047,6 +1041,14 @@ func MoveDocs(fromPaths []string, toPath string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
fromPaths = util.FilterMoveDocFromPaths(fromPaths, toPath)
|
||||
pathsBoxes := getBoxesByPaths(fromPaths)
|
||||
needShowProgress := 32 < len(fromPaths)
|
||||
if needShowProgress {
|
||||
util.PushEndlessProgress(Conf.Language(116))
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
for fromPath, fromBox := range pathsBoxes {
|
||||
_, err = moveDoc(fromBox, fromPath, toBox, toPath)
|
||||
if nil != err {
|
||||
|
|
@ -1056,9 +1058,11 @@ func MoveDocs(fromPaths []string, toPath string) (err error) {
|
|||
cache.ClearDocsIAL()
|
||||
IncSync()
|
||||
|
||||
if needShowProgress {
|
||||
util.PushEndlessProgress(Conf.Language(113))
|
||||
sql.WaitForWritingDatabase()
|
||||
util.ReloadUI()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1167,6 +1171,16 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string) (newPath
|
|||
moveTree(tree)
|
||||
moveSorts(tree.ID, fromBox.ID, toBox.ID)
|
||||
}
|
||||
|
||||
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast, util.PushModeNone)
|
||||
evt.Data = map[string]interface{}{
|
||||
"fromNotebook": fromBox.ID,
|
||||
"fromPath": fromPath,
|
||||
"toNotebook": toBox.ID,
|
||||
"toPath": toPath,
|
||||
"newPath": newPath,
|
||||
}
|
||||
util.PushEvent(evt)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,11 +178,12 @@ func NormalizeEndpoint(endpoint string) string {
|
|||
func FilterMoveDocFromPaths(fromPaths []string, toPath string) (retFromPaths []string) {
|
||||
fromPaths = append(fromPaths, toPath)
|
||||
retFromPaths = FilterSelfChildDocs(fromPaths)
|
||||
retFromPaths = gulu.Str.ExcludeElem(retFromPaths, []string{toPath})
|
||||
return
|
||||
}
|
||||
|
||||
func FilterSelfChildDocs(paths []string) (ret []string) {
|
||||
sort.Slice(paths, func(i, j int) bool { return len(paths[i]) < len(paths[j]) })
|
||||
sort.Slice(paths, func(i, j int) bool { return strings.Count(paths[i], "/") < strings.Count(paths[j], "/") })
|
||||
|
||||
dirs := map[string]string{}
|
||||
for _, fromPath := range paths {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue