mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-30 04:05:16 +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
|
|
@ -283,5 +283,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
||||
|
||||
ginServer.Handle("POST", "/api/snippet/getSnippet", model.CheckAuth, getSnippet)
|
||||
ginServer.Handle("POST", "/api/snippet/setSnippet", model.CheckAuth, setSnippet)
|
||||
ginServer.Handle("GET", "/snippets/*filepath", serveSnippets)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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