mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 支持通过界面设置代码片段 https://github.com/siyuan-note/siyuan/issues/6357
This commit is contained in:
parent
4a2a422c69
commit
221693d937
4 changed files with 104 additions and 25 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue