mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
Improve kernel API /api/notebook/* (#9987)
* 🐛 fix some notebook API
* Update notebook.go
This commit is contained in:
parent
adc42291c6
commit
abd79c29a8
2 changed files with 39 additions and 5 deletions
|
|
@ -150,13 +150,20 @@ func createNotebook(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
box := model.Conf.Box(id)
|
||||
if nil == box {
|
||||
ret.Code = -1
|
||||
ret.Msg = "opened notebook [" + id + "] not found"
|
||||
return
|
||||
}
|
||||
|
||||
ret.Data = map[string]interface{}{
|
||||
"notebook": model.Conf.Box(id),
|
||||
"notebook": box,
|
||||
}
|
||||
|
||||
evt := util.NewCmdResult("createnotebook", 0, util.PushModeBroadcast)
|
||||
evt.Data = map[string]interface{}{
|
||||
"box": model.Conf.Box(id),
|
||||
"box": box,
|
||||
"existed": existed,
|
||||
}
|
||||
util.PushEvent(evt)
|
||||
|
|
@ -194,9 +201,16 @@ func openNotebook(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
box := model.Conf.Box(notebook)
|
||||
if nil == box {
|
||||
ret.Code = -1
|
||||
ret.Msg = "opened notebook [" + notebook + "] not found"
|
||||
return
|
||||
}
|
||||
|
||||
evt := util.NewCmdResult("mount", 0, util.PushModeBroadcast)
|
||||
evt.Data = map[string]interface{}{
|
||||
"box": model.Conf.Box(notebook),
|
||||
"box": box,
|
||||
"existed": existed,
|
||||
}
|
||||
evt.Callback = arg["callback"]
|
||||
|
|
@ -233,7 +247,13 @@ func getNotebookConf(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
box := model.Conf.Box(notebook)
|
||||
box := model.Conf.GetBox(notebook)
|
||||
if nil == box {
|
||||
ret.Code = -1
|
||||
ret.Msg = "notebook [" + notebook + "] not found"
|
||||
return
|
||||
}
|
||||
|
||||
ret.Data = map[string]interface{}{
|
||||
"box": box.ID,
|
||||
"name": box.Name,
|
||||
|
|
@ -255,7 +275,12 @@ func setNotebookConf(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
box := model.Conf.Box(notebook)
|
||||
box := model.Conf.GetBox(notebook)
|
||||
if nil == box {
|
||||
ret.Code = -1
|
||||
ret.Msg = "notebook [" + notebook + "] not found"
|
||||
return
|
||||
}
|
||||
|
||||
param, err := gulu.JSON.MarshalJSON(arg["conf"])
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -649,6 +649,15 @@ func (conf *AppConf) Box(boxID string) *Box {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (conf *AppConf) GetBox(boxID string) *Box {
|
||||
for _, box := range conf.GetBoxes() {
|
||||
if box.ID == boxID {
|
||||
return box
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (conf *AppConf) BoxNames(boxIDs []string) (ret map[string]string) {
|
||||
ret = map[string]string{}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue