This commit is contained in:
Daniel 2023-05-25 10:40:09 +08:00
parent b50dd5dca5
commit 1d5365294f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 62 additions and 0 deletions

View file

@ -282,6 +282,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/setting/setEmoji", model.CheckAuth, model.CheckReadonly, setEmoji)
ginServer.Handle("POST", "/api/setting/setFlashcard", model.CheckAuth, model.CheckReadonly, setFlashcard)
ginServer.Handle("POST", "/api/setting/setAI", model.CheckAuth, model.CheckReadonly, setAI)
ginServer.Handle("POST", "/api/setting/setBazaar", model.CheckAuth, model.CheckReadonly, setBazaar)
ginServer.Handle("POST", "/api/graph/resetGraph", model.CheckAuth, model.CheckReadonly, resetGraph)
ginServer.Handle("POST", "/api/graph/resetLocalGraph", model.CheckAuth, model.CheckReadonly, resetLocalGraph)

View file

@ -29,6 +29,35 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func setBazaar(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
param, err := gulu.JSON.MarshalJSON(arg)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
bazaar := &conf.Bazaar{}
if err = gulu.JSON.UnmarshalJSON(param, bazaar); nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
model.Conf.Bazaar = bazaar
model.Conf.Save()
ret.Data = bazaar
}
func setAI(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)