🎨 闪卡配置

This commit is contained in:
Liang Ding 2023-03-19 17:06:09 +08:00
parent 5608e28030
commit 60f390d9e0
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 38 additions and 0 deletions

View File

@ -263,6 +263,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/setting/getCustomCSS", model.CheckAuth, getCustomCSS)
ginServer.Handle("POST", "/api/setting/setCustomCSS", model.CheckAuth, model.CheckReadonly, setCustomCSS)
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/graph/resetGraph", model.CheckAuth, model.CheckReadonly, resetGraph)
ginServer.Handle("POST", "/api/graph/resetLocalGraph", model.CheckAuth, model.CheckReadonly, resetLocalGraph)

View File

@ -29,6 +29,43 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func setFlashcard(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
}
flashcard := &conf.Flashcard{}
if err = gulu.JSON.UnmarshalJSON(param, flashcard); nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
if 1 > flashcard.DailyNewCardLimit {
flashcard.DailyNewCardLimit = 1
}
if 1 > flashcard.DailyReviewCardLimit {
flashcard.DailyReviewCardLimit = 1
}
model.Conf.Flashcard = flashcard
model.Conf.Save()
ret.Data = flashcard
}
func setAccount(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)