mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 支持通过界面设置代码片段 https://github.com/siyuan-note/siyuan/issues/6357
This commit is contained in:
parent
f2236b2328
commit
2c608bf593
4 changed files with 75 additions and 4 deletions
|
@ -98,14 +98,37 @@ func setSnippet(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
id := gulu.Rand.String(12)
|
||||
idArg := arg["id"]
|
||||
if nil != idArg {
|
||||
id = idArg.(string)
|
||||
}
|
||||
name := arg["name"].(string)
|
||||
typ := arg["type"].(string)
|
||||
content := arg["content"].(string)
|
||||
enabled := arg["enabled"].(bool)
|
||||
err := model.SetSnippet(name, typ, content, enabled)
|
||||
snippet, err := model.SetSnippet(id, name, typ, content, enabled)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = "set snippet failed: " + err.Error()
|
||||
return
|
||||
}
|
||||
ret.Data = snippet
|
||||
}
|
||||
|
||||
func removeSnippet(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
if err := model.RemoveSnippet(id); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = "remove snippet failed: " + err.Error()
|
||||
return
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue