This commit is contained in:
Liang Ding 2023-05-05 16:20:23 +08:00
parent 5a6db7fdb4
commit 109462a22f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 60 additions and 2 deletions

View file

@ -22,6 +22,7 @@ import (
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
func loadPetals(c *gin.Context) {
@ -31,3 +32,17 @@ func loadPetals(c *gin.Context) {
petals := model.LoadPetals()
ret.Data = petals
}
func setPetalEnabled(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
packageName := arg["packageName"].(string)
enabled := arg["enabled"].(bool)
model.SetPetalEnabled(packageName, enabled)
}

View file

@ -345,4 +345,5 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckReadonly, chatGPTWithAction)
ginServer.Handle("POST", "/api/petal/loadPetals", model.CheckAuth, model.CheckReadonly, loadPetals)
ginServer.Handle("POST", "/api/petal/setPetalEnabled", model.CheckAuth, model.CheckReadonly, setPetalEnabled)
}