mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 06:11:24 +08:00
🎨 文档树支持 Ctrl+Click
和 Shift+↑/↓
进行多选 https://github.com/siyuan-note/siyuan/issues/1359
This commit is contained in:
parent
e3a6bb2251
commit
e9d15ade00
@ -257,39 +257,6 @@ func getFullHPathByID(c *gin.Context) {
|
|||||||
ret.Data = hPath
|
ret.Data = hPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveDoc(c *gin.Context) {
|
|
||||||
ret := gulu.Ret.NewResult()
|
|
||||||
defer c.JSON(http.StatusOK, ret)
|
|
||||||
|
|
||||||
arg, ok := util.JsonArg(c, ret)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fromNotebook := arg["fromNotebook"].(string)
|
|
||||||
toNotebook := arg["toNotebook"].(string)
|
|
||||||
fromPath := arg["fromPath"].(string)
|
|
||||||
toPath := arg["toPath"].(string)
|
|
||||||
|
|
||||||
newPath, err := model.MoveDoc(fromNotebook, fromPath, toNotebook, toPath)
|
|
||||||
if nil != err {
|
|
||||||
ret.Code = -1
|
|
||||||
ret.Msg = err.Error()
|
|
||||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast, util.PushModeNone)
|
|
||||||
evt.Data = map[string]interface{}{
|
|
||||||
"fromNotebook": fromNotebook,
|
|
||||||
"toNotebook": toNotebook,
|
|
||||||
"fromPath": fromPath,
|
|
||||||
"toPath": toPath,
|
|
||||||
"newPath": newPath,
|
|
||||||
}
|
|
||||||
util.PushEvent(evt)
|
|
||||||
}
|
|
||||||
|
|
||||||
func moveDocs(c *gin.Context) {
|
func moveDocs(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
@ -88,7 +88,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/filetree/renameDoc", model.CheckAuth, model.CheckReadonly, renameDoc)
|
ginServer.Handle("POST", "/api/filetree/renameDoc", model.CheckAuth, model.CheckReadonly, renameDoc)
|
||||||
ginServer.Handle("POST", "/api/filetree/removeDoc", model.CheckAuth, model.CheckReadonly, removeDoc)
|
ginServer.Handle("POST", "/api/filetree/removeDoc", model.CheckAuth, model.CheckReadonly, removeDoc)
|
||||||
ginServer.Handle("POST", "/api/filetree/removeDocs", model.CheckAuth, model.CheckReadonly, removeDocs)
|
ginServer.Handle("POST", "/api/filetree/removeDocs", model.CheckAuth, model.CheckReadonly, removeDocs)
|
||||||
ginServer.Handle("POST", "/api/filetree/moveDoc", model.CheckAuth, model.CheckReadonly, moveDoc)
|
|
||||||
ginServer.Handle("POST", "/api/filetree/moveDocs", model.CheckAuth, model.CheckReadonly, moveDocs)
|
ginServer.Handle("POST", "/api/filetree/moveDocs", model.CheckAuth, model.CheckReadonly, moveDocs)
|
||||||
ginServer.Handle("POST", "/api/filetree/duplicateDoc", model.CheckAuth, model.CheckReadonly, duplicateDoc)
|
ginServer.Handle("POST", "/api/filetree/duplicateDoc", model.CheckAuth, model.CheckReadonly, duplicateDoc)
|
||||||
ginServer.Handle("POST", "/api/filetree/getHPathByPath", model.CheckAuth, getHPathByPath)
|
ginServer.Handle("POST", "/api/filetree/getHPathByPath", model.CheckAuth, getHPathByPath)
|
||||||
|
@ -1005,47 +1005,6 @@ func GetFullHPathByID(id string) (hPath string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err error) {
|
|
||||||
WaitForWritingFiles()
|
|
||||||
|
|
||||||
if fromBoxID == toBoxID && fromPath == toPath {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fromDir := strings.TrimSuffix(fromPath, ".sy")
|
|
||||||
if strings.HasPrefix(toPath, fromDir) {
|
|
||||||
err = errors.New(Conf.Language(87))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fromBox := Conf.Box(fromBoxID)
|
|
||||||
if nil == fromBox {
|
|
||||||
err = errors.New(Conf.Language(0))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
childDepth := util.GetChildDocDepth(filepath.Join(util.DataDir, fromBoxID, fromPath))
|
|
||||||
if depth := strings.Count(toPath, "/") + childDepth; 6 < depth && !Conf.FileTree.AllowCreateDeeper {
|
|
||||||
err = errors.New(Conf.Language(118))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
toBox := Conf.Box(toBoxID)
|
|
||||||
if nil == toBox {
|
|
||||||
err = errors.New(Conf.Language(0))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
newPath, err = moveDoc(fromBox, fromPath, toBox, toPath)
|
|
||||||
if nil != err {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cache.ClearDocsIAL()
|
|
||||||
IncSync()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error) {
|
func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error) {
|
||||||
toBox := Conf.Box(toBoxID)
|
toBox := Conf.Box(toBoxID)
|
||||||
if nil == toBox {
|
if nil == toBox {
|
||||||
@ -1060,6 +1019,16 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error) {
|
|||||||
fromPaths = util.FilterMoveDocFromPaths(fromPaths, toPath)
|
fromPaths = util.FilterMoveDocFromPaths(fromPaths, toPath)
|
||||||
}
|
}
|
||||||
pathsBoxes := getBoxesByPaths(fromPaths)
|
pathsBoxes := getBoxesByPaths(fromPaths)
|
||||||
|
|
||||||
|
// 检查路径深度是否超过限制
|
||||||
|
for fromPath, fromBox := range pathsBoxes {
|
||||||
|
childDepth := util.GetChildDocDepth(filepath.Join(util.DataDir, fromBox.ID, fromPath))
|
||||||
|
if depth := strings.Count(toPath, "/") + childDepth; 6 < depth && !Conf.FileTree.AllowCreateDeeper {
|
||||||
|
err = errors.New(Conf.Language(118))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
needShowProgress := 32 < len(fromPaths)
|
needShowProgress := 32 < len(fromPaths)
|
||||||
if needShowProgress {
|
if needShowProgress {
|
||||||
util.PushEndlessProgress(Conf.Language(116))
|
util.PushEndlessProgress(Conf.Language(116))
|
||||||
|
Loading…
Reference in New Issue
Block a user