🎨 支持通过界面设置代码片段 https://github.com/siyuan-note/siyuan/issues/6357

This commit is contained in:
Liang Ding 2022-10-26 20:44:45 +08:00
parent 4a2a422c69
commit 221693d937
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 104 additions and 25 deletions

View file

@ -88,3 +88,24 @@ func getSnippet(c *gin.Context) {
"snippets": snippets,
}
}
func setSnippet(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
name := arg["name"].(string)
typ := arg["type"].(string)
content := arg["content"].(string)
enabled := arg["enabled"].(bool)
err := model.SetSnippet(name, typ, content, enabled)
if nil != err {
ret.Code = -1
ret.Msg = "set snippet failed: " + err.Error()
return
}
}