mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🧑💻 API | getDocumentAssets https://github.com/siyuan-note/siyuan/issues/13875
This commit is contained in:
parent
4d92d63ba1
commit
693bf7e1ed
3 changed files with 30 additions and 0 deletions
|
@ -202,6 +202,25 @@ func getDocImageAssets(c *gin.Context) {
|
|||
ret.Data = assets
|
||||
}
|
||||
|
||||
func getDocAssets(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
assets, err := model.DocAssets(id)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
ret.Data = assets
|
||||
}
|
||||
|
||||
func setFileAnnotation(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
@ -279,6 +279,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/asset/removeUnusedAsset", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeUnusedAsset)
|
||||
ginServer.Handle("POST", "/api/asset/removeUnusedAssets", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeUnusedAssets)
|
||||
ginServer.Handle("POST", "/api/asset/getDocImageAssets", model.CheckAuth, getDocImageAssets)
|
||||
ginServer.Handle("POST", "/api/asset/getDocAssets", model.CheckAuth, getDocAssets)
|
||||
ginServer.Handle("POST", "/api/asset/renameAsset", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameAsset)
|
||||
ginServer.Handle("POST", "/api/asset/getImageOCRText", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getImageOCRText)
|
||||
ginServer.Handle("POST", "/api/asset/setImageOCRText", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setImageOCRText)
|
||||
|
|
|
@ -75,6 +75,16 @@ func DocImageAssets(rootID string) (ret []string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func DocAssets(rootID string) (ret []string, err error) {
|
||||
tree, err := LoadTreeByBlockID(rootID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ret = assetsLinkDestsInTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err error) {
|
||||
tree, err := LoadTreeByBlockID(rootID)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue