mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🧑💻 Add an internal kernel API /api/outline/getDocOutlineAndStorage https://github.com/siyuan-note/siyuan/issues/16206
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
ea95d62801
commit
d154b05083
2 changed files with 39 additions and 1 deletions
|
|
@ -25,6 +25,41 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getDocOutlineAndStorage(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if nil == arg["id"] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
preview := false
|
||||||
|
if previewArg := arg["preview"]; nil != previewArg {
|
||||||
|
preview = previewArg.(bool)
|
||||||
|
}
|
||||||
|
rootID := arg["id"].(string)
|
||||||
|
data, err := model.GetOutlineStorage(rootID)
|
||||||
|
if err != nil {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
headings, err := model.Outline(rootID, preview)
|
||||||
|
if err != nil {
|
||||||
|
ret.Code = 1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret.Data = map[string]any{
|
||||||
|
"headings": headings,
|
||||||
|
"storage": data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getDocOutline(c *gin.Context) {
|
func getDocOutline(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,12 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/history/getHistoryItems", model.CheckAuth, model.CheckAdminRole, getHistoryItems)
|
ginServer.Handle("POST", "/api/history/getHistoryItems", model.CheckAuth, model.CheckAdminRole, getHistoryItems)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/outline/getDocOutline", model.CheckAuth, getDocOutline)
|
ginServer.Handle("POST", "/api/outline/getDocOutline", model.CheckAuth, getDocOutline)
|
||||||
|
ginServer.Handle("POST", "/api/outline/getDocOutlineAndStorage", model.CheckAuth, getDocOutlineAndStorage)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/bookmark/getBookmark", model.CheckAuth, getBookmark)
|
ginServer.Handle("POST", "/api/bookmark/getBookmark", model.CheckAuth, getBookmark)
|
||||||
ginServer.Handle("POST", "/api/bookmark/renameBookmark", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameBookmark)
|
ginServer.Handle("POST", "/api/bookmark/renameBookmark", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameBookmark)
|
||||||
ginServer.Handle("POST", "/api/bookmark/removeBookmark", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeBookmark)
|
ginServer.Handle("POST", "/api/bookmark/removeBookmark", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeBookmark)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/tag/getTag", model.CheckAuth, getTag)
|
ginServer.Handle("POST", "/api/tag/getTag", model.CheckAuth, getTag)
|
||||||
ginServer.Handle("POST", "/api/tag/renameTag", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameTag)
|
ginServer.Handle("POST", "/api/tag/renameTag", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameTag)
|
||||||
ginServer.Handle("POST", "/api/tag/removeTag", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeTag)
|
ginServer.Handle("POST", "/api/tag/removeTag", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeTag)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue