mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +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"
|
||||
)
|
||||
|
||||
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) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue